class documentation

Lazy resolver for protobuf descriptors by fully qualified name.

Instances are callable; the first call resolves and caches the descriptor.

Parameters
nameFully qualified descriptor name. Leading . is allowed.
file_descriptorProtobuf file descriptor to search within.
expected_typeDescriptor type expected by the caller.
Method __call__ Retrieve the descriptor of the specified type using the fully qualified name.
Method __init__ Create a descriptor wrapper.
Method _find_descriptor Recursively search for a descriptor by name.
Instance Variable _descriptor Cached resolved descriptor.
Instance Variable _expected_type Expected descriptor class.
Instance Variable _file_descriptor Root file descriptor used for lookup.
Instance Variable _name Normalized fully qualified name.
def __call__(self) -> T: (source)

Retrieve the descriptor of the specified type using the fully qualified name.

def __init__(self, name: str, file_descriptor: pb.FileDescriptor, expected_type: type[T]): (source)

Create a descriptor wrapper.

Parameters
name:strFully qualified descriptor name.
file_descriptor:pb.FileDescriptorProtobuf file descriptor to search within.
expected_type:type[T]Descriptor type expected by the caller.
def _find_descriptor(self, container: pb.FileDescriptor | pb.Descriptor, name: str) -> pb.Descriptor | pb.EnumDescriptor | pb.OneofDescriptor | pb.ServiceDescriptor | None: (source)

Recursively search for a descriptor by name.

Parameters
container:pb.FileDescriptor | pb.DescriptorFile or message descriptor to search within.
name:strFully qualified name to resolve.
Returns
pb.Descriptor | pb.EnumDescriptor | pb.OneofDescriptor | pb.ServiceDescriptor | NoneMatching descriptor or None if not found.
Raises
ValueErrorIf the protobuf pool returns an unexpected type.
_descriptor: T | None = (source)

Cached resolved descriptor.

_expected_type: type[T] = (source)

Expected descriptor class.

_file_descriptor = (source)

Root file descriptor used for lookup.

Normalized fully qualified name.