what's a portable way to refer to `ellipsis`?
This came up internally - pytype supports `ellipsis` as a global definition in type stubs, and the poster was wondering how portable it was (seeing as how it's not directly accessible in python itself). Are other type checkers okay with `ellipsis` used as a type? martin
On Wed, Jun 17, 2020 at 12:21 PM Martin DeMello via Typing-sig < typing-sig@python.org> wrote:
This came up internally - pytype supports `ellipsis` as a global definition in type stubs, and the poster was wondering how portable it was (seeing as how it's not directly accessible in python itself). Are other type checkers okay with `ellipsis` used as a type?
I think there would be a good case for special-casing Ellipsis like None, i.e., to allow annotating Ellipsis values with just Ellipsis rather than ellipsis. Both Ellipsis and None are singleton objects, and aside from type-checking there is no need to refer to their types (which are somewhat of an implementation detail).
martin _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: shoyer@gmail.com
On Wed, Jun 17, 2020 at 12:57 PM Stephan Hoyer <shoyer@gmail.com> wrote:
On Wed, Jun 17, 2020 at 12:21 PM Martin DeMello via Typing-sig < typing-sig@python.org> wrote:
This came up internally - pytype supports `ellipsis` as a global definition in type stubs, and the poster was wondering how portable it was (seeing as how it's not directly accessible in python itself). Are other type checkers okay with `ellipsis` used as a type?
I think there would be a good case for special-casing Ellipsis like None, i.e., to allow annotating Ellipsis values with just Ellipsis rather than ellipsis.
Both Ellipsis and None are singleton objects, and aside from type-checking there is no need to refer to their types (which are somewhat of an implementation detail).
One problem I can see with that is that `Ellipsis` is a synonym for `...` and using a literal `...` already has a special meaning in type stubs. (The OP wanted pytype to support `Type[...]` but I felt that was a bad idea, and similarly `Literal[...]` would likely not be advisable.) martin
But a parser should still reflect in the AST whether '...' was used or 'Ellipsis'. So is this really a problem? On Wed, Jun 17, 2020 at 1:13 PM Martin DeMello via Typing-sig < typing-sig@python.org> wrote:
On Wed, Jun 17, 2020 at 12:57 PM Stephan Hoyer <shoyer@gmail.com> wrote:
On Wed, Jun 17, 2020 at 12:21 PM Martin DeMello via Typing-sig < typing-sig@python.org> wrote:
This came up internally - pytype supports `ellipsis` as a global definition in type stubs, and the poster was wondering how portable it was (seeing as how it's not directly accessible in python itself). Are other type checkers okay with `ellipsis` used as a type?
I think there would be a good case for special-casing Ellipsis like None, i.e., to allow annotating Ellipsis values with just Ellipsis rather than ellipsis.
Both Ellipsis and None are singleton objects, and aside from type-checking there is no need to refer to their types (which are somewhat of an implementation detail).
One problem I can see with that is that `Ellipsis` is a synonym for `...` and using a literal `...` already has a special meaning in type stubs. (The OP wanted pytype to support `Type[...]` but I felt that was a bad idea, and similarly `Literal[...]` would likely not be advisable.)
martin _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: guido@python.org
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>
On the same theme, there's also NotImplemented On Wed, 17 Jun 2020 at 17:24, Guido van Rossum <guido@python.org> wrote:
But a parser should still reflect in the AST whether '...' was used or 'Ellipsis'. So is this really a problem?
On Wed, Jun 17, 2020 at 1:13 PM Martin DeMello via Typing-sig < typing-sig@python.org> wrote:
On Wed, Jun 17, 2020 at 12:57 PM Stephan Hoyer <shoyer@gmail.com> wrote:
On Wed, Jun 17, 2020 at 12:21 PM Martin DeMello via Typing-sig < typing-sig@python.org> wrote:
This came up internally - pytype supports `ellipsis` as a global definition in type stubs, and the poster was wondering how portable it was (seeing as how it's not directly accessible in python itself). Are other type checkers okay with `ellipsis` used as a type?
I think there would be a good case for special-casing Ellipsis like None, i.e., to allow annotating Ellipsis values with just Ellipsis rather than ellipsis.
Both Ellipsis and None are singleton objects, and aside from type-checking there is no need to refer to their types (which are somewhat of an implementation detail).
One problem I can see with that is that `Ellipsis` is a synonym for `...` and using a literal `...` already has a special meaning in type stubs. (The OP wanted pytype to support `Type[...]` but I felt that was a bad idea, and similarly `Literal[...]` would likely not be advisable.)
martin _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: guido@python.org
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...> _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: hauntsaninja@gmail.com
participants (4)
-
Guido van Rossum
-
Martin DeMello
-
Shantanu Jain
-
Stephan Hoyer