From e985ca230c9bfa1fedcff3570a402fa914d1f3b7 Mon Sep 17 00:00:00 2001 From: mat ess Date: Sun, 13 Aug 2023 12:59:32 -0400 Subject: [PATCH] Housekeeping --- .gitignore | 1 + README.md | 4 +++- flake.lock | 12 ++++++------ flake.nix | 3 ++- justfile | 30 ++++++++++++++++++++++++++++++ pyproject.toml | 33 ++++++++++++++++++++++++--------- roll/__main__.py | 8 ++++---- 7 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 justfile diff --git a/.gitignore b/.gitignore index c13c3e2..21c9d6e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__ .*_cache .pre-commit-config.yaml .vscode +.coverage diff --git a/README.md b/README.md index 43738b1..fe24133 100644 --- a/README.md +++ b/README.md @@ -26,5 +26,7 @@ total | 1 ## todo -- [ ] roll with (dis)advantage +- [x] roll with (dis)advantage - [ ] interactive rolling mode +- [x] print criticals +- [ ] use property testing diff --git a/flake.lock b/flake.lock index 1bf6d71..2d442de 100644 --- a/flake.lock +++ b/flake.lock @@ -74,11 +74,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1691579266, - "narHash": "sha256-Ue2iaxU5VxwjXX6bWv/ElOl35O4+Rk630jBjMqQDRRs=", + "lastModified": 1691931346, + "narHash": "sha256-QLK0wLyJEnLU37CTBNnZBY6mNily7w8zeb34XyhSGh0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a14013769370b021e23200e7199d8cfaeb97098a", + "rev": "8f38b58c34bb759ae83a0581120fe2d7fa6bb539", "type": "github" }, "original": { @@ -133,11 +133,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1691397944, - "narHash": "sha256-4fa4bX3kPYKpEssgrFRxRCPVXczidArDeSWaUMSzQAU=", + "lastModified": 1691747570, + "narHash": "sha256-J3fnIwJtHVQ0tK2JMBv4oAmII+1mCdXdpeCxtIsrL2A=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "e5588ddffd4c3578547a86ef40ec9a6fbdae2986", + "rev": "c5ac3aa3324bd8aebe8622a3fc92eeb3975d317a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index cb38573..d07b199 100644 --- a/flake.nix +++ b/flake.nix @@ -26,9 +26,10 @@ pre-commit.settings.hooks = { autoflake.enable = true; black.enable = true; + mypy.enable = true; ruff.enable = true; - pyright.enable = true; }; + pre-commit.settings.settings.mypy.binPath = "${pkgs.python311Packages.mypy}/bin/mypy"; packages.default = package; devShells.default = pkgs.mkShell { shellHook = '' diff --git a/justfile b/justfile new file mode 100644 index 0000000..2be7b3f --- /dev/null +++ b/justfile @@ -0,0 +1,30 @@ +build: + hatch build + +typing: + hatch run typing:check + +lint: + hatch run lint:check + +fmt: + hatch run lint:fmt + +# run all checks +test: typing lint + hatch run check + +# create hatch envs +env: + #!/usr/bin/env fish + for env in (hatch env show --json | jq 'keys[]' --raw-output) + hatch env create $env + end + +clean: + hatch clean + hatch env purge + rm -r .{mypy,pytest,ruff}_cache + rm -r dist + rm .coverage + fd __pycache__ --no-ignore --exec rm -r diff --git a/pyproject.toml b/pyproject.toml index b257eae..254c9c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ Issues = "https://git.mat.services/mat/roll/issues" Source = "https://git.mat.services/mat/roll" [project.scripts] -roll = "roll.cli:roll" +roll = "roll.cli:cli" [tool.hatch.version] path = "roll/__about__.py" @@ -47,7 +47,7 @@ cov-report = [ "- coverage combine", "coverage report", ] -cov = [ +check = [ "test-cov", "cov-report", ] @@ -55,15 +55,18 @@ cov = [ [[tool.hatch.envs.all.matrix]] python = ["3.11"] +[tool.hatch.envs.typing] +extra-dependencies = ["mypy"] +[tool.hatch.envs.typing.scripts] +check = "mypy --install-types {args:roll tests}" + [tool.hatch.envs.lint] detached = true dependencies = [ "black>=23.1.0", - "pyright>=1.1.319", "ruff>=0.0.243", ] [tool.hatch.envs.lint.scripts] -typing = "pyright --project pyproject.toml {args:roll tests}" style = [ "ruff {args:.}", "black --check --diff {args:.}", @@ -73,19 +76,18 @@ fmt = [ "ruff --fix {args:.}", "style", ] -all = [ +check = [ "style", - "typing", ] [tool.black] target-version = ["py311"] -line-length = 120 -skip-string-normalization = true +line-length = 100 +# skip-string-normalization = true [tool.ruff] target-version = "py311" -line-length = 120 +line-length = 100 select = [ "A", "ARG", @@ -153,8 +155,21 @@ roll = ["roll", "*/roll/roll"] tests = ["tests", "*/roll/tests"] [tool.coverage.report] +show_missing = true +skip_empty = true +fail_under = 100 exclude_lines = [ "no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:", ] + +[tool.mypy] +pretty = true +strict = true + +[[tool.mypy.overrides]] +module = "tests.*" +allow_untyped_defs = true +allow_incomplete_defs = true +check_untyped_defs = true diff --git a/roll/__main__.py b/roll/__main__.py index 2baf08e..b310620 100644 --- a/roll/__main__.py +++ b/roll/__main__.py @@ -1,6 +1,6 @@ -import sys - if __name__ == "__main__": - from roll.cli import roll + import sys - sys.exit(roll()) + from roll.cli import cli + + sys.exit(cli())