Skip to content

Commit

Permalink
Revert "Roll back from __future__ import annotations for Python 3.6"
Browse files Browse the repository at this point in the history
This reverts commit b8ce4ad.

Signed-off-by: Stavros Ntentos <[email protected]>
  • Loading branch information
stdedos committed Dec 3, 2023
1 parent 421809d commit 37aea8b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
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
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 37aea8b

Please sign in to comment.