Improve None as predicate for Python 2 ifilter#8191
Merged
srittau merged 2 commits intopython:masterfrom Jun 28, 2022
david-askari:master
Merged
Improve None as predicate for Python 2 ifilter#8191srittau merged 2 commits intopython:masterfrom david-askari:master
srittau merged 2 commits intopython:masterfrom
david-askari:master
Conversation
This comment has been minimized.
This comment has been minimized.
Member
|
Thanks! Unfortunately, I know very little about Python 2, so I won't be able to review this (though one of the other maintainers might). Please be aware, however, that we're planning on deleting all of our remaining Python 2 stubs as soon as mypy drops support for Python 2, which could be very soon (#7367, python/mypy#12237) |
srittau
requested changes
Jun 28, 2022
stdlib/@python2/itertools.pyi
Outdated
| @overload | ||
| def ifilter(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... | ||
| @overload | ||
| def ifilterfalse(predicate: None, iterable: Iterable[_T | None]) -> Iterator[_T]: ... |
Collaborator
There was a problem hiding this comment.
I don't think this is correct. Using Python 3:
>>> from itertools import filterfalse
>>> list(filterfalse(None, [0,1,2,3,None]))
[0, None]I don't think an overload for ifilterfalse makes sense here.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Contributor
Author
|
@AlexWaygood thanks for the heads-up, I was expecting something like this 😬 @srittau I removed the |
srittau
approved these changes
Jun 28, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Properly support
ifilter(None, ...)on Python 2. Used Python 3filteras a basis.I stumbled over this as
six.moves.filterreturnsitertools.ifilter.