1

I am trying to declare tokens with unique value in python:

from enum import (
  auto,
  Enum,
  unique
)

from typing import NamedTuple

@unique
class TokenType(Enum):
  ASSIGN = auto()
  COMMA = auto()
  EOF = auto()
  FUNCTION = auto()
  IDENT = auto()
  ILLEGAL = auto()
  INT = auto()
  LBRACE = auto()
  LET = auto()
  LPAREN = auto()
  PLUS = auto()
  RBRACE = auto()
  RPAREN = auto()
  SEMICOLON = auto()

class Token(NamedTuple):
  token_type: TokenType
  literal: str

  def __str__(self) -> str:
    return f'Type: {self.token_type}, Literal: {self.literal}'

but I am getting this pylint error:

Inheriting 'NamedTuple', which is not a class.pylint(inherit-non-class)

martineau
  • 119,623
  • 25
  • 170
  • 301
Diesan Romero
  • 1,292
  • 4
  • 20
  • 45

1 Answers1

2

As stated in the comments:

This is an open issue in Pylint: https://github.com/PyCQA/pylint/issues/3876

The issue was fixed in the upstream project astroid. I could fix this problem by upgrading:

pip install astroid==2.5
djbrown
  • 58
  • 1
  • 6