Generate the code for a parameter in a function call.
(self)
| 486 | """A parameter to a CDP command.""" |
| 487 | |
| 488 | def generate_code(self): |
| 489 | """Generate the code for a parameter in a function call.""" |
| 490 | if self.items: |
| 491 | if self.items.ref: |
| 492 | nested_type = ref_to_python(self.items.ref) |
| 493 | py_type = f"typing.List[{nested_type}]" |
| 494 | else: |
| 495 | nested_type = CdpPrimitiveType.get_annotation(self.items.type) |
| 496 | py_type = f"typing.List[{nested_type}]" |
| 497 | else: |
| 498 | if self.ref: |
| 499 | py_type = f"{ref_to_python(self.ref)}" |
| 500 | else: |
| 501 | py_type = CdpPrimitiveType.get_annotation(cast(str, self.type)) |
| 502 | if self.optional: |
| 503 | py_type = f"typing.Optional[{py_type}]" |
| 504 | code = f"{self.py_name}: {py_type}" |
| 505 | if self.optional: |
| 506 | code += " = None" |
| 507 | return code |
| 508 | |
| 509 | def generate_decl(self): |
| 510 | """Generate the declaration for this parameter.""" |
nothing calls this directly
no test coverage detected