Stewori / pytypes

Typing-toolbox for Python 3 _and_ 2.7 w.r.t. PEP 484.
Apache License 2.0
200 stars 20 forks source link

typechecked(string) should have more consistent return type #97

Closed dbarnett closed 4 years ago

dbarnett commented 4 years ago

Currently if you call typechecked on a string module name, it has case-by-case behavior to sometimes return the original string and sometimes return the resolved module:

typechecked('requests') → <module 'requests'>
typechecked('requests') → 'requests'

Could we simplify to make it unconditionally return the value that was passed in, str→str, module→module, class→class, etc?

Stewori commented 4 years ago

I agree to that solution. Accepting a string in place of the module was meant for convenience, not to complicate static typechecking. I think nothing depends on this particular current behavior. Please go ahead and change it as you proposed.