Pre-commit hook and pyproject-flake8
See original GitHub issueHi 🙂
Thanks for this nice addition to the flake8
ecosystem!
I’m currently working on a project relying on pre-commit-config.yaml
to insure consistency in the code style.
Since the default commit hook does not include your package, I tried using the method described here:
repos:
# Flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [pyproject-flake8]
My config for flake8
in pyproject.toml
is:
[tool.flake8]
ignore = "E203, E266, E501, W503, F403, F401"
exclude = ".git, .mypy_cache, .pytest_cache, build, dist"
max-line-length = 89
max-complexity = 18
select = "B,C,E,F,W,T4,B9"
Yet, when running the commit hook, I get:
E501 line too long (87 > 79 characters)
This means that the configuration is not parsed properly from the pyproject.toml
.
Do you have any idea to solve this?
Thanks 🙂
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Using Version Control Hooks — flake8 6.0.0 documentation
pre -commit creates an isolated environment for hooks. To use flake8 plugins, use the additional_dependencies setting. - id ...
Read more >How to setup your project with pre-commit, black, and flake8
Several OpenStax Python projects use Git hooks via pre-commit in order to run formatting and linting checks before the commit process.
Read more >Automate Python workflow using pre-commits: black and flake8
Good thing, I learned about Git hooks, specifically pre-commit hooks. It enables you to automatically run a short script before commit ting.
Read more >Pre-commit flake8 with setup.cfg in subfolder - Stack Overflow
Root folder has two packages · Each has its own. pyproject.toml (configures black and isort ); setup.cfg (configures flake8 and pydocstyle ).
Read more >Supported hooks - pre-commit
cheetah-reorder-imports - This hook reorders imports in cheetah files. cheetah-flake - Lint cheetah code using flake8 and some other checks.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for the auto-reply, but if someone comes across the same issue, here is a configuration that works. The problem was that the hook used the
flake8
command and notpflake8
:I still like the above configuration because the version of
flake8
is explicitly fixed (while the pre-commit hook in the repository does not specify the version offlake8
; probably the latest one will be used, which potentially leads to some incompatibility in future).