-
Notifications
You must be signed in to change notification settings - Fork 264
Closed
Labels
Description
Describe the Bug
This code:
from typing import TypeVar, Type, Any
BaseT = TypeVar("BaseT", bound="Base")
class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None:
pass
@classmethod
def bar(cls: Type[BaseT], flag: bool) -> BaseT:
if flag:
raise ValueError(f"throwing error for {cls.__name__} because {flag=}")
else:
return cls("nah...")
class Foo(Base):
def __init__(self, x: str):
self.x = x
def main() -> None:
print(Foo.bar(False))
print(Foo.bar(True))
if __name__ == "__main__":
main()Causes these two errors related to object.__getattribute__:
$ ~/sand2-env/bin/pyrefly check --python-interpreter ~/sand2-env/bin/python x.py
ERROR Argument `Literal['__name__']` is not assignable to parameter `self` with type `BaseT` in function `object.__getattribute__` [bad-argument-type]
--> ./x.py:12:52
|
12 | raise ValueError(f"throwing error for {cls.__name__} because {flag=}")
| ^^^^^^^^^^^^
|
ERROR Missing positional argument `name` in function `object.__getattribute__` [bad-argument-count]
--> ./x.py:12:52
|
12 | raise ValueError(f"throwing error for {cls.__name__} because {flag=}")
| ^^^^^^^^^^^^
|
INFO 2 errorsPyrefly version:
$ ~/sand2-env/bin/pyrefly --version
pyrefly 0.29.2
This code passes type checking in 0.28.0, 0.28.1, 0.29.0, 0.29.1. It only started failing after installing 0.29.2 this morning.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response