class_docstr: Writes a single pyi file
class_docstr_tok: ["Writes","a","single","pyi","file"]
docstr: Type the stringly-typed methods as a Union[Literal, Literal ...]
docstr_tok: ["Type","the","stringly-typed","methods","as","a","Union","[","Literal",",","Literal","...","]"]
code: def write_stringly_typed_fields(
      self, desc: d.DescriptorProto
  ) -> None:
      """Type the stringly-typed methods as a Union[Literal, Literal ...]"""
      wl = self._write_line
      # HasField, ClearField, WhichOneof accepts both bytes/str
      # HasField only supports singular. ClearField supports repeated as well
      # In proto3, HasField only supports message fields and optional fields
      # HasField always supports oneof fields
      hf_fields = [
          f.name
          for f in desc.field
          if f.HasField("oneof_index")
          or (
              f.label != d.FieldDescriptorProto.LABEL_REPEATED
              and (
                  self.fd.syntax != "proto3"
                  or f.type == d.FieldDescriptorProto.TYPE_MESSAGE
                  or f.proto3_optional
              )
          )
      ]
      cf_fields = [f.name for f in desc.field]
      wo_fields = {
          oneof.name: [
              f.name
              for f in desc.field
              if f.HasField("oneof_index") and f.oneof_index == idx
          ]
          for idx, oneof in enumerate(desc.oneof_decl)
      }
  
      hf_fields.extend(wo_fields.keys())
      cf_fields.extend(wo_fields.keys())
  
      hf_fields_text = ", ".join(
          sorted(f'"{name}", b"{name}"' for name in hf_fields)
      )
      cf_fields_text = ", ".join(
          sorted(f'"{name}", b"{name}"' for name in cf_fields)
      )
  
      if not hf_fields and not cf_fields and not wo_fields:
          return
  
      if hf_fields:
          wl(
              "def HasField(self, field_name: {}[{}]) -> {}: ...",
              self._import("typing_extensions", "Literal"),
              hf_fields_text,
              self._builtin("bool"),
          )
      if cf_fields:
          wl(
              "def ClearField(self, field_name: {}[{}]) -> None: ...",
              self._import("typing_extensions", "Literal"),
              cf_fields_text,
          )
  
      for wo_field, members in sorted(wo_fields.items()):
          if len(wo_fields) > 1:
              wl("@{}", self._import("typing", "overload"))
          wl(
              "def WhichOneof(self, oneof_group: {}[{}]) -> {}[{}] | None: ...",
              self._import("typing_extensions", "Literal"),
              # Accepts both str and bytes
              f'"{wo_field}", b"{wo_field}"',
              self._import("typing_extensions", "Literal"),
              # Returns `str`
              ", ".join(f'"{m}"' for m in members),
          )
  
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 14 for calling the PkgWriter obj's underlying member method code with example usage: obj.write_stringly_typed_fields(desc) without return types