Python Forum
Pylint/pyflakes/flake8 missed AttributeError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pylint/pyflakes/flake8 missed AttributeError
#1
Hi,
I have the code
class MainC:
    def __init__(self):
        self.arg1 = None

# Method One, Not working
OBJ_LIST = {}
for i in range(10):
    OBJ_LIST[i] = MainC()

for i in range(10):
    print(OBJ_LIST[i].arg2)  # There is a error here

# Method Two, Also not working
OBJ_LIST = []
for i in range(10):
    OBJ_LIST.append(MainC())

for i in range(10):
    print(OBJ_LIST[i].arg2)  # There is a error here
While I am running pylint/pyflakes/flake8 I don't get any error about attribute error.
What can I do to find that error without running the code

Thanks,
Yoni
Reply
#2
Can you elaborate what exactly you want to achieve?
You designate lines 5-11 as Method1 and lines 13-19 as Method2, but actually that is where the error is.

The generic answer would be that to find errors in the code one would write tests
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
This code is just an example, I want to catch the attribute error while I am writing the code.
I look like if I run a on list of the Objects and use the one of attribute it not verified if it belong to the class
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pySerial - missed messages q_nerk 2 1,720 Jan-27-2022, 09:59 PM
Last Post: Jeff_t
  Pylint more Fast leandrogmuller 2 2,164 Oct-20-2020, 05:21 PM
Last Post: leandrogmuller
  pylint not recognizing some objects in VS Code marceloreborn 1 1,765 Jul-31-2020, 01:36 AM
Last Post: Larz60+
  pylint question dcollett 0 1,521 Mar-26-2020, 08:49 PM
Last Post: dcollett
  Pylint Statment Count Shangeetha 1 2,009 Dec-22-2019, 04:58 PM
Last Post: Larz60+
  pylint & #! pileofrogs 1 2,105 May-23-2019, 01:58 PM
Last Post: heiner55
  redefinition of a method in a class: pylint warning kboo 1 4,215 Feb-13-2018, 11:21 AM
Last Post: buran
  pyflakes vs flake8 broutray 3 7,795 Jun-02-2017, 07:54 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020