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

Method generate_code

py/generate.py:488–507  ·  view source on GitHub ↗

Generate the code for a parameter in a function call.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 2

ref_to_pythonFunction · 0.85
get_annotationMethod · 0.45

Tested by

no test coverage detected