pbryan@dynamo:~$ python3
Python 3.8.6 (default, Sep 30 2020, 04:00:38)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import annotations
>>> def fn(*argv: Any) -> Any:
... ...
...
>>> from typing import get_type_hints
>>> get_type_hints(fn)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/typing.py", line 1264, in get_type_hints
value = _eval_type(value, globalns, localns)
File "/usr/lib/python3.8/typing.py", line 270, in _eval_type
return t._evaluate(globalns, localns)
File "/usr/lib/python3.8/typing.py", line 518, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
NameError: name 'Any' is not defined
>>>
On Mon, 2020-11-30 at 06:10 +0000, Steve Barnes wrote:
> Any only works as an annotation:
>
> In [3]: def fn(*argv: Any) -> Any:
> ...: return argv[0]
> ...:
>
>
> From: Paul Bryan <[email protected]>
> Sent: 30 November 2020 05:55
> To: Inada Naoki <[email protected]>; Abdulla Al Kathiri
> <[email protected]>
> Cc: python-ideas <[email protected]>
> Subject: [Python-ideas] Re: Making "Any" a builtin
>
> pbryan@dynamo:~$ python3
> Python 3.8.6 (default, Sep 30 2020, 04:00:38)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more
> information.
> >>> from __future__ import annotations
> >>> Any
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'Any' is not defined
> >>>
>
> On Mon, 2020-11-30 at 14:43 +0900, Inada Naoki wrote:
> > Since Python 3.10, you can use "Any" without "from typing import
> > Any".
> > You can do it in Python 3.7 by "from __future__ import annotations"
> > too.
> >
> > See https://www.python.org/dev/peps/pep-0563/
> >
> > Regards,
> >
> > On Mon, Nov 30, 2020 at 12:29 AM Abdulla Al Kathiri
> > <[email protected]> wrote:
> > >
> > > Instead of importing “Any" from the typing module, we can
> > > annotate our functions with “Any" right away without the extra
> > > step. What do you think? We have the builtin function “any” which
> > > some Python users could mistakingly use, but static type checkers
> > > should catch that.
> > > _______________________________________________
> > > Python-ideas mailing list -- [email protected]
> > > To unsubscribe send an email to [email protected]
> > > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > > Message archived at
> > >
> https://mail.python.org/archives/list/[email protected]/message/ELI474TKP2OKHP4NW5HOVUPKDPLYE2JP/
> > > Code of Conduct: http://python.org/psf/codeofconduct/
> >
> >
> >
> > --
> > Inada Naoki <[email protected]>
> > _______________________________________________
> > Python-ideas mailing list -- [email protected]
> > To unsubscribe send an email to [email protected]
> > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > Message archived at
> >
> https://mail.python.org/archives/list/[email protected]/message/VENGRL6T54XQUYDXONZRZE7LUCO6MKWI/
> > Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2G2FE3ZKCPIF7QO6XUCUMYP5LWPGOPPY/
Code of Conduct: http://python.org/psf/codeofconduct/