Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Description
Feature or enhancement
Currently,annotationlib.ForwardRef has a__hash__ and__eq__ method, which look at a few attributes:
Line 1096 in8b4a0d6
| def__eq__(self,other): |
__forward_module__). This gets worse on 3.14, where ForwardRef has gained a few more fields (Line 232 ina472244
| def__eq__(self,other): |
I think it's better to remove the__eq__ and__hash__ methods fromForwardRef 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 inagronholm/typeguard#492 where the current implementation of equality caused some grief. cc people involved with some runtime type checking tools:@agronholm@Viicos@leycec.