From d7b9c116533f00fbb4e13f574f3b4129952b0b72 Mon Sep 17 00:00:00 2001 From: Sneder89 <45610045+Sneder89@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:01:05 +0200 Subject: [PATCH 1/4] Update _plugin.py Be compatible to pylint version 3 --- flake8_pylint/_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake8_pylint/_plugin.py b/flake8_pylint/_plugin.py index bcedefb..f7168d0 100644 --- a/flake8_pylint/_plugin.py +++ b/flake8_pylint/_plugin.py @@ -86,6 +86,6 @@ def __init__( def run(self) -> Iterator[tuple[int, int, str, type]]: reporter = Reporter() - Run([self.filename], reporter=reporter, do_exit=False) + Run([self.filename], reporter=reporter, exit=False) for error in reporter.errors: yield error['row'], error['col'], error['text'], type(self) From 0ef7171f42b83cad6061ff1af91b5f988a046fa1 Mon Sep 17 00:00:00 2001 From: gram Date: Sat, 7 Oct 2023 07:36:19 +0200 Subject: [PATCH 2/4] improve pylint version detection --- flake8_pylint/_plugin.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/flake8_pylint/_plugin.py b/flake8_pylint/_plugin.py index f7168d0..31d9d17 100644 --- a/flake8_pylint/_plugin.py +++ b/flake8_pylint/_plugin.py @@ -2,6 +2,7 @@ import sys from ast import AST +from contextlib import suppress from tokenize import TokenInfo from typing import TYPE_CHECKING, Any, Iterator, Sequence @@ -14,24 +15,26 @@ from pylint.reporters.ureports.nodes import BaseLayout -if sys.version_info >= (3, 8): - from importlib import metadata as importlib_metadata -else: - import importlib_metadata - - STDIN = 'stdin' PREFIX = 'PL' -try: - # older pylint versions - from pylint.__pkginfo__ import version - VERSION = version -except ImportError: + +def get_version() -> str: + with suppress(ImportError): + from pylint.__pkginfo__ import version # type: ignore[attr-defined] + return version + with suppress(ImportError): + from pylint.__pkginfo__ import __version__ + return __version__ + if sys.version_info >= (3, 8): + from importlib import metadata as importlib_metadata + else: + import importlib_metadata try: - VERSION = importlib_metadata.version('pylint') + return importlib_metadata.version('pylint') except Exception: - VERSION = 'unknown' + pass + return 'unknown' class Reporter(BaseReporter): @@ -73,7 +76,7 @@ class PyLintChecker: """The flake8 plugin entry point. """ name = 'pylint' - version = VERSION + version = get_version() def __init__( self, From f6b9d611cf63e972c9ed0dbded66bc555aaea5d8 Mon Sep 17 00:00:00 2001 From: gram Date: Sat, 7 Oct 2023 07:39:00 +0200 Subject: [PATCH 3/4] actualize tests --- tests/test_plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 7e84076..42d46d6 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -9,7 +9,7 @@ def test_smoke(tmp_path: Path) -> None: file_path = tmp_path / 'example.py' source = """ - def f(): + def F(): pass """ file_path.write_text(dedent(source)) @@ -26,4 +26,4 @@ def f(): assert ':1: PLC' in msg assert 'PLC114 Missing module docstring (missing-module-docstring)' in msgs[0] assert 'PLC116 Missing function or method docstring' in msgs[1] - assert 'PLC103 Function name "f"' in msgs[2] + assert 'PLC103 Function name "F"' in msgs[2] From eafe25b628826612ac33b2b9808311406ee01d78 Mon Sep 17 00:00:00 2001 From: gram Date: Sat, 7 Oct 2023 07:40:31 +0200 Subject: [PATCH 4/4] bump version --- flake8_pylint/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake8_pylint/__init__.py b/flake8_pylint/__init__.py index 3930414..f07e2d2 100644 --- a/flake8_pylint/__init__.py +++ b/flake8_pylint/__init__.py @@ -4,5 +4,5 @@ from ._plugin import PyLintChecker -__version__ = '0.2.0' +__version__ = '0.2.1' __all__ = ['PyLintChecker']