summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authoraha79 <34090357+aha79@users.noreply.github.com>2022-02-17 03:28:18 (GMT)
committerGitHub <noreply@github.com>2022-02-17 03:28:18 (GMT)
commit6e7b813195f9bd6a2a15c1f00ef2c0180f6c751a (patch)
treeee86170817ab4a7f892d38001ee95fed9f300692 /Lib/typing.py
parentde6043e596492201cc1a1eb28038970bb69f3107 (diff)
downloadcpython-6e7b813195f9bd6a2a15c1f00ef2c0180f6c751a.zip
cpython-6e7b813195f9bd6a2a15c1f00ef2c0180f6c751a.tar.gz
cpython-6e7b813195f9bd6a2a15c1f00ef2c0180f6c751a.tar.bz2
bpo-46333: Honor `module` parameter in ForwardRef (GH-30536)
The `module` parameter carries semantic information about the forward ref. Forward refs are different if they refer to different module even if they have the same name. This affects the `__eq__`, `__repr__` and `__hash__` methods. Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 3233827..8f923fa 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -767,10 +767,11 @@ class ForwardRef(_Final, _root=True):
if self.__forward_evaluated__ and other.__forward_evaluated__:
return (self.__forward_arg__ == other.__forward_arg__ and
self.__forward_value__ == other.__forward_value__)
- return self.__forward_arg__ == other.__forward_arg__
+ return (self.__forward_arg__ == other.__forward_arg__ and
+ self.__forward_module__ == other.__forward_module__)
def __hash__(self):
- return hash(self.__forward_arg__)
+ return hash((self.__forward_arg__, self.__forward_module__))
def __or__(self, other):
return Union[self, other]