From cb7bba41e598aa7aa57f71f987fd92d7704f4f78 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Sep 2021 00:53:27 +0200 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate (#4998) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v2.25.0 → v2.26.0](https://github.com/asottile/pyupgrade/compare/v2.25.0...v2.26.0) - [github.com/pre-commit/mirrors-prettier: v2.3.2 → v2.4.0](https://github.com/pre-commit/mirrors-prettier/compare/v2.3.2...v2.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c3e1ea65457..ebaa68b90ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - --remove-duplicate-keys - --remove-unused-variables - repo: https://github.com/asottile/pyupgrade - rev: v2.25.0 + rev: v2.26.0 hooks: - id: pyupgrade args: [--py36-plus] @@ -88,7 +88,7 @@ repos: ["platformdirs==2.2.0", "types-pkg_resources==0.1.3", "types-toml==0.1.3"] exclude: tests/functional/|tests/input|tests(/.*)*/data|tests/regrtest_data/|tests/data/|tests(/.*)+/conftest.py|doc/|bin/ - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.3.2 + rev: v2.4.0 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] From bbaa7bc9200abaab5b32de8d55ae5cc6fbbbcece Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 14 Sep 2021 09:36:01 +0200 Subject: [PATCH 2/4] Fix false negative for use-symbolic-message Closes #5000 --- ChangeLog | 4 +++ pylint/message/message_id_store.py | 2 +- .../u/use/use_symbolic_message_instead.py | 2 +- .../u/use/use_symbolic_message_instead.txt | 27 ++++++++++--------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6134fca00fe..2f80c14d4d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -93,6 +93,10 @@ Release date: TBA Closes #4616 +* Non symbolic messages with the wrong capitalisation now correctly trigger ``use-symbolic-message-instead`` + + Closes #5000 + What's New in Pylint 2.10.3? ============================ diff --git a/pylint/message/message_id_store.py b/pylint/message/message_id_store.py index 84c3747fe8f..f0ba0c2de26 100644 --- a/pylint/message/message_id_store.py +++ b/pylint/message/message_id_store.py @@ -26,7 +26,7 @@ def __repr__(self): def get_symbol(self, msgid: str) -> str: try: - return self.__msgid_to_symbol[msgid] + return self.__msgid_to_symbol[msgid.upper()] except KeyError as e: msg = f"'{msgid}' is not stored in the message store." raise UnknownMessageError(msg) from e diff --git a/tests/functional/u/use/use_symbolic_message_instead.py b/tests/functional/u/use/use_symbolic_message_instead.py index afdd93c674c..4b826d7caa8 100644 --- a/tests/functional/u/use/use_symbolic_message_instead.py +++ b/tests/functional/u/use/use_symbolic_message_instead.py @@ -1,5 +1,5 @@ # pylint: disable=C0111,R0903,T1234 # [bad-option-value,use-symbolic-message-instead,use-symbolic-message-instead] -# pylint: enable=C0111 # [use-symbolic-message-instead] +# pylint: enable=c0111,w0223 # [use-symbolic-message-instead,use-symbolic-message-instead] def my_function(arg): # [missing-function-docstring] return arg or True diff --git a/tests/functional/u/use/use_symbolic_message_instead.txt b/tests/functional/u/use/use_symbolic_message_instead.txt index 09861bf0643..ba4b729f61e 100644 --- a/tests/functional/u/use/use_symbolic_message_instead.txt +++ b/tests/functional/u/use/use_symbolic_message_instead.txt @@ -1,13 +1,14 @@ -bad-option-value:1:0::Bad option value 'T1234' -use-symbolic-message-instead:1:0::"'C0111' is cryptic: use '# pylint: disable=missing-docstring' instead" -use-symbolic-message-instead:1:0::"'R0903' is cryptic: use '# pylint: disable=too-few-public-methods' instead" -use-symbolic-message-instead:2:0::"'C0111' is cryptic: use '# pylint: enable=missing-docstring' instead" -missing-function-docstring:4:0:my_function:Missing function or method docstring -use-symbolic-message-instead:7:0::"'C0111' is cryptic: use '# pylint: disable=missing-docstring' instead" -use-symbolic-message-instead:8:0::"'R0903' is cryptic: use '# pylint: enable=too-few-public-methods' instead" -use-symbolic-message-instead:9:0::"'R0903' is cryptic: use '# pylint: disable=too-few-public-methods' instead" -use-symbolic-message-instead:12:0::"'C0102' is cryptic: use '# pylint: disable=blacklisted-name' instead" -use-symbolic-message-instead:16:0::"'C0102' is cryptic: use '# pylint: disable=blacklisted-name' instead" -use-symbolic-message-instead:16:0::"'R1711' is cryptic: use '# pylint: disable=useless-return' instead" -missing-function-docstring:20:0:test_enabled_by_id_msg:Missing function or method docstring -use-symbolic-message-instead:20:0::"'C0111' is cryptic: use '# pylint: enable=missing-docstring' instead" +bad-option-value:1:0::Bad option value 'T1234':HIGH +use-symbolic-message-instead:1:0::"'C0111' is cryptic: use '# pylint: disable=missing-docstring' instead":HIGH +use-symbolic-message-instead:1:0::"'R0903' is cryptic: use '# pylint: disable=too-few-public-methods' instead":HIGH +use-symbolic-message-instead:2:0::"'c0111' is cryptic: use '# pylint: enable=missing-docstring' instead":HIGH +use-symbolic-message-instead:2:0::"'w0223' is cryptic: use '# pylint: enable=abstract-method' instead":HIGH +missing-function-docstring:4:0:my_function:Missing function or method docstring:HIGH +use-symbolic-message-instead:7:0::"'C0111' is cryptic: use '# pylint: disable=missing-docstring' instead":HIGH +use-symbolic-message-instead:8:0::"'R0903' is cryptic: use '# pylint: enable=too-few-public-methods' instead":HIGH +use-symbolic-message-instead:9:0::"'R0903' is cryptic: use '# pylint: disable=too-few-public-methods' instead":HIGH +use-symbolic-message-instead:12:0::"'C0102' is cryptic: use '# pylint: disable=blacklisted-name' instead":HIGH +use-symbolic-message-instead:16:0::"'C0102' is cryptic: use '# pylint: disable=blacklisted-name' instead":HIGH +use-symbolic-message-instead:16:0::"'R1711' is cryptic: use '# pylint: disable=useless-return' instead":HIGH +missing-function-docstring:20:0:test_enabled_by_id_msg:Missing function or method docstring:HIGH +use-symbolic-message-instead:20:0::"'C0111' is cryptic: use '# pylint: enable=missing-docstring' instead":HIGH From ca455ce7914cc41a51ea03e5201106f0f4de074d Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 14 Sep 2021 09:59:18 +0200 Subject: [PATCH 3/4] Upgrade astroid to 2.8.0 --- requirements_test_min.txt | 3 ++- setup.cfg | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements_test_min.txt b/requirements_test_min.txt index 40b88797fca..4eb27002cbe 100644 --- a/requirements_test_min.txt +++ b/requirements_test_min.txt @@ -1,4 +1,5 @@ -e . -astroid==2.7.3 # Pinned to a specific version for tests +# astroid dependency is also defined in setup.cfg +astroid==2.8.0 # Pinned to a specific version for tests pytest~=6.2 pytest-benchmark~=3.4 diff --git a/setup.cfg b/setup.cfg index 8d5ff904444..7e18ba310cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,7 +44,7 @@ project_urls = packages = find: install_requires = platformdirs>=2.2.0 - astroid>=2.7.3,<2.8 # (You should also upgrade requirements_test_min.txt) + astroid>=2.8.0,<2.9 # (You should also upgrade requirements_test_min.txt) isort>=4.2.5,<6 mccabe>=0.6,<0.7 toml>=0.7.1 From bc95cd34071ec2e71de5bca8ff95cc9b88e23814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Tue, 14 Sep 2021 10:43:56 +0200 Subject: [PATCH 4/4] Add tests for dataclasses (#4967) * Add tests for dataclasses This closes #4963 and is based on the fix in PyCQA/astroid#1165 --- tests/functional/d/dataclass_with_default_factory.py | 7 +++++++ tests/functional/d/dataclass_with_default_factory.txt | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/functional/d/dataclass_with_default_factory.py b/tests/functional/d/dataclass_with_default_factory.py index 8f24d5e6eec..db392d8b7ff 100644 --- a/tests/functional/d/dataclass_with_default_factory.py +++ b/tests/functional/d/dataclass_with_default_factory.py @@ -4,6 +4,7 @@ # - https://github.com/PyCQA/pylint/issues/2698 from dataclasses import dataclass, field import dataclasses as dc +from typing import cast @dataclass @@ -41,3 +42,9 @@ class Test2: Test2.int_prop["key"] = "value" # [unsupported-assignment-operation] + + +@dc.dataclass +class TEST3: + """Test dataclass that puts call to field() in another function call""" + attribute: int = cast(int, field(default_factory=dict)) diff --git a/tests/functional/d/dataclass_with_default_factory.txt b/tests/functional/d/dataclass_with_default_factory.txt index c33a7d3a48c..af789b14add 100644 --- a/tests/functional/d/dataclass_with_default_factory.txt +++ b/tests/functional/d/dataclass_with_default_factory.txt @@ -1,2 +1,2 @@ -not-an-iterable:39:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH -unsupported-assignment-operation:43:0::'Test2.int_prop' does not support item assignment:HIGH +not-an-iterable:40:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH +unsupported-assignment-operation:44:0::'Test2.int_prop' does not support item assignment:HIGH