(
signature: inspect.Signature, default_kwargs, manually_passed_value: Any = DEFAULT_NONE
)
| 271 | |
| 272 | |
| 273 | def build_kwargs( |
| 274 | signature: inspect.Signature, default_kwargs, manually_passed_value: Any = DEFAULT_NONE |
| 275 | ): |
| 276 | kws = {} |
| 277 | for name, param in signature.parameters.items(): |
| 278 | # For required params we need to pass something |
| 279 | if param.default is inspect.Parameter.empty: |
| 280 | # Some special casing |
| 281 | if name == "permissions": |
| 282 | kws[name] = ChatPermissions() |
| 283 | elif name in ["prices", "commands", "errors"]: |
| 284 | kws[name] = [] |
| 285 | elif name == "media": |
| 286 | if "star_count" in signature.parameters: |
| 287 | media = InputPaidMediaPhoto("media") |
| 288 | else: |
| 289 | media = InputMediaPhoto("media", parse_mode=manually_passed_value) |
| 290 | |
| 291 | param_annotation = str(param.annotation).lower() |
| 292 | if "sequence" in param_annotation or "list" in param_annotation: |
| 293 | kws[name] = [media] |
| 294 | else: |
| 295 | kws[name] = media |
| 296 | elif name == "results": |
| 297 | itmc = InputTextMessageContent( |
| 298 | "text", |
| 299 | parse_mode=manually_passed_value, |
| 300 | link_preview_options=LinkPreviewOptions( |
| 301 | is_disabled=manually_passed_value, url=manually_passed_value |
| 302 | ), |
| 303 | ) |
| 304 | kws[name] = [ |
| 305 | InlineQueryResultArticle("id", "title", input_message_content=itmc), |
| 306 | InlineQueryResultCachedPhoto( |
| 307 | "id", |
| 308 | "photo_file_id", |
| 309 | parse_mode=manually_passed_value, |
| 310 | input_message_content=itmc, |
| 311 | ), |
| 312 | ] |
| 313 | elif name == "ok": |
| 314 | kws["ok"] = False |
| 315 | kws["error_message"] = "error" |
| 316 | elif name == "options": |
| 317 | kws[name] = ["option1", "option2"] |
| 318 | elif name in ("sticker", "old_sticker"): |
| 319 | kws[name] = Sticker( |
| 320 | file_id="file_id", |
| 321 | file_unique_id="file_unique_id", |
| 322 | width=1, |
| 323 | height=1, |
| 324 | is_animated=False, |
| 325 | is_video=False, |
| 326 | type="regular", |
| 327 | ) |
| 328 | else: |
| 329 | kws[name] = True |
| 330 |
no test coverage detected
searching dependent graphs…