Skip to content

Commit 3393270

Browse files
chore!: migrate to poetry
* chore!: migrate to poetry * chore: reformat project using ruff only * chore: set up git blame ignore revs * chore: update actions to use poetry * chore: remove requirements.*.txt files
1 parent e6e7339 commit 3393270

File tree

83 files changed

+1398
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1398
-349
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Migrate to ruff
2+
73c58b02ea964d62b44b3ded3a33828aaa505910

.github/workflows/tests.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,25 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [ubuntu-latest]
19-
python-version: ['3.11', '3.12']
19+
python-version: ['3.11', '3.12', '3.13']
2020
fail-fast: false
2121

2222
steps:
23-
- uses: actions/checkout@v3
24-
- name: Setup Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v4
23+
- uses: actions/checkout@v4
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
2626
with:
2727
python-version: ${{ matrix.python-version }}
28-
cache: 'pip'
29-
- name: Install
30-
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install hatch
28+
- name: Set up poetry
29+
uses: abatilo/actions-poetry@v2
30+
- name: Install dependencies
31+
run: poetry install --with dev
3332
- name: Run linters
34-
run: hatch run lint:all
33+
run: poetry run ruff check src tests
3534
- name: Run tests
36-
run: hatch run test-cov
35+
run: poetry run pytest --cov
3736
- name: "Upload coverage to Codecov"
38-
if: matrix.python-version == 3.12 # Only upload coverage once per run
37+
if: matrix.python-version == 3.13 # Only upload coverage once per run
3938
uses: codecov/codecov-action@v3
4039
with:
4140
fail_ci_if_error: false

.github/workflows/update_readme.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Set up Python
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: "3.12"
20-
- name: Install package
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install -e .
20+
- name: Set up poetry
21+
uses: abatilo/actions-poetry@v2
22+
- name: Install dependencies
23+
run: poetry install --with dev
2424
- name: Generate new README
2525
run: generate-readme
2626
- name: Commit new README

poetry.lock

Lines changed: 838 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 25 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,195 +1,50 @@
1-
[build-system]
2-
requires = ["hatchling"]
3-
build-backend = "hatchling.build"
4-
5-
[project]
1+
[tool.poetry]
62
name = "adventofcode"
7-
dynamic = ["version"]
3+
version = "1.10.0"
84
description = "A collection of Advent of Code solutions"
9-
readme = "README.md"
10-
requires-python = ">=3.11"
5+
authors = ["Marcel Blijleven <[email protected]>"]
116
license = "MIT"
12-
keywords = []
13-
authors = [
14-
{ name = "Marcel Blijleven", email = "[email protected]" },
15-
]
16-
classifiers = [
17-
"Development Status :: 4 - Beta",
18-
"Programming Language :: Python",
19-
"Programming Language :: Python :: 3.11",
20-
"Programming Language :: Python :: 3.12",
21-
"Programming Language :: Python :: Implementation :: CPython",
22-
"Programming Language :: Python :: Implementation :: PyPy",
23-
]
24-
dependencies = [
25-
"rich>=10",
26-
27-
]
28-
29-
[project.urls]
30-
Documentation = "https://github.com/unknown/adventofcode#readme"
31-
Issues = "https://github.com/unknown/adventofcode/issues"
32-
Source = "https://github.com/unknown/adventofcode"
33-
34-
[project.scripts]
35-
add-day = "adventofcode.scripts.add_day:add_day"
36-
clean-repo = "adventofcode.scripts.clean_repo:clean_repo"
37-
generate-benchmarks = "adventofcode.scripts.benchmarks:generate_benchmarks"
38-
generate-readme = "adventofcode.scripts.generate_readme:generate_readme"
39-
run-all = "adventofcode.scripts.runner:run_all"
40-
41-
42-
[tool.hatch.version]
43-
path = "src/adventofcode/__about__.py"
44-
45-
[tool.hatch.envs.default]
46-
dependencies = [
47-
"httpx",
48-
"coverage[toml]>=6.5",
49-
"pytest",
50-
"pytest-cov",
51-
"pytest-mock>=3.10",
52-
]
53-
[tool.hatch.envs.default.scripts]
54-
test = "pytest {args:tests}"
55-
test-cov = "coverage run -m pytest --cov {args:tests} "
56-
cov-report = [
57-
"- coverage combine",
58-
"coverage report",
59-
]
60-
cov = [
61-
"test-cov",
62-
"cov-report",
63-
]
64-
65-
[[tool.hatch.envs.all.matrix]]
66-
python = ["3.11", "3.12"]
67-
68-
[tool.hatch.envs.lint]
69-
detached = true
70-
dependencies = [
71-
"black>=23.1.0",
72-
"mypy>=1.0.0",
73-
"ruff>=0.0.243",
74-
]
75-
[tool.hatch.envs.lint.scripts]
76-
typing = "mypy --install-types --non-interactive {args:src/adventofcode}"
77-
style = [
78-
"ruff {args:.}",
79-
"black --check --diff {args:.}",
80-
]
81-
fmt = [
82-
"black {args:.}",
83-
"ruff --fix {args:.}",
84-
"style",
85-
]
86-
all = [
87-
"style",
88-
"typing",
89-
]
7+
readme = "README.md"
908

