Skip to content

Code Quality: mypy check failed #546

Open
@jameslan

Description

@jameslan

Summary

mypy check failed

Reproduction Steps

Run

poe types

Expected Results

It should pass.

Actual Results

Got

-> % poe types
Poe => mypy src --ignore-missing-imports
src/betterproto/enum.py:36: error: Invalid base class  [misc]
src/betterproto/enum.py:43: error: Need type annotation for "value_map" (hint: "value_map: Dict[<type>, <type>] = ...")  [var-annotated]
src/betterproto/enum.py:44: error: Need type annotation for "member_map" (hint: "member_map: Dict[<type>, <type>] = ...")  [var-annotated]
src/betterproto/enum.py:63: error: Need type annotation for "cls"  [var-annotated]
src/betterproto/enum.py:123: error: "object" has no attribute "name"  [attr-defined]
src/betterproto/enum.py:126: error: Invalid base class  [misc]
src/betterproto/enum.py:177: error: Unexpected keyword argument "name" for "__new__" of "object"  [call-arg]
.venv/lib/python3.7/site-packages/mypy/typeshed/stdlib/builtins.pyi:90: note: "__new__" of "object" defined here
src/betterproto/enum.py:177: error: Unexpected keyword argument "value" for "__new__" of "object"  [call-arg]
.venv/lib/python3.7/site-packages/mypy/typeshed/stdlib/builtins.pyi:90: note: "__new__" of "object" defined here
src/betterproto/_version.py:2: error: Module "importlib" has no attribute "metadata"  [attr-defined]
src/betterproto/__init__.py:201: error: Argument "default" to "field" has incompatible type "Optional[Any]"; expected "Field[Any]"  [arg-type]
src/betterproto/__init__.py:547: error: Missing return statement  [return]
src/betterproto/__init__.py:663: error: Argument 1 to "fields" has incompatible type "Type[Message]"; expected "Union[DataclassInstance, Type[DataclassInstance]]"  [arg-type]
src/betterproto/__init__.py:894: error: The erased type of self "Type[betterproto.Message]" is not a supertype of its class "betterproto.Message"  [misc]
src/betterproto/__init__.py:1606: error: Name "from_dict" already defined on line 1587  [no-redef]
src/betterproto/plugin/models.py:195: error: Incompatible types in assignment (expression has type "Union[Message, OutputTemplate]", variable has type "ProtoContentBase")  [assignment]
src/betterproto/plugin/models.py:202: error: Incompatible types in assignment (expression has type "Union[Message, OutputTemplate]", variable has type "ProtoContentBase")  [assignment]
src/betterproto/plugin/models.py:278: error: "str" has no attribute "name"  [attr-defined]
src/betterproto/plugin/models.py:295: error: Incompatible types in assignment (expression has type "Union[MessageCompiler, OutputTemplate]", base class "ProtoContentBase" defined the type as "Union[Message, OutputTemplate]")  [assignment]
src/betterproto/plugin/models.py:296: error: Incompatible types in assignment (expression has type "object", variable has type "DescriptorProto")  [assignment]
src/betterproto/plugin/models.py:297: error: Incompatible types in assignment (expression has type "object", variable has type "List[int]")  [assignment]
src/betterproto/plugin/models.py:324: error: "MessageCompiler" has no attribute "repeated"  [attr-defined]
src/betterproto/plugin/models.py:396: error: Incompatible types in assignment (expression has type "object", variable has type "MessageCompiler")  [assignment]
src/betterproto/plugin/models.py:397: error: Incompatible types in assignment (expression has type "FieldDescriptorProto", base class "MessageCompiler" defined the type as "DescriptorProto")  [assignment]
src/betterproto/plugin/models.py:484: error: Argument 2 to "is_map" has incompatible type "MessageCompiler"; expected "DescriptorProto"  [arg-type]
src/betterproto/plugin/models.py:500: error: Item "None" of "Optional[str]" has no attribute "lower"  [union-attr]
src/betterproto/plugin/models.py:610: error: Incompatible types in assignment (expression has type "object", variable has type "Type[Any]")  [assignment]
src/betterproto/plugin/models.py:611: error: Incompatible types in assignment (expression has type "object", variable has type "Type[Any]")  [assignment]
src/betterproto/plugin/models.py:612: error: Incompatible types in assignment (expression has type "object", variable has type "str")  [assignment]
src/betterproto/plugin/models.py:613: error: Incompatible types in assignment (expression has type "object", variable has type "str")  [assignment]
src/betterproto/plugin/models.py:624: error: Incompatible types in assignment (expression has type "str", variable has type "Type[Any]")  [assignment]
src/betterproto/plugin/models.py:629: error: Incompatible types in assignment (expression has type "str", variable has type "Type[Any]")  [assignment]
src/betterproto/plugin/models.py:636: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
src/betterproto/plugin/models.py:637: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
src/betterproto/plugin/models.py:661: error: Incompatible types in assignment (expression has type "EnumDescriptorProto", base class "MessageCompiler" defined the type as "DescriptorProto")  [assignment]
src/betterproto/plugin/models.py:662: error: Incompatible types in assignment (expression has type "object", variable has type "List[EnumEntry]")  [assignment]
src/betterproto/plugin/models.py:699: error: Incompatible types in assignment (expression has type "object", variable has type "OutputTemplate")  [assignment]
src/betterproto/plugin/models.py:700: error: Incompatible types in assignment (expression has type "object", variable has type "DescriptorProto")  [assignment]
src/betterproto/plugin/models.py:701: error: Incompatible types in assignment (expression has type "object", variable has type "List[int]")  [assignment]
src/betterproto/plugin/models.py:721: error: Incompatible types in assignment (expression has type "ServiceCompiler", base class "ProtoContentBase" defined the type as "Union[Message, OutputTemplate]")  [assignment]
src/betterproto/plugin/models.py:723: error: Incompatible types in assignment (expression has type "object", variable has type "List[int]")  [assignment]
src/betterproto/plugin/parser.py:58: error: "Message" has no attribute "name"  [attr-defined]
src/betterproto/plugin/parser.py:59: error: Incompatible types in "yield" (actual type "Tuple[Message, List[int]]", expected type "Tuple[Union[EnumDescriptorProto, DescriptorProto], List[int]]")  [misc]
src/betterproto/plugin/parser.py:86: error: Argument 1 to "append" of "list" has incompatible type "FileDescriptorProto"; expected "str"  [arg-type]
src/betterproto/plugin/parser.py:106: error: Argument 1 to "traverse" has incompatible type "str"; expected "FileDescriptorProto"  [arg-type]
src/betterproto/plugin/parser.py:108: error: Argument "source_file" to "read_protobuf_type" has incompatible type "str"; expected "FileDescriptorProto"  [arg-type]
src/betterproto/plugin/parser.py:109: error: Argument "item" to "read_protobuf_type" has incompatible type "Union[EnumDescriptorProto, DescriptorProto]"; expected "DescriptorProto"  [arg-type]
src/betterproto/plugin/parser.py:117: error: "str" has no attribute "service"  [attr-defined]
src/betterproto/plugin/parser.py:149: error: Incompatible types in assignment (expression has type "Path", variable has type "str")  [assignment]
src/betterproto/plugin/parser.py:216: error: Argument "proto_obj" to "ServiceCompiler" has incompatible type "ServiceDescriptorProto"; expected "DescriptorProto"  [arg-type]
Found 49 errors in 5 files (checked 24 source files)

System Information

libprotoc 25.1
Python 3.7.17

Checklist

  • I have searched the issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwaitWaiting for author

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions