Conversation
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
| source: SoupStrainer | ||
| def __init__(self, source: SoupStrainer, result: Iterable[_PageElementT] = ...) -> None: ... | ||
| @overload | ||
| def __init__(self, source: SoupStrainer) -> None: ... |
There was a problem hiding this comment.
Sorry, I haven't following this so far, but shouldn't this annotate self to bind _PageElementT?
There was a problem hiding this comment.
This is basically the same approach that we've had for a while for some generic collections in builtins and collections, e.g. this has been the first overload for builtins.list for (at least) two years now:
Lines 958 to 960 in 43f923b
If the constructor-method overload picked is one where there are no TypeVars present at all, despite the class being generic, the type checker will require the user to provide an explicit type annotation, the same as happens if you try to initialise an empty list 🙂
https://mypy-play.net/?mypy=latest&python=3.10&gist=dcbf1006ff7606d02d5670171bc6cae1
Refs #7928