New submission from Noah May <noahmouse2...@gmail.com>:

Whether this is considered a bug or not is subjective. The question is should 
callable(Tuple) return True or False? Or should it for any other annotation 
object?

The reason it returns true in the first place is because of a warning to 
explicitly NOT call them as functions/constructors:

>>> from typing import Tuple
>>> callable(Tuple)
True
>>> Tuple()
TypeError: Type Tuple cannot be instantiated; use tuple() instead

Source code: 
https://github.com/python/cpython/blob/master/Lib/typing.py#L724:L733

I honestly don't know how this could be "fixed" if it even needs to be fixed. 
But I just wanted to bring attention to it.

Cheers.

----------
components: Library (Lib)
messages: 366580
nosy: Noah May
priority: normal
severity: normal
status: open
title: Type annotation objects (Tuple, List, etc.) register as callable()
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40298>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to