Skip to content
Advertisement

Unexpected indentation when return in python

when I try to return but I got an error in 2nd return signup_result & return login_result https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUndefinedVariable

JavaScript

here is utils.py

JavaScript

I also try to tab 2 times to avoid indentation error in return signup_result & return login_result but still got the same error Unexpected indentationPylance

Advertisement

Answer

JavaScript

The cognito_login() function contains only one line of code return login_result because that is the only code that is indented underneath the function.

The rest of the following code is not indented underneath the function, therefore it is not part of the function.

Indentation is very important in Python.

Your code should likely be formatted as follows:

JavaScript
Advertisement