Switching NamedTuple declaration to the preferred declaration for typing NamedTuple
namedtuple
is preferablly done with just declaring everything in one line.
But, if using the typing version NamedTuple
it's preferable to use the class definition as it helps with the readability problem the occurs when adding typing information to a namedtuple.
Source: https://docs.python.org/3/library/typing.html#typing.NamedTuple