diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index ed2ea22..2f8bf76 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -24,7 +24,7 @@ jobs: - '3.9' - '3.10' - '3.11' -# - '3.12' # FixMe: https://github.com/pylint-dev/pylint-pytest/issues/3 + - '3.12' defaults: run: diff --git a/CHANGELOG.md b/CHANGELOG.md index 642b33e..0758c3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +### Added + +* Migrate setup.py to pyproject.toml (https://github.com/pylint-dev/pylint-pytest/pull/8) +* Support for Python 3.12 (https://github.com/pylint-dev/pylint-pytest/issues/3, + "side effect" of https://github.com/pylint-dev/pylint-pytest/pull/8) + ### Removed * Support for Python 3.6 & 3.7 (https://github.com/pylint-dev/pylint-pytest/pull/23) diff --git a/pylint_pytest/checkers/class_attr_loader.py b/pylint_pytest/checkers/class_attr_loader.py index 40d16cf..fdd8339 100644 --- a/pylint_pytest/checkers/class_attr_loader.py +++ b/pylint_pytest/checkers/class_attr_loader.py @@ -1,4 +1,4 @@ -from typing import Optional, Set +from __future__ import annotations from astroid import Assign, Attribute, ClassDef, Name @@ -10,8 +10,8 @@ class ClassAttrLoader(BasePytestChecker): msgs = {"E6400": ("", "pytest-class-attr-loader", "")} in_setup = False - request_cls: Set[str] = set() - class_node: Optional[ClassDef] = None + request_cls: set[str] = set() + class_node: ClassDef | None = None def visit_functiondef(self, node): """determine if a method is a class setup method""" diff --git a/pylint_pytest/checkers/fixture.py b/pylint_pytest/checkers/fixture.py index 86dd5bb..5b13360 100644 --- a/pylint_pytest/checkers/fixture.py +++ b/pylint_pytest/checkers/fixture.py @@ -1,8 +1,9 @@ +from __future__ import annotations + import fnmatch import io import sys from pathlib import Path -from typing import Set, Tuple import astroid import pytest @@ -19,7 +20,7 @@ from .types import FixtureDict, replacement_add_message # TODO: support pytest python_files configuration -FILE_NAME_PATTERNS: Tuple[str, ...] = ("test_*.py", "*_test.py") +FILE_NAME_PATTERNS: tuple[str, ...] = ("test_*.py", "*_test.py") ARGUMENT_ARE_KEYWORD_ONLY = ( "https://docs.pytest.org/en/stable/deprecations.html#pytest-fixture-arguments-are-keyword-only" ) @@ -28,7 +29,7 @@ class FixtureCollector: # Same as ``_pytest.fixtures.FixtureManager._arg2fixturedefs``. fixtures: FixtureDict = {} - errors: Set[pytest.CollectReport] = set() + errors: set[pytest.CollectReport] = set() def pytest_sessionfinish(self, session): # pylint: disable=protected-access @@ -76,9 +77,9 @@ class FixtureChecker(BasePytestChecker): # Store all fixtures discovered by pytest session _pytest_fixtures: FixtureDict = {} # Stores all used function arguments - _invoked_with_func_args: Set[str] = set() + _invoked_with_func_args: set[str] = set() # Stores all invoked fixtures through @pytest.mark.usefixture(...) - _invoked_with_usefixtures: Set[str] = set() + _invoked_with_usefixtures: set[str] = set() _original_add_message = replacement_add_message def open(self): diff --git a/pylint_pytest/checkers/types.py b/pylint_pytest/checkers/types.py index c4c43e8..7fd5708 100644 --- a/pylint_pytest/checkers/types.py +++ b/pylint_pytest/checkers/types.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from pprint import pprint from typing import Any, Dict, List diff --git a/pyproject.toml b/pyproject.toml index b41cecb..a1fad97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,75 @@ -# Only a configuration storage, for now +[build-system] +requires = ["setuptools>=66.1"] +build-backend = "setuptools.build_meta" + +[project] +name = "pylint-pytest" +version = "2.0.0rc0" +license = {file = "LICENSE"} +description = "A Pylint plugin to suppress pytest-related false positives." + +authors = [ + {name = "Reverb Chu"}, +] +maintainers = [ + {name = "Stavros Ntentos", email = "133706+stdedos@users.noreply.github.com"}, + {name = "Pierre Sassoulas", email = "pierre.sassoulas@gmail.com"}, +] + +readme = "README.md" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Testing", + "Topic :: Software Development :: Quality Assurance", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Operating System :: OS Independent", + "License :: OSI Approved :: MIT License", +] +keywords = [ + "pylint", + "pytest", + "plugin", +] + +requires-python = ">=3.8" +dependencies = [ + "pylint>=2", + "pytest>=4.6", +] + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-cov", + # For linting purposes, only pylint>3 is supported + "pylint>=3", +] + +[project.urls] +Changelog = "https://github.com/pylint-dev/pylint-pytest/blob/master/CHANGELOG.md" +Documentation = "https://github.com/pylint-dev/pylint-pytest#readme" +Homepage = "https://github.com/pylint-dev/pylint-pytest" +Source = "https://github.com/pylint-dev/pylint-pytest" +Tracker = "https://github.com/pylint-dev/pylint-pytest/issues" +"Say Thanks!" = "https://saythanks.io/to/stdedos" + +[tool.setuptools] +license-files = ["LICENSE"] + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "sandbox", +] + [tool.aliases] test = "pytest" diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index 33e179f..28f5531 --- a/setup.py +++ b/setup.py @@ -1,52 +1,8 @@ -#!/usr/bin/env python +""" +Only a compatibility placeholder +https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +""" -from os import path +from setuptools import setup -from setuptools import find_packages, setup - -here = path.abspath(path.dirname(__file__)) -with open(path.join(here, "README.md")) as fin: - long_description = fin.read() - - -setup( - name="pylint-pytest", - version="1.1.7", - author="Stavros Ntentos", - author_email="133706+stdedos@users.noreply.github.com", - license="MIT", - url="https://github.com/pylint-dev/pylint-pytest", - project_urls={ - "Changelog": "https://github.com/pylint-dev/pylint-pytest/blob/master/CHANGELOG.md", - "Documentation": "https://github.com/pylint-dev/pylint-pytest#readme", - "Say Thanks!": "https://saythanks.io/to/stdedos", - "Source": "https://github.com/pylint-dev/pylint-pytest", - "Tracker": "https://github.com/pylint-dev/pylint-pytest/issues", - }, - description="A Pylint plugin to suppress pytest-related false positives.", - long_description=long_description, - long_description_content_type="text/markdown", - packages=find_packages(exclude=["tests*", "sandbox"]), - install_requires=[ - "pylint>=2", - "pytest>=4.6", - ], - python_requires=">=3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Topic :: Software Development :: Testing", - "Topic :: Software Development :: Quality Assurance", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Operating System :: OS Independent", - "License :: OSI Approved :: MIT License", - ], - tests_require=["pytest", "pytest-cov", "pylint"], - keywords=["pylint", "pytest", "plugin"], -) +setup() diff --git a/tests/base_tester.py b/tests/base_tester.py index c57971e..c775502 100644 --- a/tests/base_tester.py +++ b/tests/base_tester.py @@ -1,9 +1,10 @@ +from __future__ import annotations + import os import sys from abc import ABC from pathlib import Path from pprint import pprint -from typing import List, Type import astroid from pylint.checkers import BaseChecker @@ -23,9 +24,9 @@ def get_test_root_path() -> Path: class BasePytestTester(ABC): CHECKER_CLASS = BaseChecker - IMPACTED_CHECKER_CLASSES: List[Type[BaseChecker]] = [] + IMPACTED_CHECKER_CLASSES: list[BaseChecker] = [] MSG_ID: str - msgs: List[MessageTest] = [] + msgs: list[MessageTest] = [] def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) diff --git a/tests/base_tester_test.py b/tests/base_tester_test.py index b40d510..89c714c 100644 --- a/tests/base_tester_test.py +++ b/tests/base_tester_test.py @@ -25,7 +25,7 @@ class NoMsgIDSubclass(BasePytestTester): pass -@pytest.mark.parametrize("msg_id", [123, None, ""], ids=lambda x: f"msg_id={x}") +@pytest.mark.parametrize("msg_id", [123, None, ""], ids=lambda msg_id: f"{msg_id=}") def test_init_subclass_invalid_msg_id_type(msg_id): with pytest.raises(TypeError):