diff --git a/.envrc b/.envrc index 5669729a..d23567b5 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1 @@ -export VIRTUAL_ENV=.venv -layout python3 +layout python python3.9 diff --git a/.gitignore b/.gitignore index 62044c9b..26ea2c44 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ dist/ # Logs *.log + +# direnv +.direnv/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b3dd12ff..e0a962d0 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,8 @@ "esbenp.prettier-vscode", "ms-python.python", "streetsidesoftware.code-spell-checker", - "tamasfe.even-better-toml" + "tamasfe.even-better-toml", + "ms-python.mypy-type-checker", + "ms-python.black-formatter" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 841650c0..333df77f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,6 @@ "**/.pytest_cache": true, "**/*.egg-info": true }, - "python.formatting.provider": "black", "python.testing.pytestArgs": [ "tests" ], @@ -17,8 +16,9 @@ "[jsonc][markdown]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "python.linting.mypyEnabled": true, - "python.linting.enabled": true, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, "cSpell.words": [ "aocd", "cj's", @@ -26,5 +26,12 @@ "parta", "partb", "popleft" - ] + ], + "evenBetterToml.formatter.allowedBlankLines": 1, + "evenBetterToml.formatter.alignComments": false, + "evenBetterToml.formatter.arrayAutoCollapse": false, + "evenBetterToml.formatter.arrayTrailingComma": true, + "evenBetterToml.formatter.columnWidth": 0, + "evenBetterToml.formatter.trailingNewline": true, + "evenBetterToml.formatter.arrayAutoExpand": false } diff --git a/pyproject.toml b/pyproject.toml index abb64241..5d9dce40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ homepage = "https://github.com/cj81499/advent-of-code" python = ">=3.9" advent-of-code-data = "^2.0.1" more-itertools = "^10.0.0" -numpy = "^1.25.2" # remove me +numpy = "^1.25.2" # TODO: remove me z3-solver = "^4.12.2" lark = "^1.1.7" @@ -33,9 +33,9 @@ omit = [] [tool.coverage.report] exclude_lines = [ - '# pragma: no cover', - 'if __name__ == "__main__":', - 'if TYPE_CHECKING:', + '# pragma: no cover', + 'if __name__ == "__main__":', + 'if TYPE_CHECKING:', 'raise NotImplementedError', '@abc\.abstractmethod', 'assert False', @@ -54,9 +54,9 @@ all = true # skip slow tests by default addopts = "-m 'not slow'" markers = [ - "slow: marks tests as slow" + "slow: marks tests as slow", ] -xfail_strict=true +xfail_strict = true [tool.mypy] strict = true @@ -81,12 +81,12 @@ ignore_missing_imports = true # I may eventually go back and add types to these. [[tool.mypy.overrides]] module = [ - 'aoc_cj.aoc2015.*', - 'aoc_cj.aoc2016.*', - 'aoc_cj.aoc2017.*', - 'aoc_cj.aoc2018.*', - 'aoc_cj.aoc2019.*', - 'aoc_cj.aoc2020.*', + 'aoc_cj.aoc2015.*', + 'aoc_cj.aoc2016.*', + 'aoc_cj.aoc2017.*', + 'aoc_cj.aoc2018.*', + 'aoc_cj.aoc2019.*', + 'aoc_cj.aoc2020.*', ] ignore_errors = true diff --git a/src/aoc_cj/__init__.py b/src/aoc_cj/__init__.py index 43df1381..a13b70bd 100644 --- a/src/aoc_cj/__init__.py +++ b/src/aoc_cj/__init__.py @@ -44,11 +44,11 @@ def solve(year: int, day: int, data: str) -> tuple[Answer, Answer]: # pragma: n def _solve_part(module: ModuleType, data: str, part: Literal["a", "b"]) -> Answer: # pragma: no cover if f := getattr(module, f"part{part}", None): - assert inspect.isfunction(f) + assert inspect.isfunction(f), f"f ({f}) is not a function" try: # TODO: consider checking that inspect.signature matches expected signature resp = f(data) - assert isinstance(resp, (int, str)) + assert isinstance(resp, (int, str)) or resp is None, f"resp ({resp}) must be an int, str, or None" return resp except NotImplementedError: # unsolved return None