currently I'm working on a Python project in PyCharm and often get the warning "Shadows name 'foo' from outer scope", e.g. in this minimal example:
def print_foo(foo):
print(foo)
foo = "Hello"
print_foo(foo)
I understand the sense behind this, but since I like to have a green check mark in the top right corner, I could rewrite the script like this to stop getting the warnings:
def print_foo(foo):
print(foo)
def main():
foo = "Hello"
print_foo
main()
However, I mostly run the script via Alt-Shift-E in the console and unfortunately, due to the code change, I can no longer access the variables, since they are now in the main() function and not in the script directly (if you can put it that way).
Are there any other solutions for this where I no longer get the warnings (without simply suppressing them) and can still access the variables after running the code (preferably all of them of course, but the ones from main() would be enough for me).
Thanks!