Description
This is being reported in response to an issue with pylint: pylint-dev/pylint#4431
This issue may also be related to:
See #109
See #421
Steps to reproduce
- Declare a named tuple using kwargs syntax:
Point = NamedTuple("Point", x=float, y=float)
- Try to create an instance of this type:
p = Point(1, 2)
The kwargs behavior is noted since 3.5 in the source code for CPython here:
https://github.com/python/cpython/blob/3.5/Lib/typing.py#L2176-L2213
Current behavior
astroid will not identify Point
as callable.
This causes pylint to report a not-callable
error for the application of Point
.
Expected behavior
The Point
type from the Steps to reproduce should be identified as a callable object.
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output
2.8.5
Visible in current version:
The number of expected node.args
is exactly 2 - one for the name of the named tuple type and one for the list of members. This line will probably have to be replaced with something like len(node.args) >= 2
or further examine ast for list of tuples vs kwargs syntax.