A field in a message.
| 125 | |
| 126 | @dataclass |
| 127 | class 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 |
no test coverage detected