91-
[tool.black]
92-
target-version = ["py311"]
93-
line-length = 120
94-
skip-string-normalization = true
9+
[tool.poetry.dependencies]
10+
python = ">=3.11"
11+
rich = "^13.9.4"
9512

96-
[tool.ruff]
97-
target-version = "py311"
98-
line-length = 120
99-
select = [
100-
"A",
101-
"ARG",
102-
"B",
103-
"C",
104-
"DTZ",
105-
"E",
106-
"EM",
107-
"F",
108-
"FBT",
109-
"I",
110-
"ICN",
111-
"ISC",
112-
"N",
113-
"PLC",
114-
"PLE",
115-
"PLR",
116-
"PLW",
117-
"Q",
118-
"RUF",
119-
"S",
120-
"T",
121-
"TID",
122-
"UP",
123-
"W",
124-
"YTT",
125-
]
126-
ignore = [
127-
# Allow non-abstract empty methods in abstract base classes
128-
"B027",
129-
# Allow boolean positional values in function calls, like `dict.get(... True)`
130-
"FBT003",
131-
# Ignore checks for possible passwords
132-
"S105", "S106", "S107",
133-
# Ignore complexity
134-
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915",
135-
# Use of magic values
136-
"PLR2004",
137-
# Use of boolean default values in function definition
138-
"FBT001", "FBT002",
139-
# Exceptions with string literals
140-
"EM101", "EM102",
141-
# Concatenated string literals on one line
142-
"ISC001",
14313

144-
]
145-
unfixable = [
146-
# Don't touch unused imports
147-
"F401",
148-
]
14+
[tool.poetry.group.dev.dependencies]
15+
httpx = "^0.28.0"
16+
coverage = { extras = ["toml"], version = "^7.6.8" }
17+
pytest = "^8.3.4"
18+
pytest-cov = "^6.0.0"
19+
pytest-mock = "^3.14.0"
20+
ruff = "^0.8.1"
21+
mypy = "^1.13.0"
22+
commitizen = "^4.0.0"
14923

150-
[tool.ruff.isort]
24+
[tool.ruff.lint.isort]
15125
known-first-party = ["adventofcode"]
15226

153-
[tool.ruff.flake8-tidy-imports]
27+
[tool.ruff.lint.flake8-tidy-imports]
15428
ban-relative-imports = "all"
15529

156-
[tool.ruff.per-file-ignores]
157-
# Tests can use magic values, assertions, and relative imports
158-
"tests/**/*" = ["PLR2004", "S101", "TID252"]
159-
16030
[tool.coverage.run]
16131
source_pkgs = ["adventofcode", "tests"]
16232
branch = true
16333
parallel = true
164-
omit = [
165-
"src/adventofcode/__about__.py",
166-
]
34+
omit = ["src/adventofcode/__about__.py"]
16735

