Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flake8 doesn't report mixed-case function names

Tags:

python

pep8

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
like image 347
matthewatabet Avatar asked Feb 25 '15 17:02

matthewatabet


People also ask

Should function names be capitalized Python?

Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names.

Should Python functions be CamelCase?

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.

Should you use camel case or snake case?

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.


1 Answers

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-

like image 97
shadowbq Avatar answered Oct 11 '22 10:10

shadowbq