Merge pull request #8248 from RonnyPfannschmidt/mixin-mro-position
alter the PyObjMixin to carry over typing information from Node
This commit is contained in:
commit
325d701f6e
|
@ -0,0 +1 @@
|
||||||
|
Internal Restructure: let python.PyObjMixing inherit from nodes.Node to carry over typing information.
|
|
@ -23,7 +23,6 @@ from typing import Optional
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from typing import Set
|
from typing import Set
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
from typing import Type
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
@ -254,21 +253,14 @@ def pytest_pycollect_makeitem(collector: "PyCollector", name: str, obj: object):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
class PyobjMixin:
|
class PyobjMixin(nodes.Node):
|
||||||
|
"""this mix-in inherits from Node to carry over the typing information
|
||||||
|
|
||||||
|
as its intended to always mix in before a node
|
||||||
|
its position in the mro is unaffected"""
|
||||||
|
|
||||||
_ALLOW_MARKERS = True
|
_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] = []
|
|
||||||
|
|
||||||
def getparent(self, cls: Type[nodes._NodeType]) -> Optional[nodes._NodeType]:
|
|
||||||
...
|
|
||||||
|
|
||||||
def listchain(self) -> List[nodes.Node]:
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def module(self):
|
def module(self):
|
||||||
"""Python module object this node was collected from (can be None)."""
|
"""Python module object this node was collected from (can be None)."""
|
||||||
|
|
Loading…
Reference in New Issue