Thanks to everyone who attended today's meetup. You can check out the recording, chat, and slides in the running Google doc [1]. Thanks to Sebastian for presenting about TypeVar syntax, and thanks to the core Python developers who joined this meeting.

Meeting notes:

+ Context: In the Typing Summit panel [2] during PyCon 2022, we had asked Steering Council members (Thomas Wouters and Pablo Galindo Salgado) about future syntax proposals for typing. They replied that "The more constrained the syntax is, the less resistance there will be from the community." and "We need to consider that you can put type annotation syntax into a cast as an expression and it would work, so syntax changes are not just affecting types".

So, we decided to dedicate the meetup to a discussion about TypeVar syntax, since it is a constrained syntax that will (mostly) affect the syntax of statements rather than expressions.

+ Sebastian mentioned three possible syntaxes for declaring a TypeVar:
  (a) angular brackets `def foo<T>(x: T) -> T:`
  (b) square brackets `def foo[T](x: T) -> T:`
  (c) new scope syntax: such as, `let T = TypeVar("T") in def foo[T](x: T) -> T:` (Jelle had proposed this earlier)

  Other proposals from the audience:
  (d) decorator syntax
  (e) new delimiter for TypeVar declarations: something different from `<>` and `[]`. Maybe `{}`.

  For more details, see the slides linked in the doc.

+ Sebastian also described the "mini-language" to specify variance, upper bound, etc. The main approaches here were:

  (a) punctuation only (`def foo[T <= int](x: T) -> T`)
  (b) keyword (`def foo[T bound int](x: T) -> T`)
  (c) function-style syntax (`def foo[T (bound=int)](x: T) -> T`)

  The most extensible option is (c). We could add new flags to the TypeVar declaration without having to change the language syntax.

+ Objections:

  (a) Angular brackets could lead to ambiguity with existing `<` and `>`.
  (b) Square brackets could be hard to read given how much they are already used.
  (c) New scope syntax: This could hurt readability if generic classes and methods need to be indented. If we don't indent the statement after `let T = TypeVar("T") in `, it's unclear if T is scoped only to the next statement or to the rest of the file. Most importantly, it is pretty verbose in the current proposal - we have to write what we currently write (`T = TypeVar("T")`) plus `let ... in`. It doesn't seem to be clearly better than the existing syntax.

+ Usability improvements: Eric Traut suggested that "If a TypeVar is associated with only one scope, its variance could be inferred from its usage". That might eliminate the need for special syntax to specify variance.


+ Poll: I polled participants at the end of the meeting, to get a rough sense of where people stand. It looks like we were split on the high-level syntax and in favor of a function-style mini-language:

  - high-level declaration:
    + Angle brackets - 5/12 respondents (Steven, Jelle, Shannon, Erik, Konstantin)
    + Introduce scope - 5/12 respondents (Carl, Batuhan, Sebastian, Jia, Alex)
    + Square brackets - 2/12 respondents (James, Jukka)

  - mini-language:
    + Function-style syntax - 8/12 respondents (Carl, Steven, Batuhan T, Jelle Zijlstra, Sebastian Rittau, Jia Chen, Konstantin Schukraft, Jukka Lehtosalo)
    + Punctuation - 3/12 respondents (Shannon, James, Alex)
    + Keyword - 1/12 respondents (Erik)

+ Follow-ups: Guido suggested that we don't have to cover all use cases with the syntax. That might over-complicate the syntax and leave us without a feasible solution. Instead, we might want to have a concise syntax for the most common use cases, and defer to the older syntax for the remaining cases.

If you'd like to continue this discussion, please reply to the *dedicated* TypeVar syntax thread: [3], so that this thread is purely for Typing Meetup logistics.

[1]: Meeting recording and notes: https://docs.google.com/document/d/17iqV7WWvB0IwA43EPlIqlUS6Xuvk08X3sEudAA-gQIo/edit?usp=sharing
[2]: Typing Summit recording and notes: https://docs.google.com/document/d/1_CBM9SeBrFTFULtwAzGmxlBRhqzpIArQ65cWa2WwfTI/edit#heading=h.hl5q80pc2xbz
[3]: TypeVar syntax thread: https://mail.python.org/archives/list/typing-sig@python.org/thread/GPQO2F4NHFVWZC2KEJBGDYIRFSR4AYHF/#2NQ4IEVWKUORDPWRB4QJ3YMOCLYOQP6W

On Wed, Jun 1, 2022 at 7:00 AM S Pradeep Kumar <gohanpra@gmail.com> wrote:
Reminder that the meetup is today at 11:00 am San Francisco time (UTC-7) / 7:00 pm London time (UTC+1).


Agenda
Syntax for TypeVars, by Sebastian Rittau


(We couldn't have it at the usual 10 am time this month because of conflicts. I hope to return to the 10 am slot next time.)




I'll share the recording and notes after the meetup. [1]
--
S Pradeep Kumar



--
S Pradeep Kumar


--
S Pradeep Kumar