From 7d3c34c1705b8ea01f64251a628a311eb4e18728 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sat, 25 Feb 2023 13:28:55 +0100 Subject: [PATCH] [doc] Add an example for 'non-ascii-file-name' And move links to related.rst --- .../n/non-ascii-file-name/bad/b\303\240d.py" | 1 + .../bad/not_b\303\251tter.py" | 1 + .../n/non-ascii-file-name/details.rst | 1 - .../messages/n/non-ascii-file-name/good.py | 1 - .../n/non-ascii-file-name/good/bad.py | 0 .../n/non-ascii-file-name/good/not_better.py | 0 .../n/non-ascii-file-name/related.rst | 3 +++ pylint/checkers/non_ascii_names.py | 19 ++++++------------- .../non_ascii_name_lo\305\202.txt" | 2 +- 9 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 "doc/data/messages/n/non-ascii-file-name/bad/b\303\240d.py" create mode 100644 "doc/data/messages/n/non-ascii-file-name/bad/not_b\303\251tter.py" delete mode 100644 doc/data/messages/n/non-ascii-file-name/details.rst delete mode 100644 doc/data/messages/n/non-ascii-file-name/good.py create mode 100644 doc/data/messages/n/non-ascii-file-name/good/bad.py create mode 100644 doc/data/messages/n/non-ascii-file-name/good/not_better.py create mode 100644 doc/data/messages/n/non-ascii-file-name/related.rst diff --git "a/doc/data/messages/n/non-ascii-file-name/bad/b\303\240d.py" "b/doc/data/messages/n/non-ascii-file-name/bad/b\303\240d.py" new file mode 100644 index 0000000000..bc59418e1e --- /dev/null +++ "b/doc/data/messages/n/non-ascii-file-name/bad/b\303\240d.py" @@ -0,0 +1 @@ +# [non-ascii-file-name] diff --git "a/doc/data/messages/n/non-ascii-file-name/bad/not_b\303\251tter.py" "b/doc/data/messages/n/non-ascii-file-name/bad/not_b\303\251tter.py" new file mode 100644 index 0000000000..bc59418e1e --- /dev/null +++ "b/doc/data/messages/n/non-ascii-file-name/bad/not_b\303\251tter.py" @@ -0,0 +1 @@ +# [non-ascii-file-name] diff --git a/doc/data/messages/n/non-ascii-file-name/details.rst b/doc/data/messages/n/non-ascii-file-name/details.rst deleted file mode 100644 index ab82045295..0000000000 --- a/doc/data/messages/n/non-ascii-file-name/details.rst +++ /dev/null @@ -1 +0,0 @@ -You can help us make the doc better `by contributing `_ ! diff --git a/doc/data/messages/n/non-ascii-file-name/good.py b/doc/data/messages/n/non-ascii-file-name/good.py deleted file mode 100644 index c40beb573f..0000000000 --- a/doc/data/messages/n/non-ascii-file-name/good.py +++ /dev/null @@ -1 +0,0 @@ -# This is a placeholder for correct code for this message. diff --git a/doc/data/messages/n/non-ascii-file-name/good/bad.py b/doc/data/messages/n/non-ascii-file-name/good/bad.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/doc/data/messages/n/non-ascii-file-name/good/not_better.py b/doc/data/messages/n/non-ascii-file-name/good/not_better.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/doc/data/messages/n/non-ascii-file-name/related.rst b/doc/data/messages/n/non-ascii-file-name/related.rst new file mode 100644 index 0000000000..9c7cecacf9 --- /dev/null +++ b/doc/data/messages/n/non-ascii-file-name/related.rst @@ -0,0 +1,3 @@ +- `PEP 489 `_ +- `PEP 672 `_ +- `Python issue 20485 `_ diff --git a/pylint/checkers/non_ascii_names.py b/pylint/checkers/non_ascii_names.py index 6e36280635..060aa6381b 100644 --- a/pylint/checkers/non_ascii_names.py +++ b/pylint/checkers/non_ascii_names.py @@ -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! + "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. " ), ), # First %s will always be "module" diff --git "a/tests/functional/n/non_ascii_name/non_ascii_name_lo\305\202.txt" "b/tests/functional/n/non_ascii_name/non_ascii_name_lo\305\202.txt" index eefaa197a9..b2f82cde41 100644 --- "a/tests/functional/n/non_ascii_name/non_ascii_name_lo\305\202.txt" +++ "b/tests/functional/n/non_ascii_name/non_ascii_name_lo\305\202.txt" @@ -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