Skip to content

Commit 2aafbb4

Browse files
authored
Slide Any check to be after type normalization (#35014)
1 parent dd0383e commit 2aafbb4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sdks/python/apache_beam/typehints/typehints.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,6 @@ def is_consistent_with(sub, base):
14971497
if sub == base:
14981498
# Common special case.
14991499
return True
1500-
if isinstance(sub, AnyTypeConstraint) or isinstance(base, AnyTypeConstraint):
1501-
return True
15021500
# Per PEP484, ints are considered floats and complexes and
15031501
# floats are considered complexes.
15041502
if sub is int and base in (float, complex):
@@ -1507,7 +1505,9 @@ def is_consistent_with(sub, base):
15071505
return True
15081506
sub = normalize(sub, none_as_type=True)
15091507
base = normalize(base, none_as_type=True)
1510-
if isinstance(sub, UnionConstraint):
1508+
if isinstance(sub, AnyTypeConstraint) or isinstance(base, AnyTypeConstraint):
1509+
return True
1510+
elif isinstance(sub, UnionConstraint):
15111511
return all(is_consistent_with(c, base) for c in sub.union_types)
15121512
elif isinstance(base, TypeConstraint):
15131513
return base._consistent_with_check_(sub)

0 commit comments

Comments
 (0)