Description of a function argument in IR. Argument kind is one of ARG_* constants defined in mypy.nodes.
| 34 | |
| 35 | |
| 36 | class RuntimeArg: |
| 37 | """Description of a function argument in IR. |
| 38 | |
| 39 | Argument kind is one of ARG_* constants defined in mypy.nodes. |
| 40 | """ |
| 41 | |
| 42 | def __init__( |
| 43 | self, name: str, typ: RType, kind: ArgKind = ARG_POS, pos_only: bool = False |
| 44 | ) -> None: |
| 45 | self.name = name |
| 46 | self.type = typ |
| 47 | self.kind = kind |
| 48 | self.pos_only = pos_only |
| 49 | |
| 50 | @property |
| 51 | def optional(self) -> bool: |
| 52 | return self.kind.is_optional() |
| 53 | |
| 54 | def __repr__(self) -> str: |
| 55 | return "RuntimeArg(name={}, type={}, optional={!r}, pos_only={!r})".format( |
| 56 | self.name, self.type, self.optional, self.pos_only |
| 57 | ) |
| 58 | |
| 59 | def serialize(self) -> JsonDict: |
| 60 | return { |
| 61 | "name": self.name, |
| 62 | "type": self.type.serialize(), |
| 63 | "kind": int(self.kind.value), |
| 64 | "pos_only": self.pos_only, |
| 65 | } |
| 66 | |
| 67 | @classmethod |
| 68 | def deserialize(cls, data: JsonDict, ctx: DeserMaps) -> RuntimeArg: |
| 69 | return RuntimeArg( |
| 70 | data["name"], |
| 71 | deserialize_type(data["type"], ctx), |
| 72 | ArgKind(data["kind"]), |
| 73 | data["pos_only"], |
| 74 | ) |
| 75 | |
| 76 | |
| 77 | class FuncSignature: |
no outgoing calls
searching dependent graphs…