complete typing of nodes.py
This commit is contained in:
parent
68b985346b
commit
608436cda1
|
@ -1,4 +1,3 @@
|
||||||
# mypy: allow-untyped-defs
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
@ -96,7 +95,7 @@ class NodeMeta(abc.ABCMeta):
|
||||||
progress on detangling the :class:`Node` classes.
|
progress on detangling the :class:`Node` classes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(cls, *k, **kw) -> NoReturn:
|
def __call__(cls, *k: object, **kw: object) -> NoReturn:
|
||||||
msg = (
|
msg = (
|
||||||
"Direct construction of {name} has been deprecated, please use {name}.from_parent.\n"
|
"Direct construction of {name} has been deprecated, please use {name}.from_parent.\n"
|
||||||
"See "
|
"See "
|
||||||
|
@ -105,7 +104,7 @@ class NodeMeta(abc.ABCMeta):
|
||||||
).format(name=f"{cls.__module__}.{cls.__name__}")
|
).format(name=f"{cls.__module__}.{cls.__name__}")
|
||||||
fail(msg, pytrace=False)
|
fail(msg, pytrace=False)
|
||||||
|
|
||||||
def _create(cls: type[_T], *k, **kw) -> _T:
|
def _create(cls: type[_T], *k: Any, **kw: Any) -> _T:
|
||||||
try:
|
try:
|
||||||
return super().__call__(*k, **kw) # type: ignore[no-any-return,misc]
|
return super().__call__(*k, **kw) # type: ignore[no-any-return,misc]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
@ -225,7 +224,7 @@ class Node(abc.ABC, metaclass=NodeMeta):
|
||||||
return f"{parent.nodeid}::{name}"
|
return f"{parent.nodeid}::{name}"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_parent(cls, parent: Node, **kw) -> Self:
|
def from_parent(cls, parent: Node, **kw: Any) -> Self:
|
||||||
"""Public constructor for Nodes.
|
"""Public constructor for Nodes.
|
||||||
|
|
||||||
This indirection got introduced in order to enable removing
|
This indirection got introduced in order to enable removing
|
||||||
|
@ -620,11 +619,11 @@ class FSCollector(Collector, abc.ABC):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_parent(
|
def from_parent(
|
||||||
cls,
|
cls,
|
||||||
parent,
|
parent: Node,
|
||||||
*,
|
*,
|
||||||
fspath: LEGACY_PATH | None = None,
|
fspath: LEGACY_PATH | None = None,
|
||||||
path: Path | None = None,
|
path: Path | None = None,
|
||||||
**kw,
|
**kw: Any,
|
||||||
) -> Self:
|
) -> Self:
|
||||||
"""The public constructor."""
|
"""The public constructor."""
|
||||||
return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
|
return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
|
||||||
|
@ -661,16 +660,14 @@ class Item(Node, abc.ABC):
|
||||||
Note that for a single function there might be multiple test invocation items.
|
Note that for a single function there might be multiple test invocation items.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
nextitem = None
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name,
|
name: str,
|
||||||
parent=None,
|
parent: Node | None = None,
|
||||||
config: Config | None = None,
|
config: Config | None = None,
|
||||||
session: Session | None = None,
|
session: Session | None = None,
|
||||||
nodeid: str | None = None,
|
nodeid: str | None = None,
|
||||||
**kw,
|
**kw: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
# The first two arguments are intentionally passed positionally,
|
# The first two arguments are intentionally passed positionally,
|
||||||
# to keep plugins who define a node type which inherits from
|
# to keep plugins who define a node type which inherits from
|
||||||
|
|
Loading…
Reference in New Issue