Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

492
Visualizações
pylint not-an-iterable error when subclassing List[int]

Code example:

from typing import List

class MyList(List[int]):
    def total(self) -> int:
        return sum(i for i in self)

a = MyList([1,2,3])
print(f'{a.total()=:}')

When I run it, it works

a.total()=6

But when I use pylint, I get the following error

...
toy.py:5:30: E1133: Non-iterable value self is used in an iterating context (not-an-iterable)
...

There are other pylint errors, but they're understandable. For the not-an-iterable problem, I don't quite understand it, am I subclassing List[int], correctly?

I'm using Python-3.8, pylint==2.6.0

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I upgraded pylint to a more recent version.

pylint --version    
pylint 2.9.6
astroid 2.6.6
Python 3.8.2 (default, Mar 15 2021, 10:18:42) 

and the error is gone.

Due to system constraints, I can't upgrade to the very latest version.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda