From 09509163baaba140fca2633930a6632f05830246 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 19 Sep 2024 11:33:41 +0200 Subject: [PATCH] [pre-commit] Add codespell, and fix some existing typos (#9912) * Add the spellchecker codespell to the pre-commit configuration * Make the dict name generic now that it's used by multiple tools * Fix existing typos * Sort the custom dict --- .pre-commit-config.yaml | 10 +++++++ ..._pylint_custom_dict.txt => custom_dict.txt | 21 ++++++++------ .../contributor_guide/profiling.rst | 2 +- .../contributor_guide/tests/writing_test.rst | 2 +- doc/user_guide/checkers/features.rst | 10 +++---- doc/whatsnew/0/0.x.rst | 2 +- doc/whatsnew/1/1.5.rst | 2 +- doc/whatsnew/2/2.0/summary.rst | 2 +- doc/whatsnew/2/2.13/summary.rst | 2 +- doc/whatsnew/2/2.4/full.rst | 2 +- doc/whatsnew/2/2.6/full.rst | 2 +- doc/whatsnew/2/2.6/summary.rst | 2 +- doc/whatsnew/3/3.1/index.rst | 2 +- pylint/checkers/base/function_checker.py | 2 +- .../implicit_booleaness_checker.py | 2 +- pylintrc | 2 +- pyproject.toml | 29 +++++++++++++++++++ tests/checkers/unittest_misc.py | 2 +- .../unknown_msgid/enable_unknown_msgid.toml | 2 +- tests/data/{ascript => a_script} | 0 tests/functional/a/arguments_differ.py | 2 +- .../c/consider/consider_using_get.py | 4 +-- .../inconsistent_quotes_fstring_py312.py | 2 +- .../inconsistent_quotes_fstring_py312_311.py | 2 +- .../functional/m/misplaced_format_function.py | 2 +- tests/functional/n/names_in__all__.py | 4 +-- tests/functional/n/names_in__all__.txt | 2 +- tests/functional/n/no/no_name_in_module.py | 4 +-- tests/functional/n/no/no_name_in_module.txt | 2 +- .../n/non/non_init_parent_called.py | 6 ++-- .../n/non/non_init_parent_called.txt | 2 +- .../non_ascii_name_assignment_expressions.py | 2 +- .../non_ascii_name_class.py | 2 +- .../n/not_async_context_manager_py37.py | 4 +-- tests/functional/u/uninferable_all_object.py | 2 +- ...it_booleaness_not_comparison_to_string.txt | 12 ++++---- tests/lint/unittest_lint.py | 10 +++---- tests/test_self.py | 2 +- tests/test_similar.py | 2 +- 39 files changed, 105 insertions(+), 63 deletions(-) rename .pyenchant_pylint_custom_dict.txt => custom_dict.txt (99%) rename tests/data/{ascript => a_script} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b85365a2f..2a3712cc7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,9 @@ repos: hooks: - id: trailing-whitespace exclude: tests(/\w*)*/functional/t/trailing_whitespaces.py|tests/pyreverse/data/.*.html|doc/data/messages/t/trailing-whitespace/bad.py + # - id: file-contents-sorter # commented out because it does not preserve comments order + # args: ["--ignore-case", "--unique"] + # files: "custom_dict.txt" - id: end-of-file-fixer exclude: | (?x)^( @@ -173,3 +176,10 @@ repos: - id: bandit args: ["-r", "-lll"] exclude: *fixtures + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: ["--toml=pyproject.toml"] + additional_dependencies: + - tomli diff --git a/.pyenchant_pylint_custom_dict.txt b/custom_dict.txt similarity index 99% rename from .pyenchant_pylint_custom_dict.txt rename to custom_dict.txt index 93d0793e01..576ef703e0 100644 --- a/.pyenchant_pylint_custom_dict.txt +++ b/custom_dict.txt @@ -13,10 +13,11 @@ argumentparser argumentsparser argv ascii +asend assignattr assignname -ast AST +ast astroid async asynccontextmanager @@ -67,8 +68,8 @@ contextlib contextmanager contravariance contravariant -cpython CPython +cpython csv CVE cwd @@ -126,8 +127,8 @@ formfeed fromlineno fullname func -functiøn functiondef +functiøn functools genexpr getattr @@ -160,10 +161,11 @@ isfile isinstance isort iter -itered iterable iterables +itered iteritems +iTerm jn jpg json @@ -206,10 +208,10 @@ monkeypatch mro # Used so much that we need the abbreviation msg +msg-template msgid msgids msgs -msg-template mult multiline multiset @@ -250,8 +252,8 @@ parens passthru pathlib patternerror -positionals png +positionals pragma pragma's pragmas @@ -264,9 +266,9 @@ pyenchant pyfile pyi pylint +pylint's pylintdict pylintrc -pylint's pyproject pypy pyreverse @@ -275,6 +277,7 @@ qname rawcheckers rc rcfile +re-usable readlines recognise recurse @@ -345,9 +348,9 @@ tomlkit toplevel towncrier tp +truthey truthness truthy -truthey tryexcept txt typecheck @@ -362,8 +365,8 @@ unary unflattens unhandled unicode -Uninferable uninferable +Uninferable unittest unraisablehook untriggered diff --git a/doc/development_guide/contributor_guide/profiling.rst b/doc/development_guide/contributor_guide/profiling.rst index bb49038fff..9472247eb9 100644 --- a/doc/development_guide/contributor_guide/profiling.rst +++ b/doc/development_guide/contributor_guide/profiling.rst @@ -90,7 +90,7 @@ and thus is displayed as being 0. Often you are more interested in the cumulative time (per call). This refers to the time spent within the function and any of the functions it called or the functions they called (etc.). In our example, the ``visit_importfrom`` -method and all of its child-functions took a little over 8 seconds to exectute, with an execution time of +method and all of its child-functions took a little over 8 seconds to execute, with an execution time of 0.013 ms per call. You can also search the ``profiler_stats`` for an individual function you want to check. For example diff --git a/doc/development_guide/contributor_guide/tests/writing_test.rst b/doc/development_guide/contributor_guide/tests/writing_test.rst index 9ce9ca1f0d..481bd27cef 100644 --- a/doc/development_guide/contributor_guide/tests/writing_test.rst +++ b/doc/development_guide/contributor_guide/tests/writing_test.rst @@ -21,7 +21,7 @@ Unittest tests Most other tests reside in the '/pylint/test' directory. These unittests can be used to test almost all functionality within Pylint. A good step before writing any new unittests is to look -at some tests that test a similar funcitionality. This can often help write new tests. +at some tests that test a similar functionality. This can often help write new tests. If your new test requires any additional files you can put those in the ``/pylint/test/regrtest_data`` directory. This is the directory we use to store any data needed for diff --git a/doc/user_guide/checkers/features.rst b/doc/user_guide/checkers/features.rst index 3c92594e42..4ade3c5311 100644 --- a/doc/user_guide/checkers/features.rst +++ b/doc/user_guide/checkers/features.rst @@ -918,16 +918,16 @@ Refactoring checker Messages Emitted when a single "return" or "return None" statement is found at the end of function or method definition. This statement can safely be removed because Python will implicitly return None -:use-implicit-booleaness-not-comparison-to-string (C1804): *"%s" can be simplified to "%s", if it is striclty a string, as an empty string is falsey* - Empty string are considered false in a boolean context. Following this check - blindly in weakly typed code base can create hard to debug issues. If the - value can be something else that is falsey but not a string (for example - ``None``, an empty sequence, or ``0``) the code will not be equivalent. :use-implicit-booleaness-not-comparison (C1803): *"%s" can be simplified to "%s", if it is strictly a sequence, as an empty %s is falsey* Empty sequences are considered false in a boolean context. Following this check blindly in weakly typed code base can create hard to debug issues. If the value can be something else that is falsey but not a sequence (for example ``None``, an empty string, or ``0``) the code will not be equivalent. +:use-implicit-booleaness-not-comparison-to-string (C1804): *"%s" can be simplified to "%s", if it is strictly a string, as an empty string is falsey* + Empty string are considered false in a boolean context. Following this check + blindly in weakly typed code base can create hard to debug issues. If the + value can be something else that is falsey but not a string (for example + ``None``, an empty sequence, or ``0``) the code will not be equivalent. :use-implicit-booleaness-not-comparison-to-zero (C1805): *"%s" can be simplified to "%s", if it is strictly an int, as 0 is falsey* 0 is considered false in a boolean context. Following this check blindly in weakly typed code base can create hard to debug issues. If the value can be diff --git a/doc/whatsnew/0/0.x.rst b/doc/whatsnew/0/0.x.rst index 68abe04767..793f07a941 100644 --- a/doc/whatsnew/0/0.x.rst +++ b/doc/whatsnew/0/0.x.rst @@ -1001,7 +1001,7 @@ Release date: 2004-10-19 * avoid importing analyzed modules ! * new Refactor and Convention message categories. Some Warnings have been - remaped into those new categories + remapped into those new categories * added "similar", a tool to find copied and pasted lines of code, both using a specific command line tool and integrated as a diff --git a/doc/whatsnew/1/1.5.rst b/doc/whatsnew/1/1.5.rst index f8ce036060..51c7cf2ce9 100644 --- a/doc/whatsnew/1/1.5.rst +++ b/doc/whatsnew/1/1.5.rst @@ -435,7 +435,7 @@ Release date: 2015-11-29 * astroid.utils.LocalsVisitor was moved to pylint.pyreverse.LocalsVisitor. * pylint.checkers.utils.excepts_import_error was removed. - Use pylint.chekcers.utils.error_of_type instead. + Use pylint.checkers.utils.error_of_type instead. * Don't emit undefined-all-variables for nodes which can't be inferred (YES nodes). diff --git a/doc/whatsnew/2/2.0/summary.rst b/doc/whatsnew/2/2.0/summary.rst index c74f4dc5b8..52d8945073 100644 --- a/doc/whatsnew/2/2.0/summary.rst +++ b/doc/whatsnew/2/2.0/summary.rst @@ -221,7 +221,7 @@ Other Changes ``pylint`` should be a bit faster as well. We added a new flag, ``max_inferable_values`` on ``astroid.MANAGER`` for - limitting the maximum amount of values that ``astroid`` can infer when inferring + limiting the maximum amount of values that ``astroid`` can infer when inferring values. This change should improve the performance when dealing with large frameworks such as ``django``. You can also control this behaviour with ``pylint --limit-inference-results`` diff --git a/doc/whatsnew/2/2.13/summary.rst b/doc/whatsnew/2/2.13/summary.rst index ddfb98f840..e2ad8698e6 100644 --- a/doc/whatsnew/2/2.13/summary.rst +++ b/doc/whatsnew/2/2.13/summary.rst @@ -81,7 +81,7 @@ New checkers creates memory leaks by never letting the instance get garbage collected. Closes #5670 - Clsoes #6180 + Closes #6180 Removed checkers ================ diff --git a/doc/whatsnew/2/2.4/full.rst b/doc/whatsnew/2/2.4/full.rst index 079e37707b..ab871c8b5c 100644 --- a/doc/whatsnew/2/2.4/full.rst +++ b/doc/whatsnew/2/2.4/full.rst @@ -137,7 +137,7 @@ Release date: 2019-09-24 Closes #2925 * ``useless-suppression`` check now ignores ``cyclic-import`` suppressions, - which could lead to false postiives due to incomplete context at the time + which could lead to false positives due to incomplete context at the time of the check. Closes #3064 diff --git a/doc/whatsnew/2/2.6/full.rst b/doc/whatsnew/2/2.6/full.rst index 3896677dc0..dba2143497 100644 --- a/doc/whatsnew/2/2.6/full.rst +++ b/doc/whatsnew/2/2.6/full.rst @@ -54,7 +54,7 @@ Release date: 2020-08-20 * Add ``raise-missing-from`` check for exceptions that should have a cause. -* Support both isort 4 and isort 5. If you have pinned isort 4 in your projet requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see the migration guide in isort documentation for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file. +* Support both isort 4 and isort 5. If you have pinned isort 4 in your project requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see the migration guide in isort documentation for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file. Closes #3722 diff --git a/doc/whatsnew/2/2.6/summary.rst b/doc/whatsnew/2/2.6/summary.rst index e4aee082f6..9061bd00c0 100644 --- a/doc/whatsnew/2/2.6/summary.rst +++ b/doc/whatsnew/2/2.6/summary.rst @@ -25,4 +25,4 @@ Other Changes * Fix superfluous-parens false-positive for the walrus operator -* Add support for both isort 4 and isort 5. If you have pinned isort 4 in your projet requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see `the migration guide in isort documentation` (no longer available) for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file. +* Add support for both isort 4 and isort 5. If you have pinned isort 4 in your project requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see `the migration guide in isort documentation` (no longer available) for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file. diff --git a/doc/whatsnew/3/3.1/index.rst b/doc/whatsnew/3/3.1/index.rst index 1abe832dcb..900a5ef0b6 100644 --- a/doc/whatsnew/3/3.1/index.rst +++ b/doc/whatsnew/3/3.1/index.rst @@ -118,7 +118,7 @@ Other Bug Fixes The message will report imports as follows: For "import X", it will report "(standard/third party/first party/local) import X" For "import X.Y" and "from X import Y", it will report "(standard/third party/first party/local) import X.Y" - The import category is specified to provide explanation as to why pylint has issued the message and guidence to the developer on how to fix the problem. + The import category is specified to provide explanation as to why pylint has issued the message and guidance to the developer on how to fix the problem. Closes #8808 (`#8808 `_) diff --git a/pylint/checkers/base/function_checker.py b/pylint/checkers/base/function_checker.py index f7d92a4649..2826b40b4d 100644 --- a/pylint/checkers/base/function_checker.py +++ b/pylint/checkers/base/function_checker.py @@ -45,7 +45,7 @@ def _check_contextmanager_generator_missing_cleanup( :param node: FunctionDef node to check :type node: nodes.FunctionDef """ - # if function does not use a Yield statement, it cant be a generator + # if function does not use a Yield statement, it can't be a generator with_nodes = list(node.nodes_of_class(nodes.With)) if not with_nodes: return diff --git a/pylint/checkers/refactoring/implicit_booleaness_checker.py b/pylint/checkers/refactoring/implicit_booleaness_checker.py index b5109fc579..4d3d47cf9f 100644 --- a/pylint/checkers/refactoring/implicit_booleaness_checker.py +++ b/pylint/checkers/refactoring/implicit_booleaness_checker.py @@ -81,7 +81,7 @@ class ImplicitBooleanessChecker(checkers.BaseChecker): "equivalent.", ), "C1804": ( - '"%s" can be simplified to "%s", if it is striclty a string, as an empty string is falsey', + '"%s" can be simplified to "%s", if it is strictly a string, as an empty string is falsey', "use-implicit-booleaness-not-comparison-to-string", "Empty string are considered false in a boolean context. Following this" " check blindly in weakly typed code base can create hard to debug issues." diff --git a/pylintrc b/pylintrc index c1c70c0731..bd6e8a2e22 100644 --- a/pylintrc +++ b/pylintrc @@ -400,7 +400,7 @@ spelling-ignore-words= spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:,pragma:,# noinspection # A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file=.pyenchant_pylint_custom_dict.txt +spelling-private-dict-file=custom_dict.txt # Tells whether to store unknown words to indicated private dictionary in # --spelling-private-dict-file option instead of raising a message. diff --git a/pyproject.toml b/pyproject.toml index b244f62e70..0f1d6c9eba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,3 +200,32 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "pep257" + +[tool.codespell] +ignore-words = ["custom_dict.txt"] + +# Disabled the spelling files for obvious reason, but also, +# the test file with typing extension imported as 'te' and: +# tests/functional/i/implicit/implicit_str_concat_latin1.py: +# - bad encoding +# pylint/pyreverse/diagrams.py and tests/pyreverse/test_diagrams.py: +# - An API from pyreverse use 'classe', and would need to be deprecated +# pylint/checkers/imports.py: +# - 'THIRDPARTY' is a value from isort that would need to be handled even +# if isort fix the typo in newer versions +# tests/functional/m/member/member_checks.py: +# - typos are voluntary to create credible 'no-member' + +skip = """ +tests/checkers/unittest_spelling.py,\ +CODE_OF_CONDUCT.md,\ +CONTRIBUTORS.txt,\ +pylint/checkers/imports.py,\ +pylint/pyreverse/diagrams.py,\ +tests/pyreverse/test_diagrams.py,\ +tests/functional/i/implicit/implicit_str_concat_latin1.py,\ +tests/functional/m/member/member_checks.py,\ +tests/functional/t/type/typevar_naming_style_rgx.py,\ +tests/functional/t/type/typevar_naming_style_default.py,\ +tests/functional/m/member/member_checks_async.py,\ +""" diff --git a/tests/checkers/unittest_misc.py b/tests/checkers/unittest_misc.py index 2f292b81f1..dae07efae1 100644 --- a/tests/checkers/unittest_misc.py +++ b/tests/checkers/unittest_misc.py @@ -40,7 +40,7 @@ def test_xxx_without_space(self) -> None: def test_xxx_middle(self) -> None: code = """a = 1 - # midle XXX + # middle XXX """ with self.assertNoMessages(): self.checker.process_tokens(_tokenize_str(code)) diff --git a/tests/config/functional/toml/unknown_msgid/enable_unknown_msgid.toml b/tests/config/functional/toml/unknown_msgid/enable_unknown_msgid.toml index 65fe560904..c25ca46a50 100644 --- a/tests/config/functional/toml/unknown_msgid/enable_unknown_msgid.toml +++ b/tests/config/functional/toml/unknown_msgid/enable_unknown_msgid.toml @@ -1,4 +1,4 @@ -# Check the behavior for unkonwn symbol/msgid +# Check the behavior for unknown symbol/msgid # (Originally) reported in https://github.com/pylint-dev/pylint/pull/6293 [tool.pylint."messages control"] diff --git a/tests/data/ascript b/tests/data/a_script similarity index 100% rename from tests/data/ascript rename to tests/data/a_script diff --git a/tests/functional/a/arguments_differ.py b/tests/functional/a/arguments_differ.py index 1c56ecc083..effe96c9a5 100644 --- a/tests/functional/a/arguments_differ.py +++ b/tests/functional/a/arguments_differ.py @@ -280,7 +280,7 @@ class ChildT3(ParentT3): def func(self, user_input: FooT1) -> None: pass -# Keyword and positional overriddes +# Keyword and positional overrides class AbstractFoo: def kwonly_1(self, first, *, second, third): diff --git a/tests/functional/c/consider/consider_using_get.py b/tests/functional/c/consider/consider_using_get.py index 728fccd505..8a75f99727 100644 --- a/tests/functional/c/consider/consider_using_get.py +++ b/tests/functional/c/consider/consider_using_get.py @@ -16,10 +16,10 @@ if 'key' in dictionary: # not accessing the dictionary in assignment variable = "string" -if 'key' in dictionary: # is a match, but not obvious and we ignore it for now +if 'key' in dictionary: # is a match, but not obvious, and we ignore it for now variable = dictionary[key] -if 'key1' in dictionary: # dictionary querried for wrong key +if 'key1' in dictionary: # dictionary queried for wrong key variable = dictionary['key2'] if 'key' in dictionary: # body is not pure diff --git a/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.py b/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.py index 95a79a061c..323bc6a07b 100644 --- a/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.py +++ b/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.py @@ -1,5 +1,5 @@ # pylint: disable=missing-module-docstring dictionary = {'0': 0} -# quotes are inconsistent when targetting Python 3.12 (use single quotes) +# quotes are inconsistent when targeting Python 3.12 (use single quotes) F_STRING = f'{dictionary["0"]}' # [inconsistent-quotes] diff --git a/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312_311.py b/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312_311.py index 2c49ffc726..c7099e4710 100644 --- a/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312_311.py +++ b/tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312_311.py @@ -1,5 +1,5 @@ # pylint: disable=missing-module-docstring dictionary = {'0': 0} -# quotes are consistent when targetting 3.11 and earlier (cannot use single quotes here) +# quotes are consistent when targeting 3.11 and earlier (cannot use single quotes here) F_STRING = f'{dictionary["0"]}' diff --git a/tests/functional/m/misplaced_format_function.py b/tests/functional/m/misplaced_format_function.py index 679f598582..a137210241 100644 --- a/tests/functional/m/misplaced_format_function.py +++ b/tests/functional/m/misplaced_format_function.py @@ -6,7 +6,7 @@ print("value: {}").format(123) # [misplaced-format-function] print('value: {}'.format(123)) print('{} Come Forth!'.format('Lazarus')) -print('Der Hem ist mein Licht und mein Heil, vor wem sollte ich mich furchten? => {}'.format('Psalm 27, 1')) +print('He is my light and my salvation, of whom should I be afraid? => {}'.format('Psalm 27, 1')) print('123') print() s = 'value: {}'.format(123) diff --git a/tests/functional/n/names_in__all__.py b/tests/functional/n/names_in__all__.py index 38ed18a2e7..76fbd833ae 100644 --- a/tests/functional/n/names_in__all__.py +++ b/tests/functional/n/names_in__all__.py @@ -1,7 +1,7 @@ # pylint: disable=too-few-public-methods, import-error, unnecessary-pass """Test Pylint's use of __all__. -* NonExistant is not defined in this module, and it is listed in +* NonExistent is not defined in this module, and it is listed in __all__. An error is expected. * This module imports path and republished it in __all__. No errors @@ -16,7 +16,7 @@ '', # [undefined-all-variable] Missing, SomeUndefined, # [undefined-variable] - 'NonExistant', # [undefined-all-variable] + 'NonExistent', # [undefined-all-variable] 'path', 'func', # [undefined-all-variable] 'inner', # [undefined-all-variable] diff --git a/tests/functional/n/names_in__all__.txt b/tests/functional/n/names_in__all__.txt index 720942df3d..29c0e11391 100644 --- a/tests/functional/n/names_in__all__.txt +++ b/tests/functional/n/names_in__all__.txt @@ -1,6 +1,6 @@ undefined-all-variable:16:4:16:6::Undefined variable name '' in __all__:UNDEFINED undefined-variable:18:4:18:17::Undefined variable 'SomeUndefined':UNDEFINED -undefined-all-variable:19:4:19:17::Undefined variable name 'NonExistant' in __all__:UNDEFINED +undefined-all-variable:19:4:19:17::Undefined variable name 'NonExistent' in __all__:UNDEFINED undefined-all-variable:21:4:21:10::Undefined variable name 'func' in __all__:UNDEFINED undefined-all-variable:22:4:22:11::Undefined variable name 'inner' in __all__:UNDEFINED undefined-all-variable:23:4:23:16::Undefined variable name 'InnerKlass' in __all__:UNDEFINED diff --git a/tests/functional/n/no/no_name_in_module.py b/tests/functional/n/no/no_name_in_module.py index ef9fb03d17..6d34245c84 100644 --- a/tests/functional/n/no/no_name_in_module.py +++ b/tests/functional/n/no/no_name_in_module.py @@ -7,8 +7,8 @@ toto.yo() from xml.etree import ElementTree -ElementTree.nonexistant_function() # [no-member] -ElementTree.another.nonexistant.function() # [no-member] +ElementTree.nonexistent_function() # [no-member] +ElementTree.another.nonexistent.function() # [no-member] import sys diff --git a/tests/functional/n/no/no_name_in_module.txt b/tests/functional/n/no/no_name_in_module.txt index 878793bc73..ed8628108d 100644 --- a/tests/functional/n/no/no_name_in_module.txt +++ b/tests/functional/n/no/no_name_in_module.txt @@ -1,6 +1,6 @@ no-name-in-module:5:0:5:23::No name 'tutu' in module 'collections':UNDEFINED no-name-in-module:6:0:6:28::No name 'toto' in module 'collections':UNDEFINED -no-member:10:0:10:32::Module 'xml.etree.ElementTree' has no 'nonexistant_function' member:INFERENCE +no-member:10:0:10:32::Module 'xml.etree.ElementTree' has no 'nonexistent_function' member:INFERENCE no-member:11:0:11:19::Module 'xml.etree.ElementTree' has no 'another' member:INFERENCE no-member:16:6:16:17::Module 'sys' has no 'stdoout' member; maybe 'stdout'?:INFERENCE no-name-in-module:23:0:23:34::No name 'compiile' in module 're':UNDEFINED diff --git a/tests/functional/n/non/non_init_parent_called.py b/tests/functional/n/non/non_init_parent_called.py index 7a6c94eadd..5c27a45aa1 100644 --- a/tests/functional/n/non/non_init_parent_called.py +++ b/tests/functional/n/non/non_init_parent_called.py @@ -3,7 +3,7 @@ """test for call to __init__ from a non ancestor class """ from . import non_init_parent_called -import nonexistant # [import-error] +import nonexistent # [import-error] class AAAA: @@ -19,13 +19,13 @@ class BBBBMixin: def __init__(self): print('init', self) -class CCC(BBBBMixin, non_init_parent_called.AAAA, non_init_parent_called.BBBB, nonexistant.AClass): # [no-member] +class CCC(BBBBMixin, non_init_parent_called.AAAA, non_init_parent_called.BBBB, nonexistent.AClass): # [no-member] """mix different things, some inferable some not""" def __init__(self): BBBBMixin.__init__(self) non_init_parent_called.AAAA.__init__(self) non_init_parent_called.BBBB.__init__(self) # [no-member] - nonexistant.AClass.__init__(self) + nonexistent.AClass.__init__(self) class DDDD(AAAA): """call superclass constructor in disjunct branches""" diff --git a/tests/functional/n/non/non_init_parent_called.txt b/tests/functional/n/non/non_init_parent_called.txt index d6ef10e9f8..85aad5f6e4 100644 --- a/tests/functional/n/non/non_init_parent_called.txt +++ b/tests/functional/n/non/non_init_parent_called.txt @@ -1,4 +1,4 @@ -import-error:6:0:6:18::Unable to import 'nonexistant':UNDEFINED +import-error:6:0:6:18::Unable to import 'nonexistent':UNDEFINED non-parent-init-called:14:8:14:26:AAAA.__init__:__init__ method from a non direct base class 'BBBBMixin' is called:UNDEFINED no-member:22:50:22:77:CCC:Module 'functional.n.non.non_init_parent_called' has no 'BBBB' member:INFERENCE no-member:27:8:27:35:CCC.__init__:Module 'functional.n.non.non_init_parent_called' has no 'BBBB' member:INFERENCE diff --git a/tests/functional/n/non_ascii_name/non_ascii_name_assignment_expressions.py b/tests/functional/n/non_ascii_name/non_ascii_name_assignment_expressions.py index ac51b9c4dc..a0fa108f7f 100644 --- a/tests/functional/n/non_ascii_name/non_ascii_name_assignment_expressions.py +++ b/tests/functional/n/non_ascii_name/non_ascii_name_assignment_expressions.py @@ -1,4 +1,4 @@ -"""Assigment Expression as defined in https://www.python.org/dev/peps/pep-0572/""" +"""Assignment Expression as defined in https://www.python.org/dev/peps/pep-0572/""" if (loł := __name__) == "__main__": # [non-ascii-name] print(loł) diff --git a/tests/functional/n/non_ascii_name_class/non_ascii_name_class.py b/tests/functional/n/non_ascii_name_class/non_ascii_name_class.py index edcdae6435..8de521a7f5 100644 --- a/tests/functional/n/non_ascii_name_class/non_ascii_name_class.py +++ b/tests/functional/n/non_ascii_name_class/non_ascii_name_class.py @@ -9,7 +9,7 @@ class НoldIt: # [non-ascii-name] - """nice classs""" + """Nice class.""" def public(self): """do something""" diff --git a/tests/functional/n/not_async_context_manager_py37.py b/tests/functional/n/not_async_context_manager_py37.py index c1ca26976d..9bf1cf046e 100644 --- a/tests/functional/n/not_async_context_manager_py37.py +++ b/tests/functional/n/not_async_context_manager_py37.py @@ -8,8 +8,8 @@ async def context_manager(value): yield value -async with context_manager(42) as ans: - assert ans == 42 +async with context_manager(42) as answer: + assert answer == 42 def async_context_manager(): diff --git a/tests/functional/u/uninferable_all_object.py b/tests/functional/u/uninferable_all_object.py index 3e565f9ebf..9c49c2ab6e 100644 --- a/tests/functional/u/uninferable_all_object.py +++ b/tests/functional/u/uninferable_all_object.py @@ -2,7 +2,7 @@ __all__ = sorted([ 'Dummy', - 'NonExistant', + 'NonExistent', 'path', 'func', 'inner', diff --git a/tests/functional/u/use/use_implicit_booleaness_not_comparison_to_string.txt b/tests/functional/u/use/use_implicit_booleaness_not_comparison_to_string.txt index 5f07a683c6..191de3a386 100644 --- a/tests/functional/u/use/use_implicit_booleaness_not_comparison_to_string.txt +++ b/tests/functional/u/use/use_implicit_booleaness_not_comparison_to_string.txt @@ -1,6 +1,6 @@ -use-implicit-booleaness-not-comparison-to-string:6:3:6:10::"""X is ''"" can be simplified to ""not X"", if it is striclty a string, as an empty string is falsey":HIGH -use-implicit-booleaness-not-comparison-to-string:9:3:9:14::"""Y is not ''"" can be simplified to ""Y"", if it is striclty a string, as an empty string is falsey":HIGH -use-implicit-booleaness-not-comparison-to-string:12:3:12:10::"""X == ''"" can be simplified to ""not X"", if it is striclty a string, as an empty string is falsey":HIGH -use-implicit-booleaness-not-comparison-to-string:15:3:15:10::"""Y != ''"" can be simplified to ""Y"", if it is striclty a string, as an empty string is falsey":HIGH -use-implicit-booleaness-not-comparison-to-string:18:3:18:10::"""'' == Y"" can be simplified to ""not Y"", if it is striclty a string, as an empty string is falsey":HIGH -use-implicit-booleaness-not-comparison-to-string:21:3:21:10::"""'' != X"" can be simplified to ""X"", if it is striclty a string, as an empty string is falsey":HIGH +use-implicit-booleaness-not-comparison-to-string:6:3:6:10::"""X is ''"" can be simplified to ""not X"", if it is strictly a string, as an empty string is falsey":HIGH +use-implicit-booleaness-not-comparison-to-string:9:3:9:14::"""Y is not ''"" can be simplified to ""Y"", if it is strictly a string, as an empty string is falsey":HIGH +use-implicit-booleaness-not-comparison-to-string:12:3:12:10::"""X == ''"" can be simplified to ""not X"", if it is strictly a string, as an empty string is falsey":HIGH +use-implicit-booleaness-not-comparison-to-string:15:3:15:10::"""Y != ''"" can be simplified to ""Y"", if it is strictly a string, as an empty string is falsey":HIGH +use-implicit-booleaness-not-comparison-to-string:18:3:18:10::"""'' == Y"" can be simplified to ""not Y"", if it is strictly a string, as an empty string is falsey":HIGH +use-implicit-booleaness-not-comparison-to-string:21:3:21:10::"""'' != X"" can be simplified to ""X"", if it is strictly a string, as an empty string is falsey":HIGH diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py index 086c192110..7ba8879e9a 100644 --- a/tests/lint/unittest_lint.py +++ b/tests/lint/unittest_lint.py @@ -859,7 +859,7 @@ def test_init_hooks_called_before_load_plugins() -> None: def test_analyze_explicit_script(linter: PyLinter) -> None: linter.set_reporter(testutils.GenericTestReporter()) - linter.check([os.path.join(DATA_DIR, "ascript")]) + linter.check([os.path.join(DATA_DIR, "a_script")]) assert len(linter.reporter.messages) == 1 assert linter.reporter.messages[0] == Message( msg_id="C0301", @@ -870,11 +870,11 @@ def test_analyze_explicit_script(linter: PyLinter) -> None: description="Warning without any associated confidence level.", ), location=MessageLocationTuple( - abspath=os.path.join(abspath(dirname(__file__)), "ascript").replace( - f"lint{os.path.sep}ascript", f"data{os.path.sep}ascript" + abspath=os.path.join(abspath(dirname(__file__)), "a_script").replace( + f"lint{os.path.sep}a_script", f"data{os.path.sep}a_script" ), - path=f"tests{os.path.sep}data{os.path.sep}ascript", - module="data.ascript", + path=f"tests{os.path.sep}data{os.path.sep}a_script", + module="data.a_script", obj="", line=2, column=0, diff --git a/tests/test_self.py b/tests/test_self.py index 821d051ba2..d01821c34c 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -1407,7 +1407,7 @@ def test_output_of_callback_options( [ [["--help-msg", "W0101"], ":unreachable (W0101)", False], [["--help-msg", "WX101"], "No such message id", False], - [["--help-msg"], "--help-msg: expected at least one argumen", True], + [["--help-msg"], "--help-msg: expected at least one argument", True], [["--help-msg", "C0102,C0103"], ":invalid-name (C0103):", False], ], ) diff --git a/tests/test_similar.py b/tests/test_similar.py index fe711ec34b..c5357f4b6d 100644 --- a/tests/test_similar.py +++ b/tests/test_similar.py @@ -161,7 +161,7 @@ def test_duplicate_code_raw_strings_disable_line_disable_all(self) -> None: code=0, ) - def test_duplicate_code_raw_strings_disable_line_midle(self) -> None: + def test_duplicate_code_raw_strings_disable_line_middle(self) -> None: """Tests disabling duplicate-code at a line in the middle of a piece of similar code.""" path = join(DATA, "raw_strings_disable_line_middle") self._runtest(