Skip to content

Commit 2a90ee6

Browse files
Accept Dockerfile filename and pin CI to Python 3.11
- parser: accept extension-less files whose name is in ACCEPTED_FILENAMES (Dockerfile), alongside the existing .lock support, so container/build tooling PRs are not rejected as invalid. Adds tests. - ci: fixit 0.1.4 imports the stdlib distutils removed in Python 3.12; pin setup-python to 3.11 so the test job can collect and run again.
1 parent 43e1bcf commit 2a90ee6

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ jobs:
1212
- uses: actions/checkout@v3
1313
- uses: actions/setup-python@v4
1414
with:
15-
python-version: "3.x"
15+
# fixit 0.1.4 imports the stdlib ``distutils`` module, which was removed
16+
# in Python 3.12. Pin to 3.11 until the fixit pin is upgraded.
17+
python-version: "3.11"
1618
- uses: actions/cache@v3
1719
with:
1820
path: |

‎algorithms_keeper/parser/files_parser.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class BaseFilesParser:
2323
DOCS_EXTENSIONS: Collection[str] = ()
2424
ACCEPTED_EXTENSIONS: Collection[str] = ()
2525

26+
# Extension-less filenames that are nonetheless valid (e.g. ``Dockerfile``).
27+
ACCEPTED_FILENAMES: Collection[str] = ()
28+
2629
def __init__(
2730
self,
2831
pr_files: Iterable[File],
@@ -46,12 +49,15 @@ def validate_extension(self) -> str:
4649
`ACCEPTED_EXTENSIONS` constant.
4750
4851
NOTE: Extensionless files will be considered valid only if it is present in
49-
the ".github" directory. Eg: ".github/CODEOWNERS"
52+
the ".github" directory (eg: ".github/CODEOWNERS") or if its name is listed in
53+
``ACCEPTED_FILENAMES`` (eg: "Dockerfile").
5054
"""
5155
invalid_filepath = []
5256
for file in self.pr_files:
5357
filepath = file.path
5458
if not filepath.suffix:
59+
if filepath.name in self.ACCEPTED_FILENAMES:
60+
continue
5561
if ".github" not in filepath.parts:
5662
if filepath.parent.name: # noqa: SIM114
5763
invalid_filepath.append(file.name)

‎algorithms_keeper/parser/python_parser.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class PythonParser(BaseFilesParser):
8080
*DOCS_EXTENSIONS,
8181
)
8282

83+
# Extension-less files whose exact name is accepted (container/build tooling).
84+
ACCEPTED_FILENAMES: tuple[str, ...] = ("Dockerfile",)
85+
8386
def __init__(
8487
self,
8588
pr_files: Iterable[File],

‎tests/test_parser.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def test_contains_testfile(parser: PythonParser, expected: int) -> None:
5858
),
5959
# Lock files are committed for reproducible CI, so they are valid.
6060
(get_parser("uv.lock, sol1.py"), ""),
61+
# ``Dockerfile`` is an accepted extension-less filename.
62+
(get_parser("Dockerfile, sol1.py"), ""),
63+
(get_parser(".devcontainer/Dockerfile"), ""),
6164
),
6265
)
6366
def test_validate_extension(parser: PythonParser, expected: str) -> None:

0 commit comments

Comments
 (0)