pylint-dev / pylint-dev/astroid

Our understanding of typing.NamedTuple is lossy

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

Description

It seems we can do a much better job over here:

- our current transform is losing the type of the arguments

- we should support typing.NamedTuple subclasses. I just added a basic support for it, but I don't feel it is enough, since we could store the types as well.

- it also seems that NamedTuple can have default values for its attributes

https://docs.python.org/3/library/typing.html#typing.NamedTuple

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing transform for typing.NamedTuple and read the linked Python documentation for subclass, field-type, and default-value behavior. Trace how the current transform represents arguments and attributes. Done means NamedTuple subclasses retain argument types and attribute defaults without losing information.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.