On Thu, Dec 21, 2017 at 6:39 AM Ivan Levkivskyi <levkivs...@gmail.com> wrote:
> For me, the three options for "don't care" have a bit different meaning: > > * typing.Any: this class is supposed to be used with static type checkers, > but this field is too dynamic > * ... (ellipsis): this class may or may not be used with static type > checkers, use the inferred type in the latter case > * "field docstring": this class should not be used with static type > checkers > > Assuming this, the second option would be the "real" "don't care". If this > makes sense, > then we can go the way proposed in > https://github.com/python/typing/issues/276 and make ellipsis semantics > "official" in PEP 484. > (pending Guido's approval) > I am a little nervous about using "..." for inferred types, because it could potentially cause confusion with other uses of ellipsis in typing. Ellipsis already has a special meaning for Tuple, so an annotation like MyClass[int, ...] could mean either a tuple subclass with integer elements or a two argument generic type where the second type is inferred. Actually, it's ambiguous even for Tuple. Ellipsis could also make a lot of sense for typing multi-dimensional arrays similar to how it's used in indexing to denote "any number of dimensions." Again, the semantics for "..." might defer from "an inferred size." >
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com