Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

typing.NamedTuple and PyCharm

How can I make typing.NamedTuple play nicely with PyCharm?

collections.namedtuple works fine:

import collections
B = collections.namedtuple('B', ['i'])
b = B(1)
b.i

but typing.NamedTuple doesn't:

import typing
A = typing.NamedTuple('A', [('i', int)])
a = A(1)
a. # No suggestions
like image 631
ADR Avatar asked Mar 17 '16 13:03

ADR


2 Answers

You should better direct such questions to the PyCharm bug tracker. Your problem already has an open ticket though.

like image 134
wRAR Avatar answered Sep 27 '22 03:09

wRAR


PyCharm plays very well with the prefered syntax

class A(NamedTuple):
    i: int
like image 30
Wolfgang Kuehn Avatar answered Sep 26 '22 03:09

Wolfgang Kuehn