change set_extension method argument to Callable[]

This commit is contained in:
Mike Ribbons 2024-09-10 21:15:44 +10:00
parent 8a45a9fb89
commit 228045464b
3 changed files with 9 additions and 30 deletions

View File

@ -28,13 +28,6 @@ from .underscore import Underscore
DOCBIN_ALL_ATTRS: Tuple[str, ...]
DocMethod = Union[
Callable[[Doc], Any],
Callable[[Doc, Any], Any],
Callable[[Doc, Any, Any], Any],
Callable[[Doc, Any, Any, Any], Any],
]
class Doc:
vocab: Vocab
mem: Pool
@ -57,7 +50,7 @@ class Doc:
default: Optional[Any] = ...,
getter: Optional[Callable[[Doc], Any]] = ...,
setter: Optional[Callable[[Doc, Any], None]] = ...,
method: Optional[DocMethod] = ...,
method: Optional[Callable[[Doc, Any]]] = ...,
force: bool = ...,
) -> None: ...
@classmethod
@ -65,7 +58,7 @@ class Doc:
cls, name: str
) -> Tuple[
Optional[Any],
Optional[DocMethod],
Optional[Callable[[Doc, Any]]],
Optional[Callable[[Doc], Any]],
Optional[Callable[[Doc, Any], None]],
]: ...
@ -76,7 +69,7 @@ class Doc:
cls, name: str
) -> Tuple[
Optional[Any],
Optional[DocMethod],
Optional[Callable[[Doc, Any]]],
Optional[Callable[[Doc], Any]],
Optional[Callable[[Doc, Any], None]],
]: ...

View File

@ -8,13 +8,6 @@ from .doc import Doc
from .token import Token
from .underscore import Underscore
SpanMethod = Union[
Callable[[Span], Any],
Callable[[Span, Any], Any],
Callable[[Span, Any, Any], Any],
Callable[[Span, Any, Any, Any], Any],
]
class Span:
@classmethod
def set_extension(
@ -23,7 +16,7 @@ class Span:
default: Optional[Any] = ...,
getter: Optional[Callable[[Span], Any]] = ...,
setter: Optional[Callable[[Span, Any], None]] = ...,
method: Optional[SpanMethod] = ...,
method: Optional[Callable[[Span, Any]]] = ...,
force: bool = ...,
) -> None: ...
@classmethod
@ -31,7 +24,7 @@ class Span:
cls, name: str
) -> Tuple[
Optional[Any],
Optional[SpanMethod],
Optional[Callable[[Span, Any]]],
Optional[Callable[[Span], Any]],
Optional[Callable[[Span, Any], None]],
]: ...
@ -42,7 +35,7 @@ class Span:
cls, name: str
) -> Tuple[
Optional[Any],
Optional[SpanMethod],
Optional[Callable[[Span, Any]]],
Optional[Callable[[Span], Any]],
Optional[Callable[[Span, Any], None]],
]: ...

View File

@ -9,13 +9,6 @@ from .morphanalysis import MorphAnalysis
from .span import Span
from .underscore import Underscore
TokenMethod = Union[
Callable[[Token], Any],
Callable[[Token, Any], Any],
Callable[[Token, Any, Any], Any],
Callable[[Token, Any, Any, Any], Any],
]
class Token:
i: int
doc: Doc
@ -27,7 +20,7 @@ class Token:
default: Optional[Any] = ...,
getter: Optional[Callable[[Token], Any]] = ...,
setter: Optional[Callable[[Token, Any], None]] = ...,
method: Optional[TokenMethod] = ...,
method: Optional[Callable[[Token, Any]]] = ...,
force: bool = ...,
) -> None: ...
@classmethod
@ -35,7 +28,7 @@ class Token:
cls, name: str
) -> Tuple[
Optional[Any],
Optional[TokenMethod],
Optional[Callable[[Token, Any]]],
Optional[Callable[[Token], Any]],
Optional[Callable[[Token, Any], None]],
]: ...
@ -46,7 +39,7 @@ class Token:
cls, name: str
) -> Tuple[
Optional[Any],
Optional[TokenMethod],
Optional[Callable[[Token, Any]]],
Optional[Callable[[Token], Any]],
Optional[Callable[[Token, Any], None]],
]: ...