diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2021-01-17 14:23:07 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2021-01-17 14:36:28 +0100 |
commit | a9e43152bc5081afccc6de6ef5526ff35c525fed (patch) | |
tree | 78ae86f2fb042269ae9ed1306fa86252bd1a8ba6 /src | |
parent | c9e9a599fe5231da90967b6f77c73e17c12740b7 (diff) | |
download | pytest-a9e43152bc5081afccc6de6ef5526ff35c525fed.tar.gz |
alter the PyObjMixin to carry over typing information from Node
as PyObjMixin is always supposed to be mixed in the mro
before nodes.Node the behavior doesn't change,
but all the typing information carry over to help mypy.
extracted from #8037
Diffstat (limited to 'src')
-rw-r--r-- | src/_pytest/python.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 29ebd176b..eabd7b311 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -23,7 +23,6 @@ from typing import Optional from typing import Sequence from typing import Set from typing import Tuple -from typing import Type from typing import TYPE_CHECKING from typing import Union @@ -255,20 +254,13 @@ def pytest_pycollect_makeitem(collector: "PyCollector", name: str, obj: object): return res -class PyobjMixin: - _ALLOW_MARKERS = True - - # Function and attributes that the mixin needs (for type-checking only). - if TYPE_CHECKING: - name: str = "" - parent: Optional[nodes.Node] = None - own_markers: List[Mark] = [] +class PyobjMixin(nodes.Node): + """this mix-in inherits from Node to carry over the typing information - def getparent(self, cls: Type[nodes._NodeType]) -> Optional[nodes._NodeType]: - ... + as its intended to always mix in before a node + its position in the mro is unaffected""" - def listchain(self) -> List[nodes.Node]: - ... + _ALLOW_MARKERS = True @property def module(self): |