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, ...] 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: class Doc:
vocab: Vocab vocab: Vocab
mem: Pool mem: Pool
@ -57,7 +50,7 @@ class Doc:
default: Optional[Any] = ..., default: Optional[Any] = ...,
getter: Optional[Callable[[Doc], Any]] = ..., getter: Optional[Callable[[Doc], Any]] = ...,
setter: Optional[Callable[[Doc, Any], None]] = ..., setter: Optional[Callable[[Doc, Any], None]] = ...,
method: Optional[DocMethod] = ..., method: Optional[Callable[[Doc, Any]]] = ...,
force: bool = ..., force: bool = ...,
) -> None: ... ) -> None: ...
@classmethod @classmethod
@ -65,7 +58,7 @@ class Doc:
cls, name: str cls, name: str
) -> Tuple[ ) -> Tuple[
Optional[Any], Optional[Any],
Optional[DocMethod], Optional[Callable[[Doc, Any]]],
Optional[Callable[[Doc], Any]], Optional[Callable[[Doc], Any]],
Optional[Callable[[Doc, Any], None]], Optional[Callable[[Doc, Any], None]],
]: ... ]: ...
@ -76,7 +69,7 @@ class Doc:
cls, name: str cls, name: str
) -> Tuple[ ) -> Tuple[
Optional[Any], Optional[Any],
Optional[DocMethod], Optional[Callable[[Doc, Any]]],
Optional[Callable[[Doc], Any]], Optional[Callable[[Doc], Any]],
Optional[Callable[[Doc, Any], None]], Optional[Callable[[Doc, Any], None]],
]: ... ]: ...

View File

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

View File

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