Bug Report
To Reproduce
Consider the common pattern of subclassing the output of the namedtuple() function to add extra methods:
from collections import namedtuple
class EmployeeRecord(namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')):
def is_junior():
return self.age < 18
- Save the above code to a file.
- Run
stubgen on it.
Expected Behavior
I would have expected the stubs generated by stubgen to include the namedtuple's fields (name, age, etc.), typed as Any if no type can be inferred.
I expected the output to look something like:
from typing import NamedTuple
class EmployeeRecord(NamedTuple):
name: Any
age: Any
title: Any
department: Any
paygrade: Any
def is_junior(): ...
Actual Behavior
However, the output is instead:
class EmployeeRecord:
def is_junior(): ...
EmployeeRecord doesn't subclass from NamedTuple and doesn't have the expected attributes.
Your Environment
- Mypy version used: 0.790 and 0.800+dev.e9edcb957f341dcf7a14bb7b7acfd4186fb1248b
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini (and other config files): None
- Python version used: Python 3.8.5
- Operating system and version: Ubuntu 20.04
Bug Report
To Reproduce
Consider the common pattern of subclassing the output of the
namedtuple()function to add extra methods:stubgenon it.Expected Behavior
I would have expected the stubs generated by
stubgento include the namedtuple's fields (name, age, etc.), typed asAnyif no type can be inferred.I expected the output to look something like:
Actual Behavior
However, the output is instead:
EmployeeRecorddoesn't subclass from NamedTuple and doesn't have the expected attributes.Your Environment
mypy.ini(and other config files): None