I too was having issues with getting AttributeError: `NoneType` and later on I looked it up and found out what it was. So basically this error occurs when you try to call a method or access an attribute of a variable that is None.
Here are some common causes and how to fix the problem:
def my_function():
print("Doing something")
result = my_function() # result is None
result.some_method() # This will raise an AttributeError
Uninitialized variables: A variable that has not been assigned a value is also None.
my_variable = None
my_variable.some_method() # Raises AttributeError
Logic errors: A condition may not properly assign a variable, leaving it as None.
How to diagnose
Check function return values: Examine your functions to make sure they always return valid values.
Use print statements: Add a print statement before the error line to see what your variables contain.
Debugging tools: Use a debugger to step through your code and see your variable values as it runs.
Check your conditional logic: Make sure all paths through your code properly initialize your variables.