Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Code Quality: mypy check failed

Đang mở
#546 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Chạy poe types để tái hiện 49 lỗi mypy. Bắt đầu bằng cách xem xét các vị trí được báo cáo trong src/betterproto/enum.py, src/betterproto/_version.py, src/betterproto/__init__.py, src/betterproto/plugin/models.py và src/betterproto/plugin/parser.py. Hoàn thành khi kiểm tra kiểu chạy qua mà không có lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug wait
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.
Ngôn ngữ chính
Python
Star
1.8k
Fork
235
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của danielgtaylor/python-betterproto

Tất cả issue của danielgtaylor/python-betterproto

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.