invalid-function-name (N802) 函数名称无效 (N802)
源自 pep8-naming linter。
作用
Checks for functions names that do not follow the snake_case
naming convention. 检查不遵循 snake_case
命名约定的函数名称。
为什么这不好?
PEP 8 recommends that function names follow snake_case
PEP 8 建议函数名称遵循 snake_case
命名规范。
Function names should be lowercase, with words separated by underscores as necessary to improve readability. mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility. 函数名称应为小写,单词之间用下划线分隔,以提高可读性。mixedCase 仅在已经是主要风格的上下文中才允许使用(例如 threading.py),以保持向后兼容性。
Names can be excluded from this rule using the lint.pep8-naming.ignore-names
or lint.pep8-naming.extend-ignore-names
configuration options. For example, to ignore all functions starting with test_
from this rule, set the lint.pep8-naming.extend-ignore-names
option to ["test_*"]
. 可以使用 lint.pep8-naming.ignore-names
或 lint.pep8-naming.extend-ignore-names
配置选项从此规则中排除名称。 例如,要从此规则中忽略所有以 test_
开头的函数,请将 lint.pep8-naming.extend-ignore-names
选项设置为 ["test_*"]
。
示例
建议改为