Description
Currently the proposal suggests a dictionary-based syntax for allowing the arbitrary annotations currently used in Python 3 to coexist with type annotations (https://github.com/ambv/typehinting/blob/master/pep-NNNN.txt#L194):
def notify_by_email(employees: {'type': List[Employee], 'min_size': 1, 'max_size': 100}): ...
This meshes well with existing usage if the existing non-type annotation is already a dictionary, but if it's some other kind of value it forces additional refactoring. Maybe instead, typing
could provide a TaggedType
or similar class, which cleanly separates type information from other information that the programmer wants in their annotations:
def notify_by_email(employees: TaggedType(List[Employee], {'min_size': 1, 'max_size': 100}): ...
or
def notify_by_email(employees: TaggedType(List[Employee], 'list of employees to be notified')): ...
The first argument is always a type, and the second argument is any arbitrary value.
This would also free up dictionaries for possibly representing structural types/protocols (see #11).