Describe the Bug
import typing as tp
def integer_factory() -> int:
return 1
class A:
_factory: tp.ClassVar[tp.Callable[[], int]] = integer_factory
@property
def factory(self) -> tp.Callable[[], int]:
return self._factory # Pyrefly [bad-return]: Returned type `() -> int` is not assignable to declared return type `() -> int`
The title writes itself. A class variable typed as ClassVar obscures pyrefly correctly detect the type when returned with @property descriptor. When ClassVar denotion was removed, the error messages was gone. Even so, ClassVar should make no effects in this scenario and this possibly is a bug.
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABA6cROgOZOpwvEAddEKGYYYJhwYxOMOgH0wqAMYN6pABQBKJgFoAfJPQNEQpuaZ0YDAK510TAIwjh6ZVF58AgqYcXFKmp0pIj8hADCHnBwAGqodADaDMQRqFAe2LAJCQC6ADRGDDk5TAC8hTJyAarqLhZMAALEdLjEcqxmFmISSjXBGnAwUGA6BmHhaRlZuQVSOb719Va29kyDw4TVQaRCIHkgZFZgUKSEalRQFADETAAKpEcnaxg4BEzKuOiQnHaoDBCfQhCG4AZRgMCYAAsGMk4IgAPTww7iE6EeiceEwdDwzC4ZRweEfL4QH50P4A7FMMD0HgAN1Q0FQmQhRO%2Bv3%2BnyYrQ56DgQPQZAYkM%2BulpcjgFLKTAEIAAzIRHAAmGVCBJyFp0OA5IQ2dDUWiMGCYXSYCBWVQQMVSgDkJPQ9Bg1qE9oYuisAEcbGajboANYwUi6FTKeB8crWgDu8XQTvQIAAvvtApaYAAxaAwChoLB4IhkBNAA
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
The title writes itself. A class variable typed as
ClassVarobscures pyrefly correctly detect the type when returned with@propertydescriptor. WhenClassVardenotion was removed, the error messages was gone. Even so,ClassVarshould make no effects in this scenario and this possibly is a bug.Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABA6cROgOZOpwvEAddEKGYYYJhwYxOMOgH0wqAMYN6pABQBKJgFoAfJPQNEQpuaZ0YDAK510TAIwjh6ZVF58AgqYcXFKmp0pIj8hADCHnBwAGqodADaDMQRqFAe2LAJCQC6ADRGDDk5TAC8hTJyAarqLhZMAALEdLjEcqxmFmISSjXBGnAwUGA6BmHhaRlZuQVSOb719Va29kyDw4TVQaRCIHkgZFZgUKSEalRQFADETAAKpEcnaxg4BEzKuOiQnHaoDBCfQhCG4AZRgMCYAAsGMk4IgAPTww7iE6EeiceEwdDwzC4ZRweEfL4QH50P4A7FMMD0HgAN1Q0FQmQhRO%2Bv3%2BnyYrQ56DgQPQZAYkM%2BulpcjgFLKTAEIAAzIRHAAmGVCBJyFp0OA5IQ2dDUWiMGCYXSYCBWVQQMVSgDkJPQ9Bg1qE9oYuisAEcbGajboANYwUi6FTKeB8crWgDu8XQTvQIAAvvtApaYAAxaAwChoLB4IhkBNAA
(Only applicable for extension issues) IDE Information
No response