class_docstr: Writes a single pyi file
class_docstr_tok: ["Writes","a","single","pyi","file"]
code: def write_messages(
      self,
      messages: Iterable[d.DescriptorProto],
      prefix: str,
      scl_prefix: SourceCodeLocation,
  ) -> None:
      wl = self._write_line
  
      for i, desc in enumerate(messages):
          qualified_name = prefix + desc.name
  
          # Reproduce some hardcoded logic from the protobuf implementation - where
          # some specific "well_known_types" generated protos to have additional
          # base classes
          addl_base = ""
          if self.fd.package + "." + desc.name in WKTBASES:
              # chop off the .proto - and import the well known type
              # eg `from google.protobuf.duration import Duration`
              well_known_type = WKTBASES[
                  self.fd.package + "." + desc.name
              ]
              addl_base = ", " + self._import(
                  "google.protobuf.internal.well_known_types",
                  well_known_type.__name__,
              )
  
          class_name = (
              desc.name
              if desc.name not in PYTHON_RESERVED
              else "_r_" + desc.name
          )
          message_class = self._import(
              "google.protobuf.message", "Message"
          )
          wl(f"class {class_name}({message_class}{addl_base}):")
          with self._indent():
              scl = scl_prefix + [i]
              if self._write_comments(scl):
                  wl("")
  
              desc_type = self._import(
                  "google.protobuf.descriptor", "Descriptor"
              )
              wl(f"DESCRIPTOR: {desc_type}")
              wl("")
  
              # Nested enums/messages
              self.write_enums(
                  desc.enum_type,
                  qualified_name + ".",
                  scl + [d.DescriptorProto.ENUM_TYPE_FIELD_NUMBER],
              )
              self.write_messages(
                  desc.nested_type,
                  qualified_name + ".",
                  scl + [d.DescriptorProto.NESTED_TYPE_FIELD_NUMBER],
              )
  
              # integer constants  for field numbers
              for f in desc.field:
                  wl(
                      f"{f.name.upper()}_FIELD_NUMBER: {self._builtin('int')}"
                  )
  
              for idx, field in enumerate(desc.field):
                  if field.name in PYTHON_RESERVED:
                      continue
                  field_type = self.python_type(field)
  
                  if (
                      is_scalar(field)
                      and field.label
                      != d.FieldDescriptorProto.LABEL_REPEATED
                  ):
                      # Scalar non repeated fields are r/w
                      wl(f"{field.name}: {field_type}")
                      self._write_comments(
                          scl
                          + [d.DescriptorProto.FIELD_FIELD_NUMBER, idx]
                      )
                  else:
                      # r/o Getters for non-scalar fields and scalar-repeated fields
                      scl_field = scl + [
                          d.DescriptorProto.FIELD_FIELD_NUMBER,
                          idx,
                      ]
                      wl("@property")
                      body = (
                          " ..."
                          if not self._has_comments(scl_field)
                          else ""
                      )
                      wl(
                          f"def {field.name}(self) -> {field_type}:{body}"
                      )
                      if self._has_comments(scl_field):
                          with self._indent():
                              self._write_comments(scl_field)
  
              self.write_extensions(
                  desc.extension,
                  scl + [d.DescriptorProto.EXTENSION_FIELD_NUMBER],
              )
  
              # Constructor
              wl("def __init__(")
              with self._indent():
                  if any(f.name == "self" for f in desc.field):
                      wl("# pyright: reportSelfClsParameterName=false")
                      wl("self_,")
                  else:
                      wl("self,")
              with self._indent():
                  constructor_fields = [
                      f
                      for f in desc.field
                      if f.name not in PYTHON_RESERVED
                  ]
                  if len(constructor_fields) > 0:
                      # Only positional args allowed
                      # See https://github.com/nipunn1313/mypy-protobuf/issues/71
                      wl("*,")
                  for field in constructor_fields:
                      field_type = self.python_type(
                          field, generic_container=True
                      )
                      if (
                          self.fd.syntax == "proto3"
                          and is_scalar(field)
                          and field.label
                          != d.FieldDescriptorProto.LABEL_REPEATED
                          and not self.relax_strict_optional_primitives
                          and not field.proto3_optional
                      ):
                          wl(f"{field.name}: {field_type} = ...,")
                      else:
                          wl(
                              f"{field.name}: {field_type} | None = ...,"
                          )
              wl(") -> None: ...")
  
              self.write_stringly_typed_fields(desc)
  
          if prefix == "" and not self.readable_stubs:
              wl("")
              wl(
                  f"{_mangle_global_identifier(class_name)} = {class_name}"
              )
          wl("")
  
imports: from __future__ import annotations
  import sys
  from collections import defaultdict
  from contextlib import contextmanager
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Set, Sequence, Tuple
  import google.protobuf.descriptor_pb2
  from google.protobuf.compiler import plugin_pb2
  from google.protobuf.internal.containers import RepeatedCompositeFieldContainer
  from google.protobuf.internal.well_known_types import WKTBASES
  from .None import extensions_pb2
label_desc: Use image node_id 13 for calling the PkgWriter obj's underlying member method code with example usage: obj.write_messages(messages, prefix, scl_prefix) without return types