Skip to content

Commit b8ce4ad

Browse files
committed
Roll back from __future__ import annotations for Python 3.6
... and `f{msg_id=}` Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
1 parent b65e979 commit b8ce4ad

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

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 __future__ import annotations
1+
from typing import Optional, Set
22

33
from astroid import Assign, Attribute, ClassDef, Name
44
from pylint.interfaces import IAstroidChecker
@@ -12,8 +12,8 @@ class ClassAttrLoader(BasePytestChecker):
1212
msgs = {"E6400": ("", "pytest-class-attr-loader", "")}
1313

1414
in_setup = False
15-
request_cls: set[str] = set()
16-
class_node: ClassDef | None = None
15+
request_cls: Set[str] = set()
16+
class_node: Optional[ClassDef] = None
1717

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

pylint_pytest/checkers/fixture.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from __future__ import annotations
2-
31
import fnmatch
42
import os
53
import sys
64
from pathlib import Path
5+
from typing import Set, Tuple
76

87
import astroid
98
import pylint
@@ -22,7 +21,7 @@
2221
from .types import FixtureDict, replacement_add_message
2322

2423
# TODO: support pytest python_files configuration
25-
FILE_NAME_PATTERNS: tuple[str, ...] = ("test_*.py", "*_test.py")
24+
FILE_NAME_PATTERNS: Tuple[str, ...] = ("test_*.py", "*_test.py")
2625
ARGUMENT_ARE_KEYWORD_ONLY = (
2726
"https://docs.pytest.org/en/stable/deprecations.html#pytest-fixture-arguments-are-keyword-only"
2827
)
@@ -31,7 +30,7 @@
3130
class FixtureCollector:
3231
# Same as ``_pytest.fixtures.FixtureManager._arg2fixturedefs``.
3332
fixtures: FixtureDict = {}
34-
errors: set[pytest.CollectReport] = set()
33+
errors: Set[pytest.CollectReport] = set()
3534

3635
def pytest_sessionfinish(self, session):
3736
# pylint: disable=protected-access
@@ -80,9 +79,9 @@ class FixtureChecker(BasePytestChecker):
8079
# Store all fixtures discovered by pytest session
8180
_pytest_fixtures: FixtureDict = {}
8281
# Stores all used function arguments
83-
_invoked_with_func_args: set[str] = set()
82+
_invoked_with_func_args: Set[str] = set()
8483
# Stores all invoked fixtures through @pytest.mark.usefixture(...)
85-
_invoked_with_usefixtures: set[str] = set()
84+
_invoked_with_usefixtures: Set[str] = set()
8685
_original_add_message = replacement_add_message
8786

8887
def open(self):

pylint_pytest/checkers/types.py

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

tests/base_tester.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from __future__ import annotations
2-
31
import os
42
import sys
53
from abc import ABC
64
from pprint import pprint
7-
from typing import Any
5+
from typing import Any, Dict, List
86

97
import astroid
108
from pylint.testutils import MessageTest, UnittestLinter
@@ -25,10 +23,10 @@
2523

2624
class BasePytestTester(ABC):
2725
CHECKER_CLASS = BaseChecker
28-
IMPACTED_CHECKER_CLASSES: list[BaseChecker] = []
26+
IMPACTED_CHECKER_CLASSES: List[BaseChecker] = []
2927
MSG_ID: str
30-
msgs: list[MessageTest] = []
31-
CONFIG: dict[str, Any] = {}
28+
msgs: List[MessageTest] = []
29+
CONFIG: Dict[str, Any] = {}
3230

3331
def __init_subclass__(cls, **kwargs):
3432
super().__init_subclass__(**kwargs)

tests/base_tester_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class NoMsgIDSubclass(BasePytestTester):
2020
pass
2121

2222

23-
@pytest.mark.parametrize("msg_id", [123, None, ""], ids=lambda msg_id: f"{msg_id=}")
23+
@pytest.mark.parametrize("msg_id", [123, None, ""], ids=lambda x: f"msg_id={x}")
2424
def test_init_subclass_invalid_msg_id_type(msg_id):
2525
with pytest.raises(TypeError):
2626

0 commit comments

Comments
 (0)