| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
... to match the behavior of `Set` and `AbstractSet`
... to match the behavior of `Set` and `AbstractSet`
There was a problem hiding this comment.
Sorry for the late reply and thank you for the PR. Remarks below.
Sorry, something went wrong.
|
In reference to #3184: Let's make this consistent for the annotation of set for now. When we decide to make set() more strict, we can change it later. |
Sorry, something went wrong.
Co-Authored-By: Sebastian Rittau <srittau@rittau.biz>
|
I just applied the suggestions you made. But just wait a minute: I used Iterable[T] probably because lazy, but I would have used Iterable[Any] (or maybe just Iterable) in my own code. Is there a difference? I never used Something[object], I sometimes use an unbound T, mypy doesn't complain here, and I thought it will substitute something like Any in such cases. But here in this codebase, set always references AbstractSet[object] in such cases, but Iterable[Any] if Iterable is used. 😕 |
Sorry, something went wrong.
|
I think an unbound type var is basically equivalent to Any, but less obvious. The difference between object and Any for argument types is largely academic: object implies that literally anything can used here, while Any says that the expected type can't be expressed adequately with the current type system. For example, str() could be annotated as str(o: object) -> str, since anything can be converted to a string. (It's a class in reality, though.) |
Sorry, something went wrong.
|
Thanks for explaining. |
Sorry, something went wrong.
This was discussed in #3181 and the correct explanation was given that object ought to be preferred here. In practice this caused an obscure issue with mypy when using this operations on the results of six.viewkeys(), since it decided that it wanted a mapping *from* object as a result of inference contexts. Grumble.
…3294) This was discussed in #3181 and the correct explanation was given that object ought to be preferred here. In practice this caused an obscure issue with mypy when using this operations on the results of six.viewkeys(), since it decided that it wanted a mapping *from* object as a result of inference contexts. Grumble.
| Back | FazBrowse Home | New Git URL |
Related python/mypy#7236