MCPcopy Create free account
hub / github.com/apache/fory / Field

Class Field

compiler/fory_compiler/ir/ast.py:127–159  ·  view source on GitHub ↗

A field in a message.

Source from the content-addressed store, hash-verified

125
126@dataclass
127class Field:
128 """A field in a message."""
129
130 name: str
131 field_type: FieldType
132 number: int
133 tag_id: Optional[int] = None
134 optional: bool = False
135 ref: bool = False
136 ref_options: dict = field(default_factory=dict)
137 element_optional: bool = False
138 element_ref: bool = False
139 element_ref_options: dict = field(default_factory=dict)
140 options: dict = field(default_factory=dict)
141 line: int = 0
142 column: int = 0
143 location: Optional[SourceLocation] = None
144
145 def __repr__(self) -> str:
146 modifiers = []
147 if self.optional:
148 modifiers.append("optional")
149 if self.ref:
150 modifiers.append("ref")
151 if self.element_optional:
152 modifiers.append("element_optional")
153 if self.element_ref:
154 modifiers.append("element_ref")
155 mod_str = " ".join(modifiers) + " " if modifiers else ""
156 opts_str = f" [{self.options}]" if self.options else ""
157 return (
158 f"Field({mod_str}{self.field_type} {self.name} = {self.number}{opts_str})"
159 )
160
161
162@dataclass

Callers 7

_translate_fieldMethod · 0.90
_translate_oneof_caseMethod · 0.90
parse_union_fieldMethod · 0.90
parse_fieldMethod · 0.90
_translate_fieldsMethod · 0.90
_translate_unionMethod · 0.90

Calls 1

fieldFunction · 0.50

Tested by

no test coverage detected