Any only works as an annotation:

 

In [3]: def fn(*argv: Any) -> Any:

   ...:     return argv[0]

   ...:

 

 

From: Paul Bryan <pbryan@anode.ca>
Sent: 30 November 2020 05:55
To: Inada Naoki <songofacandy@gmail.com>; Abdulla Al Kathiri <alkathiri.abdulla@gmail.com>
Cc: python-ideas <python-ideas@python.org>
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

<alkathiri.abdulla@gmail.com> 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 -- python-ideas@python.org

To unsubscribe send an email to python-ideas-leave@python.org

https://mail.python.org/mailman3/lists/python-ideas.python.org/

Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ELI474TKP2OKHP4NW5HOVUPKDPLYE2JP/

Code of Conduct: http://python.org/psf/codeofconduct/

 

 

 

--

Inada Naoki  <songofacandy@gmail.com>

_______________________________________________

Python-ideas mailing list -- python-ideas@python.org

To unsubscribe send an email to python-ideas-leave@python.org

https://mail.python.org/mailman3/lists/python-ideas.python.org/

Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VENGRL6T54XQUYDXONZRZE7LUCO6MKWI/

Code of Conduct: http://python.org/psf/codeofconduct/