summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kolbus <peter.kolbus@gmail.com>2020-11-29 07:57:39 -0600
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-03-09 09:13:05 +0100
commitf17007b55e79af1e36d4aad5ec1802fe1ba51662 (patch)
tree00c60e4bd88a3d31cb769708a9b4345b48c215e0
parentd19c7733717ae9ad0a527233c2950473dce3ffcf (diff)
downloadpylint-git-f17007b55e79af1e36d4aad5ec1802fe1ba51662.tar.gz
Remove 'blacklist' term for good/bad identifiers
Replace blacklist/whitelist terminology in the context of identifier names. The message identifier 'blacklisted-name' will be addressed in a future patch; a transition path is needed because this message may be referenced in pylintrc files or disable comments.
-rw-r--r--ChangeLog4
-rw-r--r--doc/whatsnew/2.5.rst4
-rw-r--r--pylint/checkers/base.py14
-rw-r--r--pylint/extensions/bad_builtin.py4
-rw-r--r--tests/functional/a/async_functions.txt2
-rw-r--r--tests/functional/b/blacklisted_name.txt2
-rw-r--r--tests/functional/n/name/name_good_bad_names_regex.py2
-rw-r--r--tests/functional/n/name/name_good_bad_names_regex.rc2
-rw-r--r--tests/functional/n/name/name_good_bad_names_regex.txt4
9 files changed, 19 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index e6a1a8e74..0819b7786 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5069,7 +5069,7 @@ Release date: 2003-11-20
__init__ files, and provides a new option ignore-interface-methods,
useful when you're using zope Interface implementation in your project
- * base checker checks for black listed builtins call (controlled by the
+ * base checker checks for disallowed builtins call (controlled by the
bad-functions option) and for use of * and **
* format checker checks for use of <> and "l" as long int marker
@@ -5106,7 +5106,7 @@ Release date: 2003-11-20
* still fixes in format checker : don't check comment and docstring,
check first line after an indent
- * black and white list now apply to all identifiers, not only
+ * allowed/prohibited names now apply to all identifiers, not only
variables, so changed the configuration option from
(good|bad)-variable-names to (good|bad)-names
diff --git a/doc/whatsnew/2.5.rst b/doc/whatsnew/2.5.rst
index 15731dd5f..f926f5940 100644
--- a/doc/whatsnew/2.5.rst
+++ b/doc/whatsnew/2.5.rst
@@ -64,9 +64,9 @@ Other Changes
* Add new ``good-names-rgx`` and ``bad-names-rgx`` to enable permitting or disallowing of names via regular expressions
- To enable better handling of whitelisting/blacklisting names, we added two new config options: good-names-rgxs: a comma-
+ To enable better handling of permitted/disallowed names, we added two new config options: good-names-rgxs: a comma-
separated list of regexes, that if a name matches will be exempt of naming-checking. bad-names-rgxs: a comma-
- separated list of regexes, that if a name matches will be always marked as a blacklisted name.
+ separated list of regexes, that if a name matches will be always marked as a disallowed name.
* Mutable ``collections.*`` are now flagged as dangerous defaults.
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 393a433fd..1c30acddf 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1421,7 +1421,7 @@ class BasicChecker(_BasicChecker):
"eval-used", "exec-used", "bad-reversed-sequence", "misplaced-format-function"
)
def visit_call(self, node):
- """visit a Call node -> check if this is not a blacklisted builtin
+ """visit a Call node -> check if this is not a disallowed builtin
call and check for * or ** use
"""
self._check_misplaced_format_function(node)
@@ -1725,9 +1725,9 @@ def _create_naming_options():
class NameChecker(_BasicChecker):
msgs = {
"C0102": (
- 'Black listed name "%s"',
+ 'Disallowed name "%s"',
"blacklisted-name",
- "Used when the name is listed in the black list (unauthorized names).",
+ "Used when the name matches bad-names or bad-names-rgxs- (unauthorized names).",
),
"C0103": (
'%s name "%s" doesn\'t conform to %s',
@@ -2025,12 +2025,12 @@ class NameChecker(_BasicChecker):
self.add_message(warning, node=node, args=args, confidence=confidence)
self.stats["badname_" + node_type] += 1
- def _name_valid_due_to_whitelist(self, name: str) -> bool:
+ def _name_allowed_by_regex(self, name: str) -> bool:
return name in self.config.good_names or any(
pattern.match(name) for pattern in self._good_names_rgxs_compiled
)
- def _name_invalid_due_to_blacklist(self, name: str) -> bool:
+ def _name_disallowed_by_regex(self, name: str) -> bool:
return name in self.config.bad_names or any(
pattern.match(name) for pattern in self._bad_names_rgxs_compiled
)
@@ -2056,9 +2056,9 @@ class NameChecker(_BasicChecker):
clobbering, _ = utils.clobber_in_except(node)
if clobbering:
return
- if self._name_valid_due_to_whitelist(name=name):
+ if self._name_allowed_by_regex(name=name):
return
- if self._name_invalid_due_to_blacklist(name=name):
+ if self._name_disallowed_by_regex(name=name):
self.stats["badname_" + node_type] += 1
self.add_message("blacklisted-name", node=node, args=name)
return
diff --git a/pylint/extensions/bad_builtin.py b/pylint/extensions/bad_builtin.py
index 1d74c11c2..de4271372 100644
--- a/pylint/extensions/bad_builtin.py
+++ b/pylint/extensions/bad_builtin.py
@@ -27,8 +27,8 @@ class BadBuiltinChecker(BaseChecker):
"W0141": (
"Used builtin function %s",
"bad-builtin",
- "Used when a black listed builtin function is used (see the "
- "bad-function option). Usual black listed functions are the ones "
+ "Used when a disallowed builtin function is used (see the "
+ "bad-function option). Usual disallowed functions are the ones "
"like map, or filter , where Python offers now some cleaner "
"alternative like list comprehension.",
)
diff --git a/tests/functional/a/async_functions.txt b/tests/functional/a/async_functions.txt
index 01bdec668..6eb64e253 100644
--- a/tests/functional/a/async_functions.txt
+++ b/tests/functional/a/async_functions.txt
@@ -7,5 +7,5 @@ too-many-return-statements:26:0:complex_function:Too many return statements (10/
dangerous-default-value:57:0:func:Dangerous default value [] as argument
duplicate-argument-name:57:15:func:Duplicate argument name a in function definition
duplicate-argument-name:57:18:func:Duplicate argument name a in function definition
-blacklisted-name:62:0:foo:Black listed name "foo"
+blacklisted-name:62:0:foo:Disallowed name "foo"
empty-docstring:62:0:foo:Empty function docstring
diff --git a/tests/functional/b/blacklisted_name.txt b/tests/functional/b/blacklisted_name.txt
index fd2b9a1e4..160bb6b9f 100644
--- a/tests/functional/b/blacklisted_name.txt
+++ b/tests/functional/b/blacklisted_name.txt
@@ -1 +1 @@
-blacklisted-name:3:0:baz:Black listed name "baz"
+blacklisted-name:3:0:baz:Disallowed name "baz"
diff --git a/tests/functional/n/name/name_good_bad_names_regex.py b/tests/functional/n/name/name_good_bad_names_regex.py
index f1ed4b91b..35f88b7a8 100644
--- a/tests/functional/n/name/name_good_bad_names_regex.py
+++ b/tests/functional/n/name/name_good_bad_names_regex.py
@@ -16,5 +16,5 @@ class my_class:
return self._my_secret_x * 2
-def blacklisted_2_snake_case(): # [blacklisted-name]
+def disallowed_2_snake_case(): # [blacklisted-name]
pass
diff --git a/tests/functional/n/name/name_good_bad_names_regex.rc b/tests/functional/n/name/name_good_bad_names_regex.rc
index 8246438cd..abb08ce3b 100644
--- a/tests/functional/n/name/name_good_bad_names_regex.rc
+++ b/tests/functional/n/name/name_good_bad_names_regex.rc
@@ -11,5 +11,5 @@ inlinevar-naming-style=snake_case
class-naming-style=snake_case
good-names-rgxs=ignored.*
-bad-names-rgxs=explicit.*,blacklisted.*
+bad-names-rgxs=explicit.*,disallowed.*
include-naming-hint=yes
diff --git a/tests/functional/n/name/name_good_bad_names_regex.txt b/tests/functional/n/name/name_good_bad_names_regex.txt
index 08aef7d78..4bced1323 100644
--- a/tests/functional/n/name/name_good_bad_names_regex.txt
+++ b/tests/functional/n/name/name_good_bad_names_regex.txt
@@ -1,3 +1,3 @@
-blacklisted-name:5:0::Black listed name "explicit_bad_some_constant"
+blacklisted-name:5:0::Disallowed name "explicit_bad_some_constant"
invalid-name:7:0::"Constant name ""snake_case_bad_SOME_CONSTANT"" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]*|__.*__)$' pattern)"
-blacklisted-name:19:0:blacklisted_2_snake_case:Black listed name "blacklisted_2_snake_case"
+blacklisted-name:19:0:disallowed_2_snake_case:Disallowed name "disallowed_2_snake_case"