Skip to content

Add an __init__.py to the cookiecutter hooks - #676

Merged
llucax merged 1 commit into
frequenz-floss:v0.x.xfrom
llucax:add-hooks-init
Dec 1, 2026
Merged

llucax merged 1 commit into
frequenz-floss:v0.x.xfrom
llucax:add-hooks-init

Conversation

@llucax

@llucax llucax commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Pylint now reports F0010: Unable to load file cookiecutter/hooks/__init__.py. This is a regression in pylint 4.1.4 and astroid 4.4.0, either of which is enough to trigger it. I reported it upstream as pylint-dev/pylint#11902.

Adding the __init__.py works with both the old and new versions, and cookiecutter ignores the file.

pylint now fails on `cookiecutter/hooks` with `F0010: Unable to load
file cookiecutter/hooks/__init__.py`. This breaks CI for every PR,
including the Dependabot ones.

The local `cookiecutter/` directory is an implicit namespace package,
and the installed `cookiecutter` package has a `cookiecutter.hooks`
module. Since pylint 4.1.4 and astroid 4.4.0, either of which is enough,
pylint takes `cookiecutter/hooks` for a regular package and looks for an
`__init__.py` that doesn't exist. Both releases include fixes for
pylint-dev/pylint#10278, which seem to cause this regression. I reported
it as pylint-dev/pylint#11902.

Adding the `__init__.py` makes the directory a regular package, which
works with both the old and the new versions. Cookiecutter ignores the
file, because it only runs files named after a hook. Listing the hook
files explicitly in the noxfile would also work, but new files added to
the directory would then be silently left out of the checks.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax llucax added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Dec 1, 2026
@github-actions github-actions Bot added the part:cookiecutter Affects the generation of projects using cookiecutter label Dec 1, 2026
@llucax llucax self-assigned this Dec 1, 2026
@llucax
llucax marked this pull request as ready for review December 1, 2026 14:11
@llucax
llucax requested a review from a team as a code owner December 1, 2026 14:11
@llucax
llucax requested review from Marenz, daniel-zullo-frequenz and florian-wagner-frequenz and removed request for a team December 1, 2026 14:11
@llucax
llucax enabled auto-merge December 1, 2026 14:11
@llucax llucax added this to the v0.20.0 milestone Dec 1, 2026
@llucax
llucax added this pull request to the merge queue Dec 1, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit dd7f45b Dec 1, 2026
10 of 11 checks passed
@llucax
llucax deleted the add-hooks-init branch December 1, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:cookiecutter Affects the generation of projects using cookiecutter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants