Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .flake8

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
pull_request:
branches:
- 'main'
push:
branches:
- main

jobs:
build:
Expand All @@ -22,14 +19,17 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev,test]
python -m pip install --quiet --upgrade pip setuptools
python -m pip install --editable '.[dev,test]'

- name: Run linting
run: |
python -m flake8 -v --config .flake8 --black-config pyproject.toml --show-source
continue-on-error: true
run: |
python -m ruff check -q --diff --output-format=full .
python -m ruff format -q --diff --check .
- name: Run unit tests
run: |
python -m pytest -vvv --cov --cov-context=test --cov-report=xml
48 changes: 24 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PyCQA/autoflake
rev: 'v1.7.8'
hooks:
- id: autoflake
args:
- "--in-place"

- repo: https://github.com/PyCQA/isort
rev: '5.11.5'
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: '22.12.0'
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: '5.0.4'
hooks:
- id: flake8

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.5.0'
rev: 'v4.6.0'
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-ast
- id: check-toml
- id: check-yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
hooks:
# run the linter
- id: ruff
# run the formatter
- id: ruff-format
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ Create a virtual environment:
```bash
python3 -m venv .venv
source .venv/bin/activate
```

Install dependencies:

```bash
python3 -m pip install -U pip setuptools
python3 -m pip install -e '.[test]'
```

Check all answers for 2022:
Check all answers for 2024:

```bash
pytest --cov=. -k 2022
python3 -m pytest --cov=. -k 2024
```

## License
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
155 changes: 110 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,58 +1,127 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
requires = ['setuptools>=64', 'wheel']
build-backend = 'setuptools.build_meta'

[tool.autoflake]
check = true
expand-star-imports = true
remove-all-unused-imports = true
[project]
name = 'aoc'
version = '2.0.0'
description = 'Advent of Code programming puzzles by Rudy Puig.'
license = { file = 'LICENSE.txt' }
readme = 'README.md'
authors = [{ name = 'Rodolfo Puig', email = 'rodolfo@puig.io' }]
requires-python = '~= 3.10'

[tool.isort]
profile = "black"
line_length = 120
lines_between_types = 1
lines_after_imports = 2
combine_as_imports = true
force_single_line = true
known_first_party = ["aoc", "tests"]
single_line_exclusions = ["typing"]
[project.optional-dependencies]
dev = [
'ruff ~= 0.4.7',
'mypy ~= 1.10.0',
]
test = [
'pytest >= 6.0, != 8.1.*',
'pytest-checkdocs >= 2.4',
'pytest-cov',
'pytest-mypy',
'pytest-ruff',
'covdefaults',
'docutils',
]

[tool.setuptools]
package-dir = {'' = 'src'}

[tool.black]
[tool.setuptools.packages.find]
where = ['src']
include = ['aoc']
exclude = ['docs', 'tests']
namespaces = false

[tool.mypy]
check_untyped_defs = true
disallow_any_generics = true
disallow_untyped_calls = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_unused_ignores = true

[tool.ruff]
line-length = 120
target-version = ["py310"]
include = "\\.pyi?$"
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.pytest_cache
| \.tox
| \.venv
| __pycache__
| _build
| build
| dist
)/
'''
indent-width = 4
target-version = 'py310'

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
ignore = []
select = [
'B904',
'E4',
'E7',
'E9',
'F',
'PT009',
'TRY201',
'RUF200',
]
extend-select = ['I']
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ['ALL']
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = '^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$'

[tool.ruff.lint.isort]
case-sensitive = false
combine-as-imports = false
force-sort-within-sections = false
# force-single-line = true
known-first-party = ['aoc']
known-third-party = []
lines-after-imports = 2
lines-between-types = 1
# order-by-type = false
no-lines-before = ['future', 'standard-library']
single-line-exclusions = ['typing']
section-order = [
'future',
'standard-library',
'third-party',
'first-party',
'local-folder',
]

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = 'double'
# Like Black, indent with spaces, rather than tabs.
indent-style = 'space'
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = 'auto'
# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
docstring-code-format = false
# Set the line length limit used when formatting code snippets in
# docstrings.
docstring-code-line-length = 'dynamic'

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["--strict-config", "--strict-markers", "-rpfE", "-q"]
testpaths = ["tests"]
minversion = '6.0'
addopts = ['--strict-config', '--strict-markers', '-rpfE', '-q']
testpaths = ['tests']
xfail_strict = true

[tool.coverage.run]
branch = true
parallel = true
plugins = ["covdefaults"]
source = ["aoc", "tests"]
plugins = ['covdefaults']
source = ['aoc', 'tests']

[tool.coverage.paths]
build = [
"src",
"*/site-packages",
'src',
'*/site-packages',
'*\site-packages',
]

Expand All @@ -63,13 +132,9 @@ show_missing = true
skip_covered = true
skip_empty = true
omit = [
"tests/*",
'tests/*',
]
exclude_lines = []

[tool.coverage.html]
show_contexts = true

[tool.pyright]
include = ["src"]
ignore = ["setup.py", "tests/*"]
48 changes: 0 additions & 48 deletions setup.cfg

This file was deleted.

10 changes: 0 additions & 10 deletions setup.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/aoc/2022/day_03.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import annotations

from string import ascii_letters
from typing import List, Set, Tuple


PRIORITY_TABLE = {l: p for p, l in enumerate(ascii_letters, 1)}
PRIORITY_TABLE = {c: i for i, c in enumerate(ascii_letters, 1)}


class RuckSack:
Expand Down
1 change: 0 additions & 1 deletion src/aoc/2023/day_01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import annotations

from string import digits
from typing import List

Expand Down
5 changes: 1 addition & 4 deletions src/aoc/2024/day_01.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import annotations

from functools import reduce
from operator import countOf
from operator import mul
from operator import sub
from operator import countOf, mul, sub
from typing import Iterable, Iterator, List


Expand Down
Loading
Loading