From 11e34b9ad57a8e090ddc30aebcf6a7d23a686623 Mon Sep 17 00:00:00 2001 From: Li Yun <3425791734@qq.com> Date: Mon, 8 Jan 2018 17:48:59 +0800 Subject: [PATCH 1/2] Fixing NameChecker's const regex expression could be NoneType bug in Python 3.5 and 3.6 --- pylint_django/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylint_django/plugin.py b/pylint_django/plugin.py index e24ef33c..a5f18543 100644 --- a/pylint_django/plugin.py +++ b/pylint_django/plugin.py @@ -1,5 +1,5 @@ """Common Django module.""" -from pylint.checkers.base import NameChecker +from pylint.checkers.base import NameChecker, UpperCaseStyle from pylint_django.augmentations import apply_augmentations from pylint_plugin_utils import get_checker import re @@ -19,6 +19,8 @@ def register(linter): name_checker.config.good_names += ('qs',) # Default pylint.checkers.base.CONST_NAME_RGX = re.compile('(([A-Z_][A-Z0-9_]*)|(__.*__))$'). + if name_checker.config.const_rgx is None: + name_checker.config.const_rgx = UpperCaseStyle.CONST_NAME_RGX start = name_checker.config.const_rgx.pattern[:-2] end = name_checker.config.const_rgx.pattern[-2:] const_rgx = '%s|(urls|urlpatterns|register)%s' % (start, end) From 9b84ef935d413c6f64b64eded257c282b21c414f Mon Sep 17 00:00:00 2001 From: Li Yun Date: Mon, 8 Jan 2018 17:55:57 +0800 Subject: [PATCH 2/2] Fixing NameChecker's const regex expression could be NoneType bug This bug appears in both Python 3.5 and 3.6 --- pylint_django/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylint_django/plugin.py b/pylint_django/plugin.py index e24ef33c..a5f18543 100644 --- a/pylint_django/plugin.py +++ b/pylint_django/plugin.py @@ -1,5 +1,5 @@ """Common Django module.""" -from pylint.checkers.base import NameChecker +from pylint.checkers.base import NameChecker, UpperCaseStyle from pylint_django.augmentations import apply_augmentations from pylint_plugin_utils import get_checker import re @@ -19,6 +19,8 @@ def register(linter): name_checker.config.good_names += ('qs',) # Default pylint.checkers.base.CONST_NAME_RGX = re.compile('(([A-Z_][A-Z0-9_]*)|(__.*__))$'). + if name_checker.config.const_rgx is None: + name_checker.config.const_rgx = UpperCaseStyle.CONST_NAME_RGX start = name_checker.config.const_rgx.pattern[:-2] end = name_checker.config.const_rgx.pattern[-2:] const_rgx = '%s|(urls|urlpatterns|register)%s' % (start, end)