Skip to content
This repository was archived by the owner on Sep 3, 2026. It is now read-only.
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

Pytype cannot handle <class name>.<nested class name> in pyi files #150

Closed

Description

@rchen152

For example, third_party/2and3/google/protobuf/descriptor_pb2.pyi contains:

class UninterpretedOption(Message):
    class NamePart(Message):
        def FromString(cls, s: bytes) -> UninterpretedOption.NamePart: ...

Pytype thinks that UninterpretedOption is an import and goes looking for the corresponding pyi file, leading to:
third_party/2and3/google/protobuf/descriptor_pb2.pyi: pytype.load_pytd.BadDependencyError: Can't find pyi for 'google.protobuf.descriptor_pb2.UninterpretedOption', referenced from 'google.protobuf.descriptor_pb2'

The problem is that the CollectDependencies visitor assumes that the first part of a dotted name is always a module: https://github.com/google/pytype/blob/master/pytype/pytd/visitors.py#L1830.

Activity

  1. self-assigned this
    on Oct 9, 2018
  2. removed their assignment
    on Oct 18, 2018
  3. rchen152 commented on May 1, 2019

    @rchen152
    ContributorAuthor

    One thing that would be useful until we get this bug fixed is to give a clearer error message, so that when it is encountered in hand-crafted stubs, the writer can figure out what's going on.

  4. self-assigned this
    on May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions