Skip to content

[BUG] validate's type stub makes basedpyright think its type is partially unknown #522

Description

@mkanat

Description

On a call to validate as of 2.0.0, basedpyright says:

Type of "validate" is partially unknown
  Type of "validate" is
  "(message: protobuf._message.Message[Unknown] |
  google.protobuf.message.Message, *, fail_fast: bool = False) -> None"
  (reportUnknownMemberType)

Steps to Reproduce

  # pyright: strict

  import protovalidate
  from google.protobuf import empty_pb2

  message = empty_pb2.Empty()
  protovalidate.validate(message)
  uv init --bare
  uv add protovalidate==2.0.0 basedpyright
  uv run basedpyright repro.py

Possible Solution

I think you can parameterize Message2[Any] as the simplest fix, although it might be more correct to add a typevar and do Message2[T]? Not sure, I haven't looked into the code deeply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions