mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
PyYAML: Add types to add_constructor (#7989)
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
from typing import Any, Pattern
|
||||
from collections.abc import Callable
|
||||
from typing import Any, Pattern, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from yaml.error import MarkedYAMLError
|
||||
from yaml.nodes import ScalarNode
|
||||
from yaml.loader import BaseLoader, FullLoader, Loader, SafeLoader, UnsafeLoader
|
||||
from yaml.nodes import Node, ScalarNode
|
||||
|
||||
_L = TypeVar("_L", bound=Loader | BaseLoader | FullLoader | SafeLoader | UnsafeLoader)
|
||||
_N = TypeVar("_N", bound=Node)
|
||||
|
||||
_Scalar: TypeAlias = str | int | float | bool | None
|
||||
|
||||
@@ -27,7 +32,8 @@ class BaseConstructor:
|
||||
def construct_mapping(self, node, deep=...): ...
|
||||
def construct_pairs(self, node, deep=...): ...
|
||||
@classmethod
|
||||
def add_constructor(cls, tag, constructor): ...
|
||||
# Use typevars so we can have covariant behaviour in the parameter types
|
||||
def add_constructor(cls, tag: str, constructor: Callable[[_L, _N], Any]) -> None: ...
|
||||
@classmethod
|
||||
def add_multi_constructor(cls, tag_prefix, multi_constructor): ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user