Full inlined type hints for thefuzz.process #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Provides full type hinting for the process module functions.
I have followed the typing best practices where possible, without having to add a dependency on
typing_extensions
. Thismeans:
_Processor
, etc.) withTypeAlias
. This isn't necessary anyway as none of the aliases use forward references. The annotations usetyping.Union[]
andtyping.Optional[]
instead of the newer|
syntax for the same reason.contains_dupes
only needs to support iteration and length. Return types are the most specific type.Note that
dedupe()
explicitly states it can return a list of strings or the original container type.The types have been verified against the rapidfuzz annotations and sourcecode, with the exception of the
query
and choice types, which have been constrained here tostr
. It is possible to extend this to support more types if necessary, but then we'd need to add another typevar and use this in the_Processor
and_Scorer
type aliases too, which complicates matters. Since all the default processors only accept strings I thought this a good compromise.