Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py36+: resolve py36 TODOs #7841

Merged
merged 1 commit into from Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/_pytest/mark/structures.py
Expand Up @@ -8,6 +8,7 @@
from typing import Iterator
from typing import List
from typing import Mapping
from typing import MutableMapping
from typing import NamedTuple
from typing import Optional
from typing import Sequence
Expand Down Expand Up @@ -94,8 +95,7 @@ def param(
if isinstance(marks, MarkDecorator):
marks = (marks,)
else:
# TODO(py36): Change to collections.abc.Collection.
assert isinstance(marks, (collections.abc.Sequence, set))
assert isinstance(marks, collections.abc.Collection)

if id is not None:
if not isinstance(id, str):
Expand Down Expand Up @@ -475,13 +475,12 @@ def test_function():

# See TYPE_CHECKING above.
if TYPE_CHECKING:
# TODO(py36): Change to builtin annotation syntax.
skip = _SkipMarkDecorator(Mark("skip", (), {}))
skipif = _SkipifMarkDecorator(Mark("skipif", (), {}))
xfail = _XfailMarkDecorator(Mark("xfail", (), {}))
parametrize = _ParametrizeMarkDecorator(Mark("parametrize", (), {}))
usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures", (), {}))
filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings", (), {}))
skip: _SkipMarkDecorator
skipif: _SkipifMarkDecorator
xfail: _XfailMarkDecorator
parametrize: _ParametrizeMarkDecorator
usefixtures: _UsefixturesMarkDecorator
filterwarnings: _FilterwarningsMarkDecorator

def __getattr__(self, name: str) -> MarkDecorator:
if name[0] == "_":
Expand Down Expand Up @@ -527,9 +526,8 @@ def __getattr__(self, name: str) -> MarkDecorator:
MARK_GEN = MarkGenerator()


# TODO(py36): inherit from typing.MutableMapping[str, Any].
@final
class NodeKeywords(collections.abc.MutableMapping): # type: ignore[type-arg]
class NodeKeywords(MutableMapping[str, Any]):
def __init__(self, node: "Node") -> None:
self.node = node
self.parent = node.parent
Expand Down
5 changes: 2 additions & 3 deletions testing/test_assertion.py
@@ -1,8 +1,8 @@
import collections.abc
import sys
import textwrap
from typing import Any
from typing import List
from typing import MutableSequence
from typing import Optional

import attr
Expand Down Expand Up @@ -637,8 +637,7 @@ def test_frozenzet(self) -> None:

def test_Sequence(self) -> None:
# Test comparing with a Sequence subclass.
# TODO(py36): Inherit from typing.MutableSequence[int].
class TestSequence(collections.abc.MutableSequence): # type: ignore[type-arg]
class TestSequence(MutableSequence[int]):
def __init__(self, iterable):
self.elements = list(iterable)

Expand Down