click-type-test 2.0.1__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {click_type_test-2.0.1 → click_type_test-2.0.2}/PKG-INFO +1 -1
- {click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.egg-info/PKG-INFO +1 -1
- {click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.py +36 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/pyproject.toml +1 -1
- {click_type_test-2.0.1 → click_type_test-2.0.2}/LICENSE.txt +0 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/README.md +0 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.egg-info/SOURCES.txt +0 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.egg-info/dependency_links.txt +0 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.egg-info/requires.txt +0 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.egg-info/top_level.txt +0 -0
- {click_type_test-2.0.1 → click_type_test-2.0.2}/setup.cfg +0 -0
|
@@ -552,4 +552,40 @@ def _type_or_literal_is_included(
|
|
|
552
552
|
if value in collected_literal_values:
|
|
553
553
|
return True
|
|
554
554
|
|
|
555
|
+
# if the value is a tuple of Literal-viable types, it may match a Literal tuple in
|
|
556
|
+
# a multiple use opt
|
|
557
|
+
if (
|
|
558
|
+
isinstance(value, tuple)
|
|
559
|
+
and any(t.get_origin(x) is tuple for x in possible_types)
|
|
560
|
+
and set(t.get_args(value_type)).issubset({int, str, bool})
|
|
561
|
+
):
|
|
562
|
+
for tuple_type in possible_types:
|
|
563
|
+
# we're only interested in types of the form tuple[T, ...]
|
|
564
|
+
if t.get_origin(tuple_type) is not tuple:
|
|
565
|
+
continue
|
|
566
|
+
typeargs = t.get_args(tuple_type)
|
|
567
|
+
if len(typeargs) != 2 or typeargs[1] is not Ellipsis:
|
|
568
|
+
continue
|
|
569
|
+
|
|
570
|
+
multi_use_type = typeargs[0]
|
|
571
|
+
|
|
572
|
+
# if it's a literal, check if all of the values are matched
|
|
573
|
+
if t.get_origin(multi_use_type) is t.Literal and all(
|
|
574
|
+
member in t.get_args(multi_use_type) for member in value
|
|
575
|
+
):
|
|
576
|
+
return True
|
|
577
|
+
|
|
578
|
+
# otherwise, not a literal, check if all of the types used are within the
|
|
579
|
+
# type (potential union)
|
|
580
|
+
member_types = {_type_of_value(member) for member in value}
|
|
581
|
+
if _is_union(multi_use_type):
|
|
582
|
+
union_members = set(t.get_args(multi_use_type))
|
|
583
|
+
if member_types.issubset(union_members):
|
|
584
|
+
return True
|
|
585
|
+
else:
|
|
586
|
+
if len(member_types) == 1 and _compare_types(
|
|
587
|
+
member_types.pop(), multi_use_type
|
|
588
|
+
):
|
|
589
|
+
return True
|
|
590
|
+
|
|
555
591
|
return False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{click_type_test-2.0.1 → click_type_test-2.0.2}/click_type_test.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|