Merge pull request #7841 from asottile/py36_todo
py36+: resolve py36 TODOs
This commit is contained in:
commit
aa077ab188
|
@ -8,6 +8,7 @@ from typing import Iterable
|
||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Mapping
|
from typing import Mapping
|
||||||
|
from typing import MutableMapping
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
@ -94,8 +95,7 @@ class ParameterSet(
|
||||||
if isinstance(marks, MarkDecorator):
|
if isinstance(marks, MarkDecorator):
|
||||||
marks = (marks,)
|
marks = (marks,)
|
||||||
else:
|
else:
|
||||||
# TODO(py36): Change to collections.abc.Collection.
|
assert isinstance(marks, collections.abc.Collection)
|
||||||
assert isinstance(marks, (collections.abc.Sequence, set))
|
|
||||||
|
|
||||||
if id is not None:
|
if id is not None:
|
||||||
if not isinstance(id, str):
|
if not isinstance(id, str):
|
||||||
|
@ -475,13 +475,12 @@ class MarkGenerator:
|
||||||
|
|
||||||
# See TYPE_CHECKING above.
|
# See TYPE_CHECKING above.
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
# TODO(py36): Change to builtin annotation syntax.
|
skip: _SkipMarkDecorator
|
||||||
skip = _SkipMarkDecorator(Mark("skip", (), {}))
|
skipif: _SkipifMarkDecorator
|
||||||
skipif = _SkipifMarkDecorator(Mark("skipif", (), {}))
|
xfail: _XfailMarkDecorator
|
||||||
xfail = _XfailMarkDecorator(Mark("xfail", (), {}))
|
parametrize: _ParametrizeMarkDecorator
|
||||||
parametrize = _ParametrizeMarkDecorator(Mark("parametrize", (), {}))
|
usefixtures: _UsefixturesMarkDecorator
|
||||||
usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures", (), {}))
|
filterwarnings: _FilterwarningsMarkDecorator
|
||||||
filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings", (), {}))
|
|
||||||
|
|
||||||
def __getattr__(self, name: str) -> MarkDecorator:
|
def __getattr__(self, name: str) -> MarkDecorator:
|
||||||
if name[0] == "_":
|
if name[0] == "_":
|
||||||
|
@ -527,9 +526,8 @@ class MarkGenerator:
|
||||||
MARK_GEN = MarkGenerator()
|
MARK_GEN = MarkGenerator()
|
||||||
|
|
||||||
|
|
||||||
# TODO(py36): inherit from typing.MutableMapping[str, Any].
|
|
||||||
@final
|
@final
|
||||||
class NodeKeywords(collections.abc.MutableMapping): # type: ignore[type-arg]
|
class NodeKeywords(MutableMapping[str, Any]):
|
||||||
def __init__(self, node: "Node") -> None:
|
def __init__(self, node: "Node") -> None:
|
||||||
self.node = node
|
self.node = node
|
||||||
self.parent = node.parent
|
self.parent = node.parent
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import collections.abc
|
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import List
|
from typing import List
|
||||||
|
from typing import MutableSequence
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
@ -637,8 +637,7 @@ class TestAssert_reprcompare:
|
||||||
|
|
||||||
def test_Sequence(self) -> None:
|
def test_Sequence(self) -> None:
|
||||||
# Test comparing with a Sequence subclass.
|
# Test comparing with a Sequence subclass.
|
||||||
# TODO(py36): Inherit from typing.MutableSequence[int].
|
class TestSequence(MutableSequence[int]):
|
||||||
class TestSequence(collections.abc.MutableSequence): # type: ignore[type-arg]
|
|
||||||
def __init__(self, iterable):
|
def __init__(self, iterable):
|
||||||
self.elements = list(iterable)
|
self.elements = list(iterable)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue