Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pycqa/pep8-naming
1 result
Show changes
Commits on Source (4)
Loading
Loading
@@ -46,6 +46,8 @@ These error codes are emitted:
+------+-------------------------------------------------------+
| N806 | variable in function should be lowercase |
+------+-------------------------------------------------------+
| N807 | function name should not start or end with '__' |
+------+-------------------------------------------------------+
+------+-------------------------------------------------------+
| N811 | constant imported as non constant |
+------+-------------------------------------------------------+
Loading
Loading
Loading
Loading
@@ -232,22 +232,25 @@ class FunctionNameCheck(BaseASTCheck):
"""
Function names should be lowercase, with words separated by underscores
as necessary to improve readability.
Functions *not* beeing methods '__' in front and back are not allowed.
Functions *not* being methods '__' in front and back are not allowed.
 
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards compatibility.
"""
check = LOWERCASE_REGEX.match
N802 = "function name '{name}' should be lowercase xxx"
N807 = "function name '{name}' should not start or end with '__'"
 
def visit_functiondef(self, node, parents, ignore=None):
function_type = getattr(node, 'function_type', _FunctionType.FUNCTION)
name = node.name
if ignore and name in ignore:
return
if ((function_type == 'function' and '__' in (name[:2], name[-2:])) or
not self.check(name)):
if not self.check(name):
yield self.err(node, 'N802', name)
if function_type == 'function' and '__' in (name[:2], name[-2:]):
yield self.err(node, 'N807', name)
 
 
class FunctionArgNamesCheck(BaseASTCheck):
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ setup(
keywords='flake8 pep8 naming',
author='Florent Xicluna',
author_email='florent.xicluna@gmail.com',
url='https://github.com/flintwork/pep8-naming',
url='https://github.com/PyCQA/pep8-naming',
license='Expat license',
py_modules=['pep8ext_naming'],
install_requires=['flake8_polyfill>=1.0.2,<2'],
Loading
Loading
#: Okay
def ok():
pass
#: N802
def __bad():
pass
#: N802
def bad__():
pass
#: N802
def __bad__():
pass
#: Okay
def _ok():
pass
Loading
Loading
@@ -47,11 +38,6 @@ class ClassName(object):
class ClassName(object):
def notOk(self):
pass
#: N802
class ClassName(object):
def method(self):
def __bad():
pass
#: Okay
def setUp():
pass
Loading
Loading
#: N807
def __bad():
pass
#: N807
def bad__():
pass
#: N807
def __bad__():
pass
#: N807
class ClassName(object):
def method(self):
def __bad():
pass