I created a short script called test_pep8.py
containing the following:
def myFunc():
return None
I would expect flake8 to produce a warning about mixed case function names. But, flake8 reports no warnings:
> flake8 --verbose test_pep8.py
checking test_pep8.py
I then ran pep8 directly on the file and got the same result:
import pep8
checker = pep8.Checker('test_pep8.py')
checker.check_all()
> 0
Checking out the pep8 library, I noticed this set of default ignores:
DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704'
But, incorrect function naming doesn't appear to be listed.
Here's my flake8 version info:
> flake8 --version
2.3.0 (pep8: 1.6.2, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.6.6 on Linux
Anyone know why flake8 is not reporting this pep8 violation? Thanks!
EDIT: Just spotted this module: https://pypi.python.org/pypi/pep8-naming Is pep8 naming now enforced by a different library? I seem to remember pep8 covering that before, but I could be mistaken.
pep8-naming does seem to be the solution:
> flake8 --verbose test_pep8.py
checking test_pep8.py
test_pep8.py:5:5: N802 function name should be lowercase
Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names.
1 Answer. PEP8 is Pythons official style guide and it recommends : Function names should be lowercase, with words separated by underscores as necessary to improve readability.
When multiple words are used to form a variable, camel case joins those words together, without any white space, and delineates the start of each new word with a capital letter. In contrast, snake case uses an underscore between words to create separation.
You need to install pep8-naming
pip install pep8-naming
and you should also include it in your pip requirements.txt
flake8
pep8-naming
Additional plugins/extensions for flake8 can be found at https://pypi.org/search/?q=flake8-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With