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

Full compatibility with Pylint v3 #7

Merged
merged 3 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion flake8_pylint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
from ._plugin import PyLintChecker


__version__ = '0.2.0'
__version__ = '0.2.1'
__all__ = ['PyLintChecker']
31 changes: 17 additions & 14 deletions flake8_pylint/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -73,7 +76,7 @@ class PyLintChecker:
"""The flake8 plugin entry point.
"""
name = 'pylint'
version = VERSION
version = get_version()

def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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]