summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2021-02-07 18:44:44 +0100
committerGitHub <noreply@github.com>2021-02-07 18:44:44 +0100
commit325d701f6ed73a57d7ba723c4039b348a7ea27de (patch)
tree21be5cbf78a113e88a0abe58235d3b0ba69c63d7 /src
parentbcfe253f5b5367d8537e011e3a9e56bae220d411 (diff)
parenta9e43152bc5081afccc6de6ef5526ff35c525fed (diff)
downloadpytest-325d701f6ed73a57d7ba723c4039b348a7ea27de.tar.gz
Merge pull request #8248 from RonnyPfannschmidt/mixin-mro-position
alter the PyObjMixin to carry over typing information from Node
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/python.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index 3d903ff9b..726241cb5 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
@@ -254,20 +253,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):