> Could you summarize your proposal in a few lines?
Use PEP 593 `Annotated` the way Adrian has proposed, but with an additional
parameter which maps the type guard on the given function parameter name:
```python
def check_int_and_str(x, y) -> Annotated[bool, TypeGuard(int, "x"),
TypeGuard(str,
I've proposed PEP 593 `Annotated` too, but in the typing-sig mailing list:
https://mail.python.org/archives/list/typing-...@python.org/message/CVLLRWU7MU7T2AMC4P7ZEG4IMJF6V5UL/
and Guido had the following answer:
> I see PEP 593 as a verbose solution to the problem "how do we use
annotations for
PEP 649 doesn't prevent to use stringified annotations (Larry has previously
mentioned it in its response to Paul Bryan), and they seem to be still required
when `if TYPE_CHECKING:` is used, despite the PEP claim.
And my last message bring some use cases where strings are also required
If I've understood the PEP correctly, it would cause the following simple
example to fail:
```python
from dataclasses import dataclass
@dataclass
class User:
name: str
friends: list[User]
```
In fact, when the `dataclass` decorator is called, `User` class is not yet
added to the module
> Please note that this is a thread about PEP 649.
>
> If PEP 649 accepted and PEP 563 dies, all such idioms breaks
annotation completely.
>
> Users need to import all heavy modules and circular references used
only type hints, or user can not get even string form annotation which
is very useful
By the way, without adding an other constant, `__debug__` can also be used. It
discards runtime overhead when it matters, in optimized mode.
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
> How about having a pseudo-module called __typing__ that is
> ignored by the compiler:
>
> from __typing__ import ...
>
> would be compiled to a no-op, but recognised by type checkers.
If you want to do run-time typing stuff, you would use
There is already a way of doing that: `if