Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit89c801b

Browse files
[3.14]gh-133925: Make typing._UnionGenericAlias hashable (GH-133929) (#133936)
gh-133925: Make typing._UnionGenericAlias hashable (GH-133929)(cherry picked from commit8d478c7)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parentecc12bf commit89c801b

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

‎Lib/test/test_typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10731,6 +10731,9 @@ def test_eq(self):
1073110731
withself.assertWarns(DeprecationWarning):
1073210732
self.assertNotEqual(int,typing._UnionGenericAlias)
1073310733

10734+
deftest_hashable(self):
10735+
self.assertEqual(hash(typing._UnionGenericAlias),hash(Union))
10736+
1073410737

1073510738
defload_tests(loader,tests,pattern):
1073610739
importdoctest

‎Lib/typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,9 @@ def __eq__(self, other):
16491649
returnTrue
16501650
returnNotImplemented
16511651

1652+
def__hash__(self):
1653+
returnhash(Union)
1654+
16521655

16531656
class_UnionGenericAlias(metaclass=_UnionGenericAliasMeta):
16541657
"""Compatibility hack.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make the private class ``typing._UnionGenericAlias`` hashable.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp