We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The built-in sync filter has a overload type hint to infer that the return type of filter(None, iter) is not None, can you add similar type overload?
filter
e.g.
maybe_none: Iterable[int | None] = [1, 2, None] not_none: Iterable[int] = filter(None, maybe_none) # it knows not_none is type Iterable[int] without cast
The text was updated successfully, but these errors were encountered:
Indeed the typeshed annotations for filter handle more cases. Good catch, thanks for the report.
class filter(Iterator[_T]): @overload def __new__(cls, __function: None, __iterable: Iterable[_T | None]) -> Self: ... @overload def __new__(cls, __function: Callable[[_S], TypeGuard[_T]], __iterable: Iterable[_S]) -> Self: ... @overload def __new__(cls, __function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Self: ... def __iter__(self) -> Self: ... def __next__(self) -> _T: ...
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
The built-in sync
filter
has a overload type hint to infer that the return type of filter(None, iter) is not None, can you add similar type overload?e.g.
The text was updated successfully, but these errors were encountered: