Representation of an output .py file. Each output file corresponds to a .proto input file, but may need references to other .proto files to be built.
| 228 | |
| 229 | @dataclass |
| 230 | class OutputTemplate: |
| 231 | """Representation of an output .py file. |
| 232 | |
| 233 | Each output file corresponds to a .proto input file, |
| 234 | but may need references to other .proto files to be |
| 235 | built. |
| 236 | """ |
| 237 | |
| 238 | parent_request: PluginRequestCompiler |
| 239 | package_proto_obj: FileDescriptorProto |
| 240 | input_files: List[str] = field(default_factory=list) |
| 241 | imports: Set[str] = field(default_factory=set) |
| 242 | datetime_imports: Set[str] = field(default_factory=set) |
| 243 | pydantic_imports: Set[str] = field(default_factory=set) |
| 244 | builtins_import: bool = False |
| 245 | messages: List["MessageCompiler"] = field(default_factory=list) |
| 246 | enums: List["EnumDefinitionCompiler"] = field(default_factory=list) |
| 247 | services: List["ServiceCompiler"] = field(default_factory=list) |
| 248 | imports_type_checking_only: Set[str] = field(default_factory=set) |
| 249 | pydantic_dataclasses: bool = False |
| 250 | output: bool = True |
| 251 | typing_compiler: TypingCompiler = field(default_factory=DirectImportTypingCompiler) |
| 252 | |
| 253 | @property |
| 254 | def package(self) -> str: |
| 255 | """Name of input package. |
| 256 | |
| 257 | Returns |
| 258 | ------- |
| 259 | str |
| 260 | Name of input package. |
| 261 | """ |
| 262 | return self.package_proto_obj.package |
| 263 | |
| 264 | @property |
| 265 | def input_filenames(self) -> Iterable[str]: |
| 266 | """Names of the input files used to build this output. |
| 267 | |
| 268 | Returns |
| 269 | ------- |
| 270 | Iterable[str] |
| 271 | Names of the input files used to build this output. |
| 272 | """ |
| 273 | return sorted(f.name for f in self.input_files) |
| 274 | |
| 275 | @property |
| 276 | def python_module_imports(self) -> Set[str]: |
| 277 | imports = set() |
| 278 | |
| 279 | has_deprecated = False |
| 280 | if any(m.deprecated for m in self.messages): |
| 281 | has_deprecated = True |
| 282 | if any(x for x in self.messages if any(x.deprecated_fields)): |
| 283 | has_deprecated = True |
| 284 | if any( |
| 285 | any(m.proto_obj.options.deprecated for m in s.methods) |
| 286 | for s in self.services |
| 287 | ): |