You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm against merging python#7430 because:
- Generator is not an ergonomic type
- It's very widely breaking
- Safety could easily be enforced by a linter that ensures use of `yield
from` instead of `return` in an @contextmanager
To expand on that a little:
- I care about the typing system being accessible. Generator with its
three type vars is not a friendly type. I see enough confusion
about Iterable, Iterator, Generator as it is.
- Maintaining a high signal to noise / effort ratio is an important
part of making typing accessible. Breaking changes that seem
arbitrary to a casual user reinforce existing negative impressions
of typing that hurt the ecosystem as a whole.
- In all the years of typing, this has come up basically never
(reported twice by asottile, none of the outlinks from the issue
contain the bug, issue itself is not popular), so I think this is
99.99% noise. Between typeshed and mypy, I've seen a lot of typing
issue reports.
But I'm willing to admit that the considerations are slightly different
for asynccontextmanager:
- async is less widely used than sync, so maybe this is less
widely breaking (let's at least see primer)
- async is typically used by more experienced Python users, so there's
already an accessibility floor here
- There is no equivalent to `yield from` in async that a linter could
enforce, so this genuinely can only be solved in type checkers
- The issue that led to python#7430 was with asynccontextmanager
- We've gotten away with some pedantic narrowings of async types before
This is just an experiment, I'm not sure whether I'm actually in favour
of this change, but I'm a lot more willing to consider it. Note that I'm
not open to slippery slope consistency arguments here; if a constraint
is that we do both async and sync or neither, then I'm firmly in the
neither camp.
0 commit comments