-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Currently, annotationlib.ForwardRef has a __hash__ and __eq__ method, which look at a few attributes:
Line 1096 in 8b4a0d6
| def __eq__(self, other): |
__forward_module__). This gets worse on 3.14, where ForwardRef has gained a few more fields (Line 232 in a472244
| def __eq__(self, other): |
I think it's better to remove the __eq__ and __hash__ methods from ForwardRef objects, and make it so two ForwardRefs are equal only if they're identical. I don't see a good use case for comparing two ForwardRefs for equality; if you want to know that they refer to the same thing, you should evaluate them and compare the type object that comes out.
This came up in agronholm/typeguard#492 where the current implementation of equality caused some grief. cc people involved with some runtime type checking tools: @agronholm @Viicos @leycec.
Linked PRs
carljm
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancementA feature request or enhancement