diff options
author | SergeyKosarchuk <sergeykosarchuk@gmail.com> | 2018-07-17 10:42:06 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-06-01 12:42:36 +0200 |
commit | 55314ae65ce81d923cc3360a53fbbfba313631f9 (patch) | |
tree | 0223d75e59f6adb0fef8b24312b6990325b126b6 | |
parent | 1448b32cd0dba1e866d1a2c0702f1d3f987f719c (diff) | |
download | pylint-git-55314ae65ce81d923cc3360a53fbbfba313631f9.tar.gz |
Backport: Remove the maximum length from the style regular expressions (#2290)
Close #2047
(cherry picked from commit 0581d30e6297b3080ce12b2fc75a2f5283392e20)
-rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | pylint/checkers/base.py | 16 | ||||
-rw-r--r-- | pylint/test/functional/namePresetCamelCase.txt | 2 | ||||
-rw-r--r-- | pylint/test/functional/name_preset_snake_case.txt | 2 | ||||
-rw-r--r-- | pylint/test/functional/name_styles.py | 4 | ||||
-rw-r--r-- | pylint/test/functional/name_styles.txt | 1 | ||||
-rw-r--r-- | pylintrc | 8 |
8 files changed, 19 insertions, 24 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 1ba25c7b4..d714c90be 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -16,7 +16,7 @@ Order doesn't matter (not that much, at least ;) multiple-imports, not-iterable, not-a-mapping, various patches. * Ashley Whetter: committer - + check_docs extension can find constructor parameters in __init__, added check_raise_docs extension, various patches. @@ -259,7 +259,7 @@ Release date: 2017-12-15 Close #1713 - * Fixing u'' string in superfluous-parens message + * Fixing u'' string in superfluous-parens message Close #1420 @@ -281,7 +281,7 @@ Release date: 2017-12-15 This may lead to args list getting modified if keyword argument's value is not provided in the function call assuming it will take default value provided in the definition. - + * The `invalid-name` check contains the name of the template that caused the failure Close #1176 @@ -333,7 +333,7 @@ Release date: 2017-12-15 * Added a new key-value pair in json output. The key is ``message-id`` and the value is the message id. Close #1512 - + * Added a new Python 3.0 check for raising a StopIteration inside a generator. The check about raising a StopIteration inside a generator is also valid if the exception raised inherit from StopIteration. @@ -402,7 +402,7 @@ Release date: 2017-12-15 Close #1681 * Fix ``line-too-long`` message deactivated by wrong disable directive. - The directive ``disable=fixme`` doesn't deactivate anymore the emission + The directive ``disable=fixme`` doesn't deactivate anymore the emission of ``line-too-long`` message for long commented lines. Close #1741 diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 2d5795248..1d117468c 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -84,8 +84,8 @@ class SnakeCaseStyle(NamingStyle): MOD_NAME_RGX = re.compile('([a-z_][a-z0-9_]*)$') CONST_NAME_RGX = re.compile('(([a-z_][a-z0-9_]*)|(__.*__))$') COMP_VAR_RGX = re.compile('[a-z_][a-z0-9_]*$') - DEFAULT_NAME_RGX = re.compile('(([a-z_][a-z0-9_]{2,30})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$') - CLASS_ATTRIBUTE_RGX = re.compile(r'(([a-z_][a-z0-9_]{2,30}|(__.*__)))$') + DEFAULT_NAME_RGX = re.compile('(([a-z_][a-z0-9_]{2,})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$') + CLASS_ATTRIBUTE_RGX = re.compile(r'(([a-z_][a-z0-9_]{2,}|(__.*__)))$') class CamelCaseStyle(NamingStyle): @@ -93,8 +93,8 @@ class CamelCaseStyle(NamingStyle): MOD_NAME_RGX = re.compile('([a-z_][a-zA-Z0-9]*)$') CONST_NAME_RGX = re.compile('(([a-z_][A-Za-z0-9]*)|(__.*__))$') COMP_VAR_RGX = re.compile('[a-z_][A-Za-z0-9]*$') - DEFAULT_NAME_RGX = re.compile('(([a-z_][a-zA-Z0-9]{2,30})|(__[a-z][a-zA-Z0-9_]+__))$') - CLASS_ATTRIBUTE_RGX = re.compile(r'([a-z_][A-Za-z0-9]{2,30}|(__.*__))$') + DEFAULT_NAME_RGX = re.compile('(([a-z_][a-zA-Z0-9]{2,})|(__[a-z][a-zA-Z0-9_]+__))$') + CLASS_ATTRIBUTE_RGX = re.compile(r'([a-z_][A-Za-z0-9]{2,}|(__.*__))$') class PascalCaseStyle(NamingStyle): @@ -102,8 +102,8 @@ class PascalCaseStyle(NamingStyle): MOD_NAME_RGX = re.compile('[A-Z_][a-zA-Z0-9]+$') CONST_NAME_RGX = re.compile('(([A-Z_][A-Za-z0-9]*)|(__.*__))$') COMP_VAR_RGX = re.compile('[A-Z_][a-zA-Z0-9]+$') - DEFAULT_NAME_RGX = re.compile('[A-Z_][a-zA-Z0-9]{2,30}$|(__[a-z][a-zA-Z0-9_]+__)$') - CLASS_ATTRIBUTE_RGX = re.compile('[A-Z_][a-zA-Z0-9]{2,30}$') + DEFAULT_NAME_RGX = re.compile('[A-Z_][a-zA-Z0-9]{2,}$|(__[a-z][a-zA-Z0-9_]+__)$') + CLASS_ATTRIBUTE_RGX = re.compile('[A-Z_][a-zA-Z0-9]{2,}$') class UpperCaseStyle(NamingStyle): @@ -111,8 +111,8 @@ class UpperCaseStyle(NamingStyle): MOD_NAME_RGX = re.compile('[A-Z_][A-Z0-9_]+$') CONST_NAME_RGX = re.compile('(([A-Z_][A-Z0-9_]*)|(__.*__))$') COMP_VAR_RGX = re.compile('[A-Z_][A-Z0-9_]+$') - DEFAULT_NAME_RGX = re.compile('([A-Z_][A-Z0-9_]{2,30})|(__[a-z][a-zA-Z0-9_]+__)$') - CLASS_ATTRIBUTE_RGX = re.compile('[A-Z_][A-Z0-9_]{2,30}$') + DEFAULT_NAME_RGX = re.compile('([A-Z_][A-Z0-9_]{2,})|(__[a-z][a-zA-Z0-9_]+__)$') + CLASS_ATTRIBUTE_RGX = re.compile('[A-Z_][A-Z0-9_]{2,}$') class AnyStyle(NamingStyle): diff --git a/pylint/test/functional/namePresetCamelCase.txt b/pylint/test/functional/namePresetCamelCase.txt index 7ffec7876..3c31bbcb0 100644 --- a/pylint/test/functional/namePresetCamelCase.txt +++ b/pylint/test/functional/namePresetCamelCase.txt @@ -1,3 +1,3 @@ invalid-name:3::"Constant name ""SOME_CONSTANT"" doesn't conform to camelCase naming style ('(([a-z_][A-Za-z0-9]*)|(__.*__))$' pattern)" invalid-name:10:MyClass:"Class name ""MyClass"" doesn't conform to camelCase naming style ('[a-z_][a-zA-Z0-9]+$' pattern)" -invalid-name:22:say_hello:"Function name ""say_hello"" doesn't conform to camelCase naming style ('(([a-z_][a-zA-Z0-9]{2,30})|(__[a-z][a-zA-Z0-9_]+__))$' pattern)" +invalid-name:22:say_hello:"Function name ""say_hello"" doesn't conform to camelCase naming style ('(([a-z_][a-zA-Z0-9]{2,})|(__[a-z][a-zA-Z0-9_]+__))$' pattern)" diff --git a/pylint/test/functional/name_preset_snake_case.txt b/pylint/test/functional/name_preset_snake_case.txt index 6cecd8518..14a3d6530 100644 --- a/pylint/test/functional/name_preset_snake_case.txt +++ b/pylint/test/functional/name_preset_snake_case.txt @@ -1,3 +1,3 @@ invalid-name:3::"Constant name ""SOME_CONSTANT"" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]*)|(__.*__))$' pattern)" invalid-name:10:MyClass:"Class name ""MyClass"" doesn't conform to snake_case naming style ('[a-z_][a-z0-9_]+$' pattern)" -invalid-name:22:sayHello:"Function name ""sayHello"" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]{2,30})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)" +invalid-name:22:sayHello:"Function name ""sayHello"" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]{2,})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)" diff --git a/pylint/test/functional/name_styles.py b/pylint/test/functional/name_styles.py index dec5c613f..07c1c13c6 100644 --- a/pylint/test/functional/name_styles.py +++ b/pylint/test/functional/name_styles.py @@ -129,10 +129,6 @@ def good_public_function_name(good_arg_name): return good_variable_name + good_arg_name -def too_long_function_name_in_public_scope(): # [invalid-name] - """Public scope function with a too long name""" - return 12 - def _private_scope_function_with_long_descriptive_name(): """Private scope function are cool with long descriptive names""" return 12 diff --git a/pylint/test/functional/name_styles.txt b/pylint/test/functional/name_styles.txt index 63bc1ceb7..74d4fb801 100644 --- a/pylint/test/functional/name_styles.txt +++ b/pylint/test/functional/name_styles.txt @@ -14,4 +14,3 @@ invalid-name:94:test_globals:"Constant name ""AlsoCorrect"" doesn't conform to U invalid-name:107:FooClass.PROPERTY_NAME:"Attribute name ""PROPERTY_NAME"" doesn't conform to snake_case naming style":INFERENCE invalid-name:112:FooClass.ABSTRACT_PROPERTY_NAME:"Attribute name ""ABSTRACT_PROPERTY_NAME"" doesn't conform to snake_case naming style":INFERENCE invalid-name:117:FooClass.PROPERTY_NAME_SETTER:"Attribute name ""PROPERTY_NAME_SETTER"" doesn't conform to snake_case naming style":INFERENCE -invalid-name:132:too_long_function_name_in_public_scope:"Function name ""too_long_function_name_in_public_scope"" doesn't conform to snake_case naming style" @@ -202,10 +202,10 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ # Regular expression matching correct attribute names -attr-rgx=[a-z_][a-z0-9_]{2,30}$ +attr-rgx=[a-z_][a-z0-9_]{2,}$ # Naming hint for attribute names -attr-name-hint=[a-z_][a-z0-9_]{2,30}$ +attr-name-hint=[a-z_][a-z0-9_]{2,}$ # Regular expression matching correct argument names argument-rgx=[a-z_][a-z0-9_]{2,30}$ @@ -238,10 +238,10 @@ module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ # Regular expression matching correct method names -method-rgx=[a-z_][a-z0-9_]{2,30}$ +method-rgx=[a-z_][a-z0-9_]{2,}$ # Naming hint for method names -method-name-hint=[a-z_][a-z0-9_]{2,30}$ +method-name-hint=[a-z_][a-z0-9_]{2,}$ # Regular expression which should only match function or class names that do # not require a docstring. |