Skip to content

Commit c36c1eb

Browse files
committed
Keep the original message name
1 parent 54709b8 commit c36c1eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+76
-54
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Release date: TBA
1414

1515
Closes #5588
1616

17-
* Renamed ``non-ascii-name`` to ``non-ascii-identifier`` and rewrote the checker.
17+
* Rewrote checker for ``non-ascii-name``.
1818
It now ensures __all__ Python names are ASCII and also properly
1919
checks the names of imports (``non-ascii-module-import``) as
2020
well as file names (``non-ascii-file-name``) and emits their respective new warnings.

doc/whatsnew/2.13.rst

Lines changed: 1 addition & 1 deletion

pylint/checkers/non_ascii_names.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ class NonAsciiNamesChecker(
6363
msgs = {
6464
"C2401": (
6565
'%s name "%s" contains a non-ASCII character, consider renaming it.',
66-
"non-ascii-identifier",
66+
"non-ascii-name",
6767
(
6868
"Used when the name contains at least one non-ASCII unicode character. "
6969
"See https://www.python.org/dev/peps/pep-0672/#confusable-characters-in-identifiers"
7070
" for a background why this could be bad."
7171
),
72-
{"old_names": [("C0144", "non-ascii-name")]},
72+
{"old_names": [("C0144", "old-non-ascii-name")]},
7373
),
7474
# First %s will always be "file"
7575
"W2402": (
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" Tests for non-ascii-name checker. """
22

3-
áéíóú = 4444 # [non-ascii-identifier]
3+
áéíóú = 4444 # [non-ascii-name]
44

5-
def úóíéá(): # [non-ascii-identifier]
5+
def úóíéá(): # [non-ascii-name]
66
"""yo"""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
non-ascii-identifier:3:0:3:10::"Variable name ""áéíóú"" contains a non-ASCII character, consider renaming it.":HIGH
2-
non-ascii-identifier:5:0:6:12:úóíéá:"Function name ""úóíéá"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:3:0:3:10::"Variable name ""áéíóú"" contains a non-ASCII character, consider renaming it.":HIGH
2+
non-ascii-name:5:0:6:12:úóíéá:"Function name ""úóíéá"" contains a non-ASCII character, consider renaming it.":HIGH
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Assigment Expression as defined in https://www.python.org/dev/peps/pep-0572/"""
22

3-
if (loł := __name__) == "__main__": # [non-ascii-identifier]
3+
if (loł := __name__) == "__main__": # [non-ascii-name]
44
print(loł)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:3:4:3:8::"Variable name ""loł"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:3:4:3:8::"Variable name ""loł"" contains a non-ASCII character, consider renaming it.":HIGH
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Ensure that also decorator calls caught correctly
3+
Column and line not correctly detected with Python 3.8, so we
4+
skip it and only test versions after that.
5+
"""
6+
7+
8+
def decoractor_func(*args, **kwargs):
9+
"""A docstring"""
10+
return lambda x: f"Foobar {args} {kwargs}"
11+
12+
13+
@decoractor_func(
14+
aaaaaaaaaaaaaaaaaaalllllllooooooooooooonnngggggggggglllline=1,
15+
normal=2,
16+
fåling=3, # [non-ascii-name]
17+
)
18+
def a_function():
19+
"""A docstring"""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[testoptions]
2+
min_pyver=3.9
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
non-ascii-name:14:4:14:13:a_function:"Argument name ""fåling"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_for_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
def main():
77
"""main func"""
8-
# +2: [non-ascii-identifier]
8+
# +2: [non-ascii-name]
99
a_variable = ""
1010
for łol in os.listdir("."):
1111
# Usage should not raise a second error
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:10:8:10:12:main:"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:10:8:10:12:main:"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def sayHello():
77
print("Hello, World!")
88

99

10-
# +3: [non-ascii-identifier]
10+
# +3: [non-ascii-name]
1111

1212

1313
def sayНello():
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:13:0:15:28:sayНello:"Function name ""sayНello"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:13:0:15:28:sayНello:"Function name ""sayНello"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_function_argument_py38.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def okay(
99
just_some_thing_long_again: str,
1010
lol_very_long_argument: str,
11-
łol: str, # [non-ascii-identifier]
11+
łol: str, # [non-ascii-name]
1212
) -> bool:
1313
"""Be okay, yeah?"""
1414
# Usage should not raise a second error
@@ -20,5 +20,5 @@ def okay(
2020
okay(
2121
"A VVVVVVVEEEERRRRRRRRRRYYYYYYYYYY LONG TIME ",
2222
lol_very_long_argument="a",
23-
łol="b", # [non-ascii-identifier]
23+
łol="b", # [non-ascii-name]
2424
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
non-ascii-identifier:11:4:11:13:okay:"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
2-
non-ascii-identifier:23:0:None:None::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:11:4:11:13:okay:"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
2+
non-ascii-name:23:0:None:None::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_function_argument_py39plus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def okay(
1010
just_some_thing_long_again: str,
1111
lol_very_long_argument: str,
12-
łol: str, # [non-ascii-identifier]
12+
łol: str, # [non-ascii-name]
1313
) -> bool:
1414
"""Be okay, yeah?"""
1515
# Usage should not raise a second error
@@ -21,5 +21,5 @@ def okay(
2121
okay(
2222
"A VVVVVVVEEEERRRRRRRRRRYYYYYYYYYY LONG TIME ",
2323
lol_very_long_argument="a",
24-
łol="b", # [non-ascii-identifier]
24+
łol="b", # [non-ascii-name]
2525
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
non-ascii-identifier:12:4:12:13:okay:"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
2-
non-ascii-identifier:24:4:24:12::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:12:4:12:13:okay:"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
2+
non-ascii-name:24:4:24:12::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_inline_var.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
foo = [
66
f"{łol} "
7-
for łol in os.listdir(".") # [non-ascii-identifier]
7+
for łol in os.listdir(".") # [non-ascii-name]
88
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:7:8:7:12::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:7:8:7:12::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_kwargs_py38.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ def okay(**kwargs):
1313
okay(
1414
a_long_attribute_that_is_very_okay=1,
1515
b_belongs_to_yet_another_okay_attributed=2,
16-
łol=3, # [non-ascii-identifier]
16+
łol=3, # [non-ascii-name]
1717
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:16:0:None:None::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:16:0:None:None::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_kwargs_py39plus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ def okay(**kwargs):
1414
okay(
1515
a_long_attribute_that_is_very_okay=1,
1616
b_belongs_to_yet_another_okay_attributed=2,
17-
łol=3, # [non-ascii-identifier]
17+
łol=3, # [non-ascii-name]
1818
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:17:4:17:10::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:17:4:17:10::"Argument name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def okay():
55
"""docstring"""
6-
łol = "foo" # [non-ascii-identifier]
6+
łol = "foo" # [non-ascii-name]
77
# Usage should not raise a second error
88
baring = łol
99
print(baring)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:6:4:6:8:okay:"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:6:4:6:8:okay:"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_pos_and_kwonly_function.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
def name(
88
some_thing_long_but_okay,
9-
not_okay_łol, # [non-ascii-identifier]
10-
not_okay_defaułt=None, # [non-ascii-identifier]
9+
not_okay_łol, # [non-ascii-name]
10+
not_okay_defaułt=None, # [non-ascii-name]
1111
/,
1212
p_or_kw_okay=None,
13-
p_or_kw_not_økay=None, # [non-ascii-identifier]
13+
p_or_kw_not_økay=None, # [non-ascii-name]
1414
*,
1515
kw_arg_okay,
16-
kw_arg_not_økay, # [non-ascii-identifier]
16+
kw_arg_not_økay, # [non-ascii-name]
1717
):
1818
"""
1919
Do something!
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
non-ascii-identifier:9:4:9:17:name:"Argument name ""not_okay_łol"" contains a non-ASCII character, consider renaming it.":HIGH
2-
non-ascii-identifier:10:4:10:21:name:"Argument name ""not_okay_defaułt"" contains a non-ASCII character, consider renaming it.":HIGH
3-
non-ascii-identifier:13:4:13:21:name:"Argument name ""p_or_kw_not_økay"" contains a non-ASCII character, consider renaming it.":HIGH
4-
non-ascii-identifier:16:4:16:20:name:"Argument name ""kw_arg_not_økay"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:9:4:9:17:name:"Argument name ""not_okay_łol"" contains a non-ASCII character, consider renaming it.":HIGH
2+
non-ascii-name:10:4:10:21:name:"Argument name ""not_okay_defaułt"" contains a non-ASCII character, consider renaming it.":HIGH
3+
non-ascii-name:13:4:13:21:name:"Argument name ""p_or_kw_not_økay"" contains a non-ASCII character, consider renaming it.":HIGH
4+
non-ascii-name:16:4:16:20:name:"Argument name ""kw_arg_not_økay"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_staticmethod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def public(self):
88
"""Say it load"""
99

1010
@staticmethod
11-
def umlaut_ä(): # [non-ascii-identifier]
11+
def umlaut_ä(): # [non-ascii-name]
1212
"""Say ä"""
1313
return "ä"
1414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:11:4:13:19:OkayClass.umlaut_ä:"Function name ""umlaut_ä"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:11:4:13:19:OkayClass.umlaut_ä:"Function name ""umlaut_ä"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_try_except.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
try:
77
raise AttributeError("Test")
8-
# +1: [non-ascii-identifier]
8+
# +1: [non-ascii-name]
99
except AttributeError as łol:
1010
# Usage should not raise a second error
1111
foo = łol
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:9:0:11:14::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:9:0:11:14::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name/non_ascii_name_variable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# pylint: disable=invalid-name
55

66
# Test invalid variable name
7-
łol = "Foobar" # [non-ascii-identifier]
7+
łol = "Foobar" # [non-ascii-name]
88
# Usage should not raise a second error
9-
łol += "-" # [non-ascii-identifier]
9+
łol += "-" # [non-ascii-name]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
non-ascii-identifier:7:0:7:4::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
2-
non-ascii-identifier:9:0:9:4::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:7:0:7:4::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH
2+
non-ascii-name:9:0:9:4::"Variable name ""łol"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name_class/non_ascii_name_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pylint: disable=too-few-public-methods
33

44

5-
class НoldIt: # [non-ascii-identifier]
5+
class НoldIt: # [non-ascii-name]
66
"""nice classs"""
77

88
def public(self):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:5:0:10:19:НoldIt:"Class name ""НoldIt"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:5:0:10:19:НoldIt:"Class name ""НoldIt"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name_class/non_ascii_name_class_attribute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def public(self):
99
print(self)
1010

1111
def __init__(self):
12-
self.łoopback = "invalid" # [non-ascii-identifier]
12+
self.łoopback = "invalid" # [non-ascii-name]
1313

1414
def foobar(self):
1515
"""do something"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:12:8:12:22:OkayIsh.__init__:"Attribute name ""łoopback"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:12:8:12:22:OkayIsh.__init__:"Attribute name ""łoopback"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name_class/non_ascii_name_class_constant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class OkayIsh:
55
"""Class docstring"""
6-
ŁOOPBACK = "invalid" # [non-ascii-identifier]
6+
ŁOOPBACK = "invalid" # [non-ascii-name]
77

88

99
def more_public(self):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:6:4:6:13:OkayIsh:"Attribute name ""ŁOOPBACK"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:6:4:6:13:OkayIsh:"Attribute name ""ŁOOPBACK"" contains a non-ASCII character, consider renaming it.":HIGH

tests/functional/n/non_ascii_name_class/non_ascii_name_class_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def public(self):
99
print(self)
1010

1111
@classmethod
12-
def umlaut_ä(cls): # [non-ascii-identifier]
12+
def umlaut_ä(cls): # [non-ascii-name]
1313
"""do something"""
1414
return "ä"
1515

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
non-ascii-identifier:12:4:14:19:OkayClass.umlaut_ä:"Function name ""umlaut_ä"" contains a non-ASCII character, consider renaming it.":HIGH
1+
non-ascii-name:12:4:14:19:OkayClass.umlaut_ä:"Function name ""umlaut_ä"" contains a non-ASCII character, consider renaming it.":HIGH

0 commit comments

Comments
 (0)