Skip to content

Fix autogenerated protobuf stub's nonexistent import #4815

Description

@gvanrossum

My PR (#4814) is failing tests in a part I didn't touch:

running mypy --python-version 3.9 --strict-optional --no-site-packages --show-traceback --no-implicit-optional --disallow-any-generics --disallow-subclassing-any --platform linux # with 1042 files
third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi:45: error: Cannot find implementation or library stub for module named 'google.protobuf.unittest_pb2'
third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi:45: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1042 source files)

(and repeated for other versions). The same seems to be happening for other recent PRs, e.g. #4813 and #4811.

Activity

  1. hauntsaninja commented on Dec 13, 2020

    @hauntsaninja
    Collaborator

    Did some investigating, it looks like the trigger for this was syncing typeshed: python/mypy#9794
    The error looks legitimate, the file was removed in https://github.com/python/typeshed/pull/4785/files#diff-328c07f017a31da756c9b78484dbeab4ec7757a29092a2ba2c9afe2d4bc63a50 but continues to be imported. I assume mypy managed to continue to find the file in its bundled typeshed, which is a little weird (maybe mypy_test should pass in --custom-typeshed-dir).

    I'm not sure how to fix, since the file is autogenerated, so cc @nipunn1313

  2. hauntsaninja commented on Dec 13, 2020

    @hauntsaninja
    Collaborator

    (In case Nipunn doesn't see this soon, just removing third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi entirely seems to be enough to get things green in a pinch)

  3. added a commit that references this issue on Dec 13, 2020
  4. srittau commented on Dec 14, 2020

    @srittau
    Collaborator

    I have replaced the missing import with Any for now. This should work, but of course still needs a proper fix.

  5. changed the title [-]Tests seem to be failing[/-] [+]Fix autogenerated protobuf stub's nonexistent import[/+] on Dec 14, 2020
  6. nipunn1313 commented on Dec 23, 2020

    @nipunn1313
    Contributor

    Fixed! My mistake.
    Thanks for the report @gvanrossum - and thanks for the quick fix @srittau - bought me time to look into a proper fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions