I'm sorry, but realistically this is not going to make it into 3.8. Fortunately it should be possible to make the version in typing_extensions.py support all Python versions (including 2.7). On Wed, May 29, 2019 at 2:14 PM Till <till.varoquaux@gmail.com> wrote:
Just a friendly reminder that the window to get this in to 3.8 is closing. The implementation in typing_extensions is pretty simple; upstreaming it will be easy. Also on a personal level: I'm in between big projects at work, now is a good time for me to work on it.
The backport (to python versions prior to pep_560) is proving a bit more challenging and I doubt we'll be able to get all the functionalities. I'm still trying to figure out the best way to proceed.
Best, Till
On Tue, May 28, 2019 at 12:24 PM Jakub Stasiak <jakub@stasiak.at> wrote:
On 28 May 2019, at 17:58, Till <till.varoquaux@gmail.com> wrote:
Thanks Jakub, You're right __origin__ should point to `Annotated`. I created a pull request (https://github.com/python/typing/pull/635) that should address that. Also:
def fun(x: List[Annotated[int, ‘some marker’]])
is definitely valid.
On Tue, May 28, 2019 at 9:01 AM Jakub Stasiak <jakub@stasiak.at> wrote:
On 28 May 2019, at 14:53, Jakub Stasiak <jakub@stasiak.at> wrote:
On 28 May 2019, at 11:52, Ivan Levkivskyi <levkivskyi@gmail.com>
On Tue, 28 May 2019 at 04:37, Till <till.varoquaux@gmail.com> wrote: I didn't implement any good helper function because I couldn't figure out the idiomatic way to traverse type hints at runtime. It would be very easy to add a "get_extras(t: typing.<Type>) -> Tuple[Any, ...]" function. Would that work?
This reminds me about something I wanted to do for Python 3.8: there
is an idea to add couple public helpers for introspection of typing objects.
For example `get_origin()` and `get_args()`. That would essentially just thin public wrappers around private `__origin__`/`__args__` API.
With such API one will be able to just write `if get_origin(typ) is Annotated: ...`
-- Ivan
_______________________________________________ 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/
This actually gave me the idea to test
x.__origin__ is Annotated
instead of
isinstance(x, _Annotated)
but with the current implementation _Annotated.__origin__ points to
On an unrelated note, something I’ve been wondering about since
yesterday – is Annotated supposed to be, in principle, allowed to be used
wrote: the type being annotated, not the Annotated class. I made a dirty typing_extensions pull request[1] that attempts to rectify this but I’m not sure i’ll be able to finish it myself right now. like this?
def fun(x: List[Annotated[int, ‘some marker’]])
Best, Jakub
[1] https://github.com/python/typing/pull/634 _______________________________________________ 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/
PS. Apologies for ignoring your question regarding hypothetical get_extras function Till – I don’t have an opinion on it at the moment, doing things “manually” is fine for my purposes.
Jakub
Cool, the code from your pull request works for me. I don’t think I have any other concernes or questions.
Jakub
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him/his **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>