Skip to content

Commit f559398

Browse files
authored
Merge pull request #8 from pylint-dev/migrate-to-setup.cfg
See more details in #8
2 parents 69ad82f + 2df48d8 commit f559398

File tree

9 files changed

+101
-64
lines changed

9 files changed

+101
-64
lines changed

.github/workflows/run-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- '3.9'
2525
- '3.10'
2626
- '3.11'
27-
# - '3.12' # FixMe: https://github.com/pylint-dev/pylint-pytest/issues/3
27+
- '3.12'
2828

2929
defaults:
3030
run:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
* Migrate setup.py to pyproject.toml (https://github.com/pylint-dev/pylint-pytest/pull/8)
8+
* Support for Python 3.12 (https://github.com/pylint-dev/pylint-pytest/issues/3,
9+
"side effect" of https://github.com/pylint-dev/pylint-pytest/pull/8)
10+
511
### Removed
612

713
* Support for Python 3.6 & 3.7 (https://github.com/pylint-dev/pylint-pytest/pull/23)

pylint_pytest/checkers/class_attr_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Set
1+
from __future__ import annotations
22

33
from astroid import Assign, Attribute, ClassDef, Name
44

@@ -10,8 +10,8 @@ class ClassAttrLoader(BasePytestChecker):
1010
msgs = {"E6400": ("", "pytest-class-attr-loader", "")}
1111

1212
in_setup = False
13-
request_cls: Set[str] = set()
14-
class_node: Optional[ClassDef] = None
13+
request_cls: set[str] = set()
14+
class_node: ClassDef | None = None
1515

1616
def visit_functiondef(self, node):
1717
"""determine if a method is a class setup method"""

pylint_pytest/checkers/fixture.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from __future__ import annotations
2+
13
import fnmatch
24
import io
35
import sys
46
from pathlib import Path
5-
from typing import Set, Tuple
67

78
import astroid
89
import pytest
@@ -19,7 +20,7 @@
1920
from .types import FixtureDict, replacement_add_message
2021

2122
# TODO: support pytest python_files configuration
22-
FILE_NAME_PATTERNS: Tuple[str, ...] = ("test_*.py", "*_test.py")
23+
FILE_NAME_PATTERNS: tuple[str, ...] = ("test_*.py", "*_test.py")
2324
ARGUMENT_ARE_KEYWORD_ONLY = (
2425
"https://docs.pytest.org/en/stable/deprecations.html#pytest-fixture-arguments-are-keyword-only"
2526
)
@@ -28,7 +29,7 @@
2829
class FixtureCollector:
2930
# Same as ``_pytest.fixtures.FixtureManager._arg2fixturedefs``.
3031
fixtures: FixtureDict = {}
31-
errors: Set[pytest.CollectReport] = set()
32+
errors: set[pytest.CollectReport] = set()
3233

3334
def pytest_sessionfinish(self, session):
3435
# pylint: disable=protected-access
@@ -76,9 +77,9 @@ class FixtureChecker(BasePytestChecker):
7677
# Store all fixtures discovered by pytest session
7778
_pytest_fixtures: FixtureDict = {}
7879
# Stores all used function arguments
79-
_invoked_with_func_args: Set[str] = set()
80+
_invoked_with_func_args: set[str] = set()
8081
# Stores all invoked fixtures through @pytest.mark.usefixture(...)
81-
_invoked_with_usefixtures: Set[str] = set()
82+
_invoked_with_usefixtures: set[str] = set()
8283
_original_add_message = replacement_add_message
8384

8485
def open(self):

pylint_pytest/checkers/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import sys
24
from pprint import pprint
35
from typing import Any, Dict, List

pyproject.toml

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,75 @@
1-
# Only a configuration storage, for now
1+
[build-system]
2+
requires = ["setuptools>=66.1"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pylint-pytest"
7+
version = "2.0.0rc0"
8+
license = {file = "LICENSE"}
9+
description = "A Pylint plugin to suppress pytest-related false positives."
10+
11+
authors = [
12+
{name = "Reverb Chu"},
13+
]
14+
maintainers = [
15+
{name = "Stavros Ntentos", email = "[email protected]"},
16+
{name = "Pierre Sassoulas", email = "[email protected]"},
17+
]
18+
19+
readme = "README.md"
20+
classifiers = [
21+
"Development Status :: 5 - Production/Stable",
22+
"Intended Audience :: Developers",
23+
"Topic :: Software Development :: Testing",
24+
"Topic :: Software Development :: Quality Assurance",
25+
"Programming Language :: Python",
26+
"Programming Language :: Python :: 3",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Operating System :: OS Independent",
34+
"License :: OSI Approved :: MIT License",
35+
]
36+
keywords = [
37+
"pylint",
38+
"pytest",
39+
"plugin",
40+
]
41+
42+
requires-python = ">=3.8"
43+
dependencies = [
44+
"pylint>=2",
45+
"pytest>=4.6",
46+
]
47+
48+
[project.optional-dependencies]
49+
test = [
50+
"pytest",
51+
"pytest-cov",
52+
# For linting purposes, only pylint>3 is supported
53+
"pylint>=3",
54+
]
55+
56+
[project.urls]
57+
Changelog = "https://github.com/pylint-dev/pylint-pytest/blob/master/CHANGELOG.md"
58+
Documentation = "https://github.com/pylint-dev/pylint-pytest#readme"
59+
Homepage = "https://github.com/pylint-dev/pylint-pytest"
60+
Source = "https://github.com/pylint-dev/pylint-pytest"
61+
Tracker = "https://github.com/pylint-dev/pylint-pytest/issues"
62+
"Say Thanks!" = "https://saythanks.io/to/stdedos"
63+
64+
[tool.setuptools]
65+
license-files = ["LICENSE"]
66+
67+
[tool.setuptools.packages.find]
68+
exclude = [
69+
"tests*",
70+
"sandbox",
71+
]
72+
273
[tool.aliases]
374
test = "pytest"
475

setup.py

100755100644
Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,8 @@
1-
#!/usr/bin/env python
1+
"""
2+
Only a compatibility placeholder
3+
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
4+
"""
25

3-
from os import path
6+
from setuptools import setup
47

5-
from setuptools import find_packages, setup
6-
7-
here = path.abspath(path.dirname(__file__))
8-
with open(path.join(here, "README.md")) as fin:
9-
long_description = fin.read()
10-
11-
12-
setup(
13-
name="pylint-pytest",
14-
version="1.1.7",
15-
author="Stavros Ntentos",
16-
author_email="[email protected]",
17-
license="MIT",
18-
url="https://github.com/pylint-dev/pylint-pytest",
19-
project_urls={
20-
"Changelog": "https://github.com/pylint-dev/pylint-pytest/blob/master/CHANGELOG.md",
21-
"Documentation": "https://github.com/pylint-dev/pylint-pytest#readme",
22-
"Say Thanks!": "https://saythanks.io/to/stdedos",
23-
"Source": "https://github.com/pylint-dev/pylint-pytest",
24-
"Tracker": "https://github.com/pylint-dev/pylint-pytest/issues",
25-
},
26-
description="A Pylint plugin to suppress pytest-related false positives.",
27-
long_description=long_description,
28-
long_description_content_type="text/markdown",
29-
packages=find_packages(exclude=["tests*", "sandbox"]),
30-
install_requires=[
31-
"pylint>=2",
32-
"pytest>=4.6",
33-
],
34-
python_requires=">=3.8",
35-
classifiers=[
36-
"Development Status :: 5 - Production/Stable",
37-
"Intended Audience :: Developers",
38-
"Topic :: Software Development :: Testing",
39-
"Topic :: Software Development :: Quality Assurance",
40-
"Programming Language :: Python",
41-
"Programming Language :: Python :: 3",
42-
"Programming Language :: Python :: 3.8",
43-
"Programming Language :: Python :: 3.9",
44-
"Programming Language :: Python :: 3.10",
45-
"Programming Language :: Python :: 3.11",
46-
"Programming Language :: Python :: Implementation :: CPython",
47-
"Operating System :: OS Independent",
48-
"License :: OSI Approved :: MIT License",
49-
],
50-
tests_require=["pytest", "pytest-cov", "pylint"],
51-
keywords=["pylint", "pytest", "plugin"],
52-
)
8+
setup()

tests/base_tester.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from __future__ import annotations
2+
13
import os
24
import sys
35
from abc import ABC
46
from pathlib import Path
57
from pprint import pprint
6-
from typing import List, Type
78

89
import astroid
910
from pylint.checkers import BaseChecker
@@ -23,9 +24,9 @@ def get_test_root_path() -> Path:
2324

2425
class BasePytestTester(ABC):
2526
CHECKER_CLASS = BaseChecker
26-
IMPACTED_CHECKER_CLASSES: List[Type[BaseChecker]] = []
27+
IMPACTED_CHECKER_CLASSES: list[BaseChecker] = []
2728
MSG_ID: str
28-
msgs: List[MessageTest] = []
29+
msgs: list[MessageTest] = []
2930

3031
def __init_subclass__(cls, **kwargs):
3132
super().__init_subclass__(**kwargs)

tests/base_tester_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NoMsgIDSubclass(BasePytestTester):
2525
pass
2626

2727

28-
@pytest.mark.parametrize("msg_id", [123, None, ""], ids=lambda x: f"msg_id={x}")
28+
@pytest.mark.parametrize("msg_id", [123, None, ""], ids=lambda msg_id: f"{msg_id=}")
2929
def test_init_subclass_invalid_msg_id_type(msg_id):
3030
with pytest.raises(TypeError):
3131

0 commit comments

Comments
 (0)