Skip to content

Commit

Permalink
Merge pull request #7 from orsinium-labs/fix-ci
Browse files Browse the repository at this point in the history
Full compatibility with Pylint v3
  • Loading branch information
orsinium authored Oct 7, 2023
2 parents 270cbe1 + eafe25b commit 438160e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
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]

0 comments on commit 438160e

Please sign in to comment.