danielgtaylor / python-betterproto

Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
MIT License
1.56k stars 218 forks source link

Mypy sees enum members as integer #600

Closed phooijenga closed 3 months ago

phooijenga commented 3 months ago

Summary

As of 2.0.0b7, mypy sees enum members as integers

Reproduction Steps

import betterproto

class Event(betterproto.Enum):
    START = 0
    STOP = 1

e: Event = Event.START

Expected Results

I expect the code to type-check without issues, as it does with 2.0.0b6.

Actual Results

test-enum.py:9: error: Incompatible types in assignment (expression has type "int", variable has type "Event")  [assignment]

System Information

betterproto 2.0.0b7 mypy 1.11.1

Checklist

Gobot1234 commented 3 months ago

Mypy isn't interpreting the bases list correctly. This isn't something we can fix (I've tried) if you want your code to type check use Pyright