Usage¶
This library provides the Flake8 plugin flake8-dunder-all
as well as the
ensure-dunder-all
script which adds __all__
to files that require it.
Flake8 codes¶
Code |
Description |
---|---|
DALL000 |
Module lacks __all__. |
Note
In version 0.3.1
the entry point changed from DALL
to DAL
, due to changes in flake8 itself.
However, the codes remain DALLXXX
and should continue to work as normal.
ensure-dunder-all
script¶
Given a list of Python source files, check each file defines __all__
.
Exit codes:
0: The file already contains a
__all__
declaration or has no function or class definitions.1: A
__all__
declaration was added to the file.4: A file could not be parsed due to a syntax error.
5: Bitwise OR of 1 and 4.
ensure-dunder-all [OPTIONS] FILENAME
Options
-
--use-tuple
¶
Use tuples instead of lists for __all__.
-
--quote-type
<quote_type>
¶ The type of quote to use.
- Default
”
Arguments
-
FILENAME
¶
Optional argument(s). Default
None
pre-commit hooks¶
Using the Flake8 plugin as a pre-commit hook¶
This will only check for missing __all__
declarations but won’t add them.
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-dunder-all==0.3.1
Using the script as a pre-commit hook¶
This will add __all__
to files that require them and prevent the commit if any changes were made.
See pre-commit for instructions.
Sample .pre-commit-config.yaml
:
- repo: https://github.com/python-formate/flake8-dunder-all
rev: v0.3.1
hooks:
- id: ensure-dunder-all