Skip to content

Commit

Permalink
Merge pull request #7841 from asottile/py36_todo
Browse files Browse the repository at this point in the history
py36+: resolve py36 TODOs
  • Loading branch information
asottile committed Oct 3, 2020
2 parents c2a197f + 53b5f64 commit aa077ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
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

0 comments on commit aa077ab

Please sign in to comment.