Skip to content

Commit

Permalink
Merge pull request #246 from cj81499/2023_08_16
Browse files Browse the repository at this point in the history
2023/08/16
  • Loading branch information
cj81499 authored Aug 17, 2023
2 parents bb624a2 + 4ceea47 commit 22bb07d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export VIRTUAL_ENV=.venv
layout python3
layout python python3.9
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ dist/

# Logs
*.log

# direnv
.direnv/
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
15 changes: 11 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,29 @@
"**/.pytest_cache": true,
"**/*.egg-info": true
},
"python.formatting.provider": "black",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"[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",
"ilen",
"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
}
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/aoc_cj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22bb07d

Please sign in to comment.