When viewing the following Python code in PyCharm, PyCharm will report a helpful warning Name 'x' may be undefined:
condition = False
if condition:
x = "foo"
print(x)
And with this code, PyCharm will report Local variable 'x' might be referenced before assignment:
def func():
condition = False
if condition:
x = "foo"
print(x)
Performing linting checks with pylint (2.6.0) and flake8 (3.8.3) won't report any errors on this code.
However detecting this problem in CI can prevent serious bugs hitting production.
How can I detect this problem without PyCharm (or PyCharm inspect.sh), are there any plugins available for flake8/pylint I'm missing?