-
Notifications
You must be signed in to change notification settings - Fork 280
Labels
typecheckingusabilityUsability & readiness issues identified with running Pyrefly on top OSS projectsUsability & readiness issues identified with running Pyrefly on top OSS projects
Description
Describe the Bug
Minimal repro:
"""
When a TypeVar has a bound (e.g., bound=type), pyrefly resolves attribute
access on the TypeVar to `object` instead of the bound type. This causes
false positives when accessing attributes that exist on the bound type
but not on `object`.
"""
from typing import TypeVar
# TypeVar bound to `type` -- accessing `__name__`
# `type` has a `__name__` attribute, so cls.__name__ should be valid
# when T is bound to `type`. Pyrefly resolves T as `object` instead.
T = TypeVar("T", bound=type)
def get_class_name(cls: T) -> str:
return cls.__name__ # FP: Object of class `object` has no attribute `__name__` No other type checker has this behavior.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
typecheckingusabilityUsability & readiness issues identified with running Pyrefly on top OSS projectsUsability & readiness issues identified with running Pyrefly on top OSS projects