Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Add an example for 'non-ascii-file-name' #8340

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/data/messages/n/non-ascii-file-name/bad/bàd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# [non-ascii-file-name]
1 change: 1 addition & 0 deletions doc/data/messages/n/non-ascii-file-name/bad/not_bétter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# [non-ascii-file-name]
1 change: 0 additions & 1 deletion doc/data/messages/n/non-ascii-file-name/details.rst

This file was deleted.

1 change: 0 additions & 1 deletion doc/data/messages/n/non-ascii-file-name/good.py

This file was deleted.

Empty file.
Empty file.
3 changes: 3 additions & 0 deletions doc/data/messages/n/non-ascii-file-name/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `PEP 489 <https://peps.python.org/pep-0489/#export-hook-name>`_
- `PEP 672 <https://peps.python.org/pep-0672/#confusing-features>`_
- `Python issue 20485 <https://bugs.python.org/issue20485>`_
15 changes: 6 additions & 9 deletions doc/user_guide/checkers/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,10 @@ Verbatim name of the checker is ``nonascii-checker``.

Nonascii-Checker checker Messages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:non-ascii-file-name (W2402): *%s name "%s" contains a non-ASCII character. PEP 3131 only allows non-ascii identifiers, not file names.*
Some editors don't support non-ASCII file names properly. Even though Python
supports UTF-8 files since Python 3.5 this isn't recommended for
interoperability. Further reading: -
https://peps.python.org/pep-0489/#export-hook-name -
https://peps.python.org/pep-0672/#confusing-features -
https://bugs.python.org/issue20485
:non-ascii-file-name (W2402): *%s name "%s" contains a non-ASCII character.*
Under python 3.5, PEP 3131 only allows non-ascii identifiers, not file
names.Since Python 3.5, even though Python supports UTF-8 files, some editors
or tools don't.
:non-ascii-name (C2401): *%s name "%s" contains a non-ASCII character, consider renaming it.*
Used when the name contains at least one non-ASCII unicode character. See
https://peps.python.org/pep-0672/#confusing-features for a background why
Expand Down Expand Up @@ -1363,8 +1360,8 @@ Variables checker Messages
:unused-variable (W0612): *Unused variable %r*
Used when a variable is defined but not used.
:global-variable-not-assigned (W0602): *Using global for %r but no assignment is done*
When a variable defined in the global scope is modified in an inner scope, the
'global' keyword is required in the inner scope only if there is an
When a variable defined in the global scope is modified in an inner scope,
the 'global' keyword is required in the inner scope only if there is an
assignment operation done in the inner scope.
:undefined-loop-variable (W0631): *Using possibly undefined loop variable %r*
Used when a loop variable (i.e. defined by a for loop or a list comprehension
Expand Down
18 changes: 10 additions & 8 deletions doc/user_guide/configuration/all-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@ Standard Checkers
**Default:** ``(3, 10)``


--source-roots
""""""""""""""
*Add paths to the list of the source roots. The source root is an absolute path or a path relative to the current working directory used to determine a package namespace for modules located under the source root.*

**Default:** ``()``


--recursive
"""""""""""
*Discover python modules and packages in the file system subtree.*
Expand All @@ -202,6 +195,13 @@ Standard Checkers
**Default:** ``True``


--source-roots
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be part of this MR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot to generate the doc previousely because of #6736

""""""""""""""
*Add paths to the list of the source roots. Supports globbing patterns. The source root is an absolute path or a path relative to the current working directory used to determine a package namespace for modules located under the source root.*

**Default:** ``()``


--suggestion-mode
"""""""""""""""""
*When enabled, pylint would attempt to guess common misconfiguration and emit user-friendly hints instead of false-positive error messages.*
Expand Down Expand Up @@ -279,6 +279,8 @@ Standard Checkers

score = true

source-roots = []

suggestion-mode = true

unsafe-load-any-extension = false
Expand Down Expand Up @@ -1000,7 +1002,7 @@ Standard Checkers

--preferred-modules
"""""""""""""""""""
*Couples of modules and preferred modules, separated by a comma. Submodules may also be specified using '.' syntax (for ex. 'os.path').*
*Couples of modules and preferred modules, separated by a comma.*

**Default:** ``()``

Expand Down
19 changes: 6 additions & 13 deletions pylint/checkers/non_ascii_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,15 @@ class NonAsciiNameChecker(base_checker.BaseChecker):
),
# First %s will always be "file"
"W2402": (
(
'%s name "%s" contains a non-ASCII character. PEP 3131 only allows '
"non-ascii identifiers, not file names."
),
'%s name "%s" contains a non-ASCII character.',
"non-ascii-file-name",
(
# Some = PyCharm at the time of writing didn't display the non_ascii_name_loł
# files and had big troubles with git.
# Probably only a bug shows the problem quite good.
# That's also why this is a warning and not only a convention!
"Some editors don't support non-ASCII file names properly. "
"Even though Python supports UTF-8 files since Python 3.5 this isn't "
"recommended for interoperability. Further reading:\n"
"- https://peps.python.org/pep-0489/#export-hook-name\n"
"- https://peps.python.org/pep-0672/#confusing-features\n"
"- https://bugs.python.org/issue20485"
# files and had big troubles with git. Probably only a bug shows the problem
# quite good. That's also why this is a warning and not only a convention!
Pierre-Sassoulas marked this conversation as resolved.
Show resolved Hide resolved
"Under python 3.5, PEP 3131 only allows non-ascii identifiers, not file names."
Pierre-Sassoulas marked this conversation as resolved.
Show resolved Hide resolved
"Since Python 3.5, even though Python supports UTF-8 files, some editors or tools "
"don't."
),
),
# First %s will always be "module"
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/n/non_ascii_name/non_ascii_name_loł.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
non-ascii-file-name:1:0:None:None::"File name ""non_ascii_name_loł"" contains a non-ASCII character. PEP 3131 only allows non-ascii identifiers, not file names.":HIGH
non-ascii-file-name:1:0:None:None::"File name ""non_ascii_name_loł"" contains a non-ASCII character.":HIGH