Skip to content

Commit

Permalink
Merge pull request #8 from pylint-dev/migrate-to-setup.cfg
Browse files Browse the repository at this point in the history
See more details in #8
  • Loading branch information
stdedos committed Dec 19, 2023
2 parents 69ad82f + 2df48d8 commit f559398
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pylint_pytest/checkers/class_attr_loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Set
from __future__ import annotations

from astroid import Assign, Attribute, ClassDef, Name

Expand All @@ -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"""
Expand Down
11 changes: 6 additions & 5 deletions pylint_pytest/checkers/fixture.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
)
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions pylint_pytest/checkers/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import sys
from pprint import pprint
from typing import Any, Dict, List
Expand Down
73 changes: 72 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
{name = "Pierre Sassoulas", email = "[email protected]"},
]

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"

Expand Down
56 changes: 6 additions & 50 deletions setup.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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()
7 changes: 4 additions & 3 deletions tests/base_tester.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/base_tester_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit f559398

Please sign in to comment.