pylint-dev / pylint-dev/astroid

Support namedtuple's getitem

Open
#182 0 comments 0 reactions 0 assignees View on GitHub
Bug 🪳 T: NamedTuple
Dominant language
Python
Stars
582
Forks
357
Avg merge
1d 1h
Merged PRs (30d)
23

Description

Originally reported by: **Claudiu Popa (BitBucket: [PCManticore](http://bitbucket.org/PCManticore), GitHub: @PCManticore)**

---

We should detect namedtuple's indexing, as it is the case for this example:

```
#!python

from collections import namedtuple
f = namedtuple('a', 'a b')
c = f(1, 2)
print(c[0].lala)
```

---
- Bitbucket: https://bitbucket.org/logilab/astroid/issue/182

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the supplied namedtuple example and trace how astroid infers c[0]. The issue names no files or tests, so first locate the namedtuple and getitem inference entry points, then add coverage showing that c[0].lala is understood as access to the namedtuple field.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.