Skip to content

Recommend reveal_type in PEP 484 #277

@ilevkivskyi

Description

@ilevkivskyi

When #136 will be fixed, it will be nice to have something that could be used in place of issubclass for "experimentation" with types. Mypy already provides such a function -- reveal_type. I think it works very well and maybe it is a good idea to add a recommendation to PEP 484 that static type checkers should provide a function to reveal the inferred types? Or maybe even add a function

def reveal_type(obj):
    print('Runtime type is:', getattr(obj, '__orig_class__',  type(obj)))
    return obj

to typing.py so that it can be used for this purpose by other type checkers.

Metadata

Metadata

Assignees

Labels

topic: featureDiscussions about new features for Python's type annotations

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions