-
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
When import collections.abc appears alongside import collections, pyrefly loses its special handling of collections.namedtuple() and resolves the constructor to tuple.__new__. This causes unexpected-keyword errors when constructing namedtuple instances with keyword arguments.
Minimal repro:
import collections
import collections.abc # This import triggers the bug
GetWorkResponse = collections.namedtuple(
"GetWorkResponse",
(
"task_id",
),
)
response = GetWorkResponse(
task_id="abc123", # pyrefly: unexpected-keyword in tuple.__new__
)
print(response.task_id) # pyrefly: Object of class `tuple` has no attribute `task_id` One theory: the submodule import collections.abc may have shadowed or interfered with pyrefly's resolution of the collections module, causing collections.namedtuple to no longer be recognized as the namedtuple factory.
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