mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 18:26:30 +03:00
Fix StringStore.__getitem__ return type depending on parameter types (#10741)
* Fix StringStore.__getitem__ return type depending on parameter types Small fix using `@overload` so that `StringStore.__getitem__` returns an `int` when given a `str` or `bytes` and a `str` when given an `int`. * Update spacy/strings.pyi Co-authored-by: Adriane Boyd <adrianeboyd@gmail.com>
This commit is contained in:
parent
e03b9f8095
commit
0a92d5644e
|
@ -1,4 +1,4 @@
|
||||||
from typing import Optional, Iterable, Iterator, Union, Any
|
from typing import Optional, Iterable, Iterator, Union, Any, overload
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
def get_string_id(key: Union[str, int]) -> int: ...
|
def get_string_id(key: Union[str, int]) -> int: ...
|
||||||
|
@ -7,7 +7,10 @@ class StringStore:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, strings: Optional[Iterable[str]] = ..., freeze: bool = ...
|
self, strings: Optional[Iterable[str]] = ..., freeze: bool = ...
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def __getitem__(self, string_or_id: Union[bytes, str, int]) -> Union[str, int]: ...
|
@overload
|
||||||
|
def __getitem__(self, string_or_id: Union[bytes, str]) -> int: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, string_or_id: int) -> str: ...
|
||||||
def as_int(self, key: Union[bytes, str, int]) -> int: ...
|
def as_int(self, key: Union[bytes, str, int]) -> int: ...
|
||||||
def as_string(self, key: Union[bytes, str, int]) -> str: ...
|
def as_string(self, key: Union[bytes, str, int]) -> str: ...
|
||||||
def add(self, string: str) -> int: ...
|
def add(self, string: str) -> int: ...
|
||||||
|
|
Loading…
Reference in New Issue
Block a user