flake8-force
Flake8 extension that provides force-check option.
When this option is enabled, flake8 performs all checks even if the target file cannot be interpreted as a Python source code (e.g., when there is a syntax error in the file).
This extension was written to bring back the behavior of flake8 v3.x in flake8 v4.0+ to lint against Cython code. Note that the option is ineffective in flake8 v3.x or earlier.
Installation
pip install flake8-forceUsage
You can enable the flake8-force plugin by either:
- Specifying the option via the command line:
flake8 --force-check .... - Adding
force-check = Trueto the flake8 configuration file.
Tips for checking Cython code
While this extension "forces" flake8 to ignore problems with parsing Cython syntax as Python code, flake8 must be separately configured to permit Cython syntax through ignoring certain rules. The configuration below is suggested for that purpose. Some projects may not need to ignore every rule, depending on the use of Cython. The pycodestyle docs define what each rule means.
[flake8]
filename = *.py,*.pyx,*.pxd,*.pxi
ignore = E203,E225,E226,E227,E402,E741,E901,E999,W503,W504
force-check = TruePre-commit hook
The configuration below can be used with pre-commit to install this extension alongside flake8 and enable checking Cython files. Also see the flake8 docs on version control hooks.
- repo: https://github.com/PyCQA/flake8
rev: '' # Pick a git hash / tag to point to
hooks:
- id: flake8
types: ["file"] # Override the default types (only python)
types_or: ["python", "cython"] # Support both python and cython types
additional_dependencies: ["flake8-force"] # Add this extension
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
