[New-bugs-announce] [issue40298] Type annotation objects (Tuple, List, etc.) register as callable()

Noah May report at bugs.python.org
Thu Apr 16 03:27:17 EDT 2020


New submission from Noah May <noahmouse2011 at 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 <report at bugs.python.org>
<https://bugs.python.org/issue40298>
_______________________________________


More information about the New-bugs-announce mailing list