Skip to content

Commit 6fe2599

Browse files
committed
typing for diff
Before: Diff Coverage Diff: eb00182...HEAD, staged and unstaged changes ------------- src/_pytest/mark/structures.py (0.0%): Missing lines 274 src/_pytest/nodes.py (100%) src/_pytest/python.py (72.2%): Missing lines 290,301,1518-1520 testing/test_mark.py (61.5%): Missing lines 967,981,984,989,992-993,995,997-1000,1014-1015,1017-1018 ------------- Total: 63 lines Missing: 21 lines Coverage: 66% After: Diff Coverage Diff: eb00182...HEAD, staged and unstaged changes ------------- src/_pytest/mark/structures.py (100%) src/_pytest/nodes.py (100%) src/_pytest/python.py (95.7%): Missing lines 1519 testing/test_mark.py (64.1%): Missing lines 967,984,989,992-993,995,997-1000,1014-1015,1017-1018 ------------- Total: 72 lines Missing: 15 lines Coverage: 79%
1 parent 2cadcfd commit 6fe2599

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/_pytest/mark/structures.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .._code.source import getfslineno
1818
from ..compat import ascii_escaped
1919
from ..compat import NOTSET
20+
from .. import nodes
2021
from _pytest.outcomes import fail
2122
from _pytest.warning_types import PytestUnknownMarkWarning
2223

@@ -271,7 +272,7 @@ def __call__(self, *args: object, **kwargs: object):
271272
return self.with_args(*args, **kwargs)
272273

273274

274-
def get_unpacked_marks(obj) -> List[Mark]:
275+
def get_unpacked_marks(obj: object) -> List[Mark]:
275276
"""
276277
obtain the unpacked marks that are stored on an object
277278
"""
@@ -371,7 +372,7 @@ def __getattr__(self, name: str) -> MarkDecorator:
371372

372373

373374
class NodeKeywords(MutableMapping):
374-
def __init__(self, node):
375+
def __init__(self, node: nodes.Node) -> None:
375376
self.node = node
376377
self.parent = node.parent
377378
self._markers = {node.name: True}

src/_pytest/nodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from functools import lru_cache
44
from typing import Any
55
from typing import Dict
6+
from typing import Iterator
67
from typing import List
78
from typing import Optional
89
from typing import Set
@@ -264,7 +265,7 @@ def add_marker(
264265
else:
265266
self._own_markers[0].insert(0, marker_.mark)
266267

267-
def iter_markers(self, name=None):
268+
def iter_markers(self, name: Optional[str] = None) -> Iterator[Mark]:
268269
"""
269270
:param name: if given, filter the results by the name attribute
270271

src/_pytest/python.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,19 @@ class PyobjMixin:
279279
_own_markers = ([], []) # type: Tuple[List[Mark], List[Mark]]
280280

281281
@property
282-
def obj(self):
282+
def obj(self) -> object:
283283
"""Underlying Python object."""
284284
obj = getattr(self, "_obj", None)
285285
if obj is None:
286286
self._obj = obj = self._getobj()
287287
return obj
288288

289289
@obj.setter
290-
def obj(self, value) -> None:
290+
def obj(self, value: object) -> None:
291291
self._obj = value
292292
self._obj_markers = None
293293

294-
def _getobj(self):
294+
def _getobj(self) -> object:
295295
"""Gets the underlying Python object. May be overwritten by subclasses."""
296296
return getattr(self.parent.obj, self.name)
297297

@@ -791,13 +791,13 @@ def hasnew(obj):
791791

792792

793793
class CallSpec2:
794-
def __init__(self, metafunc):
794+
def __init__(self, metafunc: "Metafunc") -> None:
795795
self.metafunc = metafunc
796796
self.funcargs = {}
797797
self._idlist = []
798798
self.params = {}
799799
self._arg2scopenum = {} # used for sorting parametrized resources
800-
self.marks = []
800+
self.marks = [] # type: List[Mark]
801801
self.indices = {}
802802

803803
def copy(self):
@@ -1448,7 +1448,7 @@ def __init__(
14481448
config=None,
14491449
callspec: Optional[CallSpec2] = None,
14501450
callobj=NOTSET,
1451-
keywords=None,
1451+
keywords: Optional[Iterable[str]] = None,
14521452
session=None,
14531453
fixtureinfo: Optional[FuncFixtureInfo] = None,
14541454
originalname=None,

0 commit comments

Comments
 (0)