From 02c1bc03c8bdffd89309748ce63593667295e93b Mon Sep 17 00:00:00 2001 From: kadarakos Date: Wed, 3 May 2023 11:44:01 +0000 Subject: [PATCH] mypy fix for integer type infinity --- spacy/pipeline/span_finder.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spacy/pipeline/span_finder.py b/spacy/pipeline/span_finder.py index 988dd4ce9..1a32fe12e 100644 --- a/spacy/pipeline/span_finder.py +++ b/spacy/pipeline/span_finder.py @@ -148,6 +148,11 @@ def span_finder_score( return scores +class _MaxInt(int): + def __le__(self, other): + return False + + class SpanFinder(TrainablePipe): """Pipeline that learns span boundaries""" @@ -184,15 +189,16 @@ class SpanFinder(TrainablePipe): self.vocab = nlp.vocab self.threshold = threshold if max_length is None: - max_length = float("inf") + max_length = _MaxInt() if min_length is None: min_length = 1 + + self.min_length = min_length + self.max_length = max_length if max_length < 1 or min_length < 1: raise ValueError( Errors.E1052.format(min_length=min_length, max_length=max_length) ) - self.max_length = max_length - self.min_length = min_length self.predicted_key = predicted_key self.training_key = training_key self.model = model