I agree that type comments should be deprecated. To that end, I removed most mentions of type comments from the mypy docs earlier this year.

That said, 20% is higher than I'd have guessed, so any eventual removal would need to be quite gentle (thank you Anthony for making that estimate!)

For completeness, the other (niche) use cases for type comments I've seen are:
- Zero overhead annotations. I don't think we need to sweat this, the SC has been quite clear that annotations need to be part of the runtime.
- Annotating multiple assignments (probably more niche than annotating "for" or "with")

On Sun, 5 Jun 2022 at 17:41, Michael Sullivan <sully@msully.net> wrote:
Type comments are also needed (in more limited circumstances) to support Python 3.5, though that is also EOL

On Sun, Jun 5, 2022 at 2:45 PM Anthony Sottile <asottile@umich.edu> wrote:
I selfishly nudged Ethan to post this heh

I'm planning on removing support for type comments in pyflakes since
it makes it significantly slower and pyflakes no longer supports
python 2x. So I wanted some additional more-official confirmation of
"let's deprecate typing comments" from typing-sig.
https://github.com/PyCQA/pyflakes/pull/684

I did a very rough survey of the top 500 pypi packages and 111 (about
~20%) utilize type comments (though I suspect they are only there to
support python 2.x or by accident) (this was on stream:
https://www.youtube.com/watch?v=JcaYY07SRDo&t=1h12m )

as for `for` / `with` -- while there isn't a _direct_ replacement then
can be typed with inline annotations (hopefully making the argument
stronger for deprecating type comments):

```python
import contextlib

def untyped(): ...

@contextlib.contextmanager
def untyped_ctx(): ...

x: int
for x in untyped():
    reveal_type(x)  # Revealed type is "builtins.int"

y: int
with untyped_ctx() as y:
    reveal_type(y)  # Revealed type is "builtins.int"
```

anthony

On Sun, Jun 5, 2022 at 5:21 PM Jelle Zijlstra <jelle.zijlstra@gmail.com> wrote:
>
>
>
> El dom, 5 jun 2022 a las 13:26, Ethan Smith (<ethan@ethanhs.me>) escribió:
>>
>> Hi all,
>>
>> Recently I was thinking about the place of type comments in Python typing. As far as I am aware, mypy is the only typechecker that remains that still supports Python 2. I expect we will remove support for Python 2 before the end of the year (but we haven't decided anything on that yet).
>>
>> So what does this  mean for type comments? I think it would be best if we no longer needed to support them. However, there are a couple of issues:
>>
>> 1. They are specified in PEP 484 so we would need a new PEP most likely to deprecate/remove them
>
>
> Yes, there's really no other process right now that we could use to officially deprecate the feature. I'm hoping eventually we'll put together a "typing specification" separate from the PEP texts where we could make a change like this without a need for the full PEP process.
>
> On the substance I agree that there's no need for type comments any more. Type checkers should feel free to deprecate and remove their support (subject to their own deprecation policy and timeline), and code that is intended to be understood by multiple type checkers should not use them.
>
>>
>> 2. There isn't an obvious replacement for for/with type comments, we'd need to figure out a reasonable replacement.
>
>
> Do we need a replacement? I have never felt the need to use a type comment for a for or with statement, and I don't recall any user requests around them either. If your `__iter__` and `__enter__` methods are correctly annotated, you shouldn't need a specified type for the for/with target.
>
>>
>>
>> Anyway, I thought I'd start this thread to kick off some discussion, I'd love to hear what others think and if people have ideas for syntax for with/for statements.
>>
>> Ethan
>> He/Him
>> _______________________________________________
>> 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: jelle.zijlstra@gmail.com
>
> _______________________________________________
> 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: asottile@umich.edu
_______________________________________________
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: sully@msully.net
_______________________________________________
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