DEV Community

Discussion on: 📝Python's Type Annotations 📝- Why You Always Should Use It

Collapse
 
hasii2011 profile image
Humberto A Sanchez II

Just wondering if you have any thoughts/comments on using NewType vs. type equivalencies. By that I mean, creating a type like:

MethodName = str

vs.

MethodName = NewType('MethodName', str)

The former makes the PyCharm type checker happy, but fails when using the 'mypy' linter.

The latter makes 'mypy' happy, but causes a lot of extra casting and syntactic sugar to keep PyCharm happy.

Collapse
 
hasii2011 profile image
Humberto A Sanchez II

I really hope to hear you on this?