MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / generate_code

Method generate_code

py/generate.py:489–508  ·  view source on GitHub ↗

Generate the code for a parameter in a function call.

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

ref_to_pythonFunction · 0.85
get_annotationMethod · 0.45

Tested by

no test coverage detected