mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-06 06:03:11 +03:00
Fix mypy errors.
This commit is contained in:
parent
51c485da09
commit
581c2fd40f
|
@ -1,5 +1,5 @@
|
|||
from pathlib import Path
|
||||
from typing import Optional, Callable, Iterable, List, Tuple, Generator, Iterator
|
||||
from typing import Optional, Callable, Iterable, List, Tuple, Iterator
|
||||
from thinc.types import Floats2d
|
||||
from thinc.api import chain, list2ragged, reduce_mean, residual
|
||||
from thinc.api import Model, Maxout, Linear, tuplify, Ragged
|
||||
|
@ -136,7 +136,7 @@ def create_candidates() -> Callable[[KnowledgeBase, Span], Iterable[Candidate]]:
|
|||
|
||||
@registry.misc("spacy.CandidateAllGenerator.v1")
|
||||
def create_candidates_all() -> Callable[
|
||||
[KnowledgeBase, Generator[Iterable[Span], None, None]],
|
||||
[KnowledgeBase, Iterator[Doc]],
|
||||
Iterator[Iterable[Iterable[Candidate]]],
|
||||
]:
|
||||
return get_candidates_all
|
||||
|
|
|
@ -477,7 +477,9 @@ class EntityLinker(TrainablePipe):
|
|||
RETURN (doc): Doc instance with only valid entities (i.e. those to retrieve candidates for).
|
||||
"""
|
||||
_doc = doc.copy()
|
||||
_doc.ents = [doc.ents[i] for i in valid_ent_idx]
|
||||
# mypy complains about mismatching types here (Tuple[str] vs. Tuple[str, ...]), which isn't correct and
|
||||
# probably an artifact of a misreading of the Cython code.
|
||||
_doc.ents = tuple([doc.ents[i] for i in valid_ent_idx]) # type: ignore
|
||||
return _doc
|
||||
|
||||
all_ent_cands = self.get_candidates_all(
|
||||
|
|
Loading…
Reference in New Issue
Block a user