16836
[tool.coverage.paths]
169-
adventofcode = ["src/adventofcode", "*/adventofcode/src/adventofcode"]
37+
adventofcode = ["src/adventofcode", "*/adventofcode/arc/adventofcode"]
17038
tests = ["tests", "*/adventofcode/tests"]
17139

17240
[tool.coverage.report]
173-
exclude_lines = [
174-
"no cov",
175-
"if __name__ == .__main__.:",
176-
"if TYPE_CHECKING:",
177-
]
41+
exclude_lines = ["no cov", "if __name__ == __main__:", "if TYPE_CHECKING:"]
17842

17943
[tool.commitizen]
18044
tag_format = "v$version"
18145
version = "1.10.0"
182-
version_files = [
183-
"src/adventofcode/__about__.py",
184-
]
46+
version_files = ["src/adventofcode/__about__.py"]
18547

186-
[[tool.mypy.overrides]]
187-
module = [
188-
"rich.console",
189-
"rich.table",
190-
"httpx",
191-
"utils",
192-
"config",
193-
]
194-
disable_error_code = ["name-defined"]
195-
ignore_missing_imports = true
48+
[build-system]
49+
requires = ["poetry-core"]
50+
build-backend = "poetry.core.masonry.api"

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements_dev.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/adventofcode/scripts/add_day.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def add_day():
2828
write_solution_template(solution_file, year, day)
2929

3030
# Test file
31-
test_module_path = os.path.abspath(os.path.join(ROOT_DIR, "../../tests/adventofcode", f"year_{year}"))
31+
test_module_path = os.path.abspath(
32+
os.path.join(ROOT_DIR, "../../tests/adventofcode", f"year_{year}")
33+
)
3234
test_file = os.path.join(test_module_path, f"test_day_{day:02}_{year}.py")
3335
create_module_dir(test_module_path)
3436
write_test_template(test_file, year, day)
@@ -42,7 +44,10 @@ def write_solution_template(path: str, year: int, day: int) -> None:
4244
write_template(path, read_solution_template(year, day))
4345
console.print(f"[green]Wrote template to {path}")
4446
else:
45-
console.print(f"[yellow]Did not write template for year {year} day {day}" ", the file already exists.")
47+
console.print(
48+
f"[yellow]Did not write template for year {year} day {day}"
49+
", the file already exists."
50+
)
4651

4752

4853
def write_test_template(path: str, year: int, day: int) -> None:
@@ -51,7 +56,10 @@ def write_test_template(path: str, year: int, day: int) -> None:
5156
write_template(path, read_test_template(year, day))
5257
console.print(f"[green]Wrote test template to {path}")
5358
else:
54-
console.print(f"[yellow]Did not write test template for year {year} day {day}" ", the file already exists.")
59+
console.print(
60+
f"[yellow]Did not write test template for year {year} day {day}"
61+
", the file already exists."
62+
)
5563

5664

5765
def create_module_dir(path: str) -> None:
@@ -73,19 +81,27 @@ def verify_input_exists(year: int, day: int) -> None:
7381
"""Verifies if user input exists, and downloads it if not"""
7482
try:
7583
_ = get_input_for_day(year, day)
76-
console.print(f"Input data already exists for year {year} day {day}, skipping download")
84+
console.print(
85+
f"Input data already exists for year {year} day {day}, skipping download"
86+
)
7787
return
7888
except FileNotFoundError:
7989
try:
8090
get_input(year, day)
81-
console.print(f"Automatically downloaded input data for year {year} day {day}")
91+
console.print(
92+
f"Automatically downloaded input data for year {year} day {day}"
93+
)
8294
return
8395
except HTTPError as e:
84-
console.print("[red]Could not retrieve input data for " f"year {year} day {day} automatically: {e}")
96+
console.print(
97+
"[red]Could not retrieve input data for "
98+
f"year {year} day {day} automatically: {e}"
99+
)
85100
return
86101
except FileNotFoundError:
87102
console.print(
88-
"[red]Could not retrieve input data for " f"year {year} day {day}: .session not set correctly"
103+
"[red]Could not retrieve input data for "
104+
f"year {year} day {day}: .session not set correctly"
89105
)
90106
return
91107

0 commit comments

Comments
 (0)