type-analyzer 0.1.0__tar.gz → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: type-analyzer
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Functions for introspecting Python type hints.
5
5
  Project-URL: Repository, https://github.com/100nm/type-analyzer
6
6
  Author: remimd
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "type-analyzer"
3
- version = "0.1.0"
3
+ version = "0.1.2"
4
4
  description = "Functions for introspecting Python type hints."
5
5
  license = "MIT"
6
6
  license-files = ["LICENSE"]
@@ -21,12 +21,15 @@ class MatchingTypesConfig:
21
21
  with_type_alias_value: bool = field(default=False)
22
22
 
23
23
 
24
+ _empty_config = MatchingTypesConfig()
25
+
26
+
24
27
  def iter_matching_types(
25
28
  type_hint: Any,
26
29
  /,
27
30
  config: MatchingTypesConfig | None = None,
28
31
  ) -> Iterator[Any]:
29
- config = config or MatchingTypesConfig()
32
+ config = config or _empty_config
30
33
  type_hints = (type_hint,)
31
34
  return _iter_matching_types(type_hints, config)
32
35
 
@@ -76,7 +79,7 @@ def _iter_matching_types(
76
79
  continue
77
80
 
78
81
  if _is_type_var(type_hint):
79
- yield params[type_hint]
82
+ yield params.get(type_hint, type_hint)
80
83
  continue
81
84
 
82
85
  origin = get_origin(type_hint)
@@ -92,10 +95,11 @@ def _iter_matching_types(
92
95
  yield type_hint
93
96
 
94
97
  else:
95
- iter_args = (
96
- params[arg] if _is_type_var(arg) else arg for arg in get_args(type_hint)
98
+ args = tuple(
99
+ next(_iter_matching_types((arg,), _empty_config, params))
100
+ for arg in get_args(type_hint)
97
101
  )
98
- yield origin[*iter_args]
102
+ yield origin[*args]
99
103
 
100
104
  if config.with_origin:
101
105
  yield origin
File without changes
File without changes
File without changes