3 ms·
Why not use Enum anyway, which works fine with MyPy? I don't mind the verbosity, it's a one-time commitment to what, 10 extra lines of code?
by nerdponx 6y ago
Why not use Enum anyway, which works fine with MyPy? I don't mind the verbosity, it's a one-time commitment to what, 10 extra lines of code?
- ramraj07 6y agoIssue is I'll now need two imports everytime I call this method, which becomes mildly annoying. I was doing this, but a lot of times the Literal type seems more than sufficient. It also seems to play real nice with pydantic so it's an added win!
- nerdponx 6y agoI'm not sure what you mean by "two imports". If you define your Enum subclass in the same file, you use one import for enum.Enu. If you eschew enums and use Literal, you use one import for typing.Literal.