Open Daraan opened 1 month ago
I haven't thought too hard about examples that might break things, but I'm concerned about using ==
to check whether the two annotations are the same; I don't know if we can rely on equality of annotation objects working reliably for this.
I haven't thought too hard about examples that might break things, but I'm concerned about using
==
to check whether the two annotations are the same; I don't know if we can rely on equality of annotation objects working reliably for this.
Do you refer to assertEqual
here, or also for the ones in typing_extensions.py
?
hash
checks, which are fine. str
and repr
are fine, too.assertIs
fails in some(to-many) cases depending on the python version.
In essence the problem can be seen here:import typing
from typing import List
a = List["str"]
print(typing._eval_type(a, None, None) is typing._eval_type(a, None, None)) # False
typing._eval_type
uses _GenericAlias.copy_with
or in some cases creates a new GenericAlias
which do not make use of the caches.
Fixes #310
This PR reverts injection of
Union[..., NoneType]
bytyping.get_type_hints
in Python <3.11 if a function uses aNone
default value.