Skip to content

Commit 37aea8b

Browse files
committed
Revert "Roll back from __future__ import annotations for Python 3.6"
This reverts commit b8ce4ad. Signed-off-by: Stavros Ntentos <[email protected]>
1 parent 421809d commit 37aea8b

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
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 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

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)