| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
The homeassistant errors are caused by exposing an existing bug in walrus. On master this test [case testNarrowOnSelfInGeneric]
# flags: --strict-optional
from typing import Generic, TypeVar, Optional
T = TypeVar("T", int, str)
class C(Generic[T]):
x: Optional[T]
def meth(self) -> Optional[T]:
if (y := self.x) is not None:
return reveal_type(y)
return None
reveals type Any. But with this PR it becomes optional, so it is still wrong. I will first try to figure out what is going on. |
Sorry, something went wrong.
|
OK, I have a fix for the walrus bug, since it is an obvious bug, I am going to just add it to this PR. |
Sorry, something went wrong.
|
Looking again at mypy_primer it looks like this PR accidental fixes another bug related to type vars with values, this type for self types. I am going to include a regression for that one as well. |
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: artigraph (https://github.com/artigraph/artigraph)
+ tests/arti/producers/test_producer.py:679: error: Unused "type: ignore" comment
+ tests/arti/producers/test_producer.py:680: error: Unused "type: ignore" comment
Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/dependencies/reloaders.py:566: error: Cannot determine type of "real_path" [has-type]
- tanjun/dependencies/reloaders.py:567: error: Cannot determine type of "time" [has-type]
- tanjun/dependencies/reloaders.py:578: error: Cannot determine type of "info" [has-type]
- tanjun/dependencies/reloaders.py:579: error: Cannot determine type of "time" [has-type]
- tanjun/dependencies/reloaders.py:599: error: Cannot determine type of "path" [has-type]
- tanjun/dependencies/reloaders.py:600: error: Cannot determine type of "tracked_value" [has-type]
- tanjun/dependencies/reloaders.py:609: error: Cannot determine type of "path" [has-type]
- tanjun/dependencies/reloaders.py:609: error: Cannot determine type of "path_info" [has-type]
- tanjun/commands/menu.py:580: error: Incompatible return value type (got "MenuCommand[_MenuCommandCallbackSigT, _MenuTypeT]", expected "Self") [return-value]
mypy (https://github.com/python/mypy)
+ mypy/stubtest.py:357: error: Unused "type: ignore[valid-type]" comment
cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/templater.py:44: error: Unused "type: ignore" comment
|
Sorry, something went wrong.
There was a problem hiding this comment.
Nice -- fixing three bugs for the price of one!
I can't see why setting the argument types in the semantic analyzer would be a problem.
Left a comment that is mostly unrelated to this PR, feel free to ignore it if you are not sure.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #5865
Looks quite easy and safe, unless I am missing something. Most changes in the diff are just moving stuff around.
Previously we only applied argument types before type checking, but it looks like we can totally do this in semantic analyzer. I also enable variable annotated as type (or equivalently Type[Any]), this use case was mentioned in the comments.
This PR also accidentally fixes two additional bugs, one related to type variables with values vs walrus operator, another one for type variables with values vs self types. I include test cases for those as well.