Skip to content

Infer a dep on types-protobuf when running mypy on protobuf-generated code #19766

Open
@benjyw

Description

@benjyw

Today adding the dep manually allows it to typecheck:

protobuf_sources(
    dependencies = ["3rdparty/python#types-protobuf"],
)

As long as this is set too:

[python-protobuf]
mypy_plugin = true

that is.

We should add this dep automatically.

Note that without types-protobuf you would have to set this in mypy.ini:

[mypy-*.v1.*]
ignore_errors = True

Which would cause mypy to miss some type information from the generated code, which would in turn cause it to miss errors (such as accessing unknown fields) in code that uses the generated code.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions