MCPcopy Create free account
hub / github.com/dagger/dagger / _make_parameter

Method _make_parameter

sdk/python/src/dagger/mod/_resolver.py:163–195  ·  view source on GitHub ↗

Create a parameter object from an inspect.Parameter.

(self, param: inspect.Parameter)

Source from the content-addressed store, hash-verified

161 return mapping
162
163 def _make_parameter(self, param: inspect.Parameter) -> Parameter:
164 """Create a parameter object from an inspect.Parameter."""
165 try:
166 # Use type_hints instead of param.annotation to get
167 # resolved forward references and stripped Annotated.
168 annotation = self.type_hints[param.name]
169 except KeyError:
170 logger.warning("Missing type annotation for parameter '%s'", param.name)
171 annotation = Any
172
173 if isinstance(annotation, dataclasses.InitVar):
174 annotation: Any = annotation.type
175
176 # Get the annotated type (with Annotated preserved) for metadata extraction.
177 # This is needed when `from __future__ import annotations` is used,
178 # which causes param.annotation to be a string instead of a type.
179 try:
180 annotated_type = self.type_hints_with_extras[param.name]
181 except KeyError:
182 annotated_type = param.annotation
183
184 return Parameter(
185 name=get_alt_name(annotated_type) or normalize_name(param.name),
186 signature=param,
187 resolved_type=annotation,
188 is_nullable=is_nullable(TypeHint(annotation)),
189 doc=get_doc(annotated_type),
190 ignore=get_ignore(annotated_type),
191 default_path=get_default_path(annotated_type),
192 default_address=get_default_address(annotated_type),
193 deprecated=get_deprecated(annotated_type),
194 conv=self.converter,
195 )
196
197 @property
198 def return_type(self) -> Any:

Callers 1

parametersMethod · 0.95

Calls 9

ParameterClass · 0.90
get_alt_nameFunction · 0.90
normalize_nameFunction · 0.90
is_nullableFunction · 0.90
get_docFunction · 0.90
get_ignoreFunction · 0.90
get_default_pathFunction · 0.90
get_default_addressFunction · 0.90
get_deprecatedFunction · 0.90

Tested by

no test coverage detected