27
27
List ,
28
28
Tuple ,
29
29
TypeVar ,
30
- Union ,
31
30
cast ,
32
31
)
33
32
53
52
while the second element of the tuple is the option value itself
54
53
"""
55
54
AllCommandOptions = Dict ["str" , SingleCommandOptions ] # cmd name => its options
56
- Target = TypeVar ("Target" , bound = Union [ "Distribution" , "DistributionMetadata" ] )
55
+ Target = TypeVar ("Target" , "Distribution" , "DistributionMetadata" )
57
56
58
57
59
58
def read_configuration (
@@ -96,7 +95,7 @@ def _apply(
96
95
filepath : StrPath ,
97
96
other_files : Iterable [StrPath ] = (),
98
97
ignore_option_errors : bool = False ,
99
- ) -> tuple [ConfigHandler , ... ]:
98
+ ) -> tuple [ConfigMetadataHandler , ConfigOptionsHandler ]:
100
99
"""Read configuration from ``filepath`` and applies to the ``dist`` object."""
101
100
from setuptools .dist import _Distribution
102
101
@@ -122,7 +121,7 @@ def _apply(
122
121
return handlers
123
122
124
123
125
- def _get_option (target_obj : Target , key : str ):
124
+ def _get_option (target_obj : Distribution | DistributionMetadata , key : str ):
126
125
"""
127
126
Given a target object and option key, get that option from
128
127
the target object, either through a get_{key} method or
@@ -134,10 +133,14 @@ def _get_option(target_obj: Target, key: str):
134
133
return getter ()
135
134
136
135
137
- def configuration_to_dict (handlers : tuple [ConfigHandler , ...]) -> dict :
136
+ def configuration_to_dict (
137
+ handlers : Iterable [
138
+ ConfigHandler [Distribution ] | ConfigHandler [DistributionMetadata ]
139
+ ],
140
+ ) -> dict :
138
141
"""Returns configuration data gathered by given handlers as a dict.
139
142
140
- :param list [ConfigHandler] handlers: Handlers list,
143
+ :param Iterable [ConfigHandler] handlers: Handlers list,
141
144
usually from parse_configuration()
142
145
143
146
:rtype: dict
@@ -254,7 +257,7 @@ def __init__(
254
257
ensure_discovered : expand .EnsurePackagesDiscovered ,
255
258
):
256
259
self .ignore_option_errors = ignore_option_errors
257
- self .target_obj = target_obj
260
+ self .target_obj : Target = target_obj
258
261
self .sections = dict (self ._section_options (options ))
259
262
self .set_options : list [str ] = []
260
263
self .ensure_discovered = ensure_discovered
0 commit comments