- Ouro version: 0.2.0
- Python version: 3.12
- Operating System: Ubuntu
Description
First of all, thanks for the great tool!
One strategy to avoid circular imports that I personally use when there is no alternative is to have some imports within function definitions (Python caches the imported modules, so this is quite fast for functions that run rarely). In this case, i would prefer if Ouro only created a warning/no issue.
I think this can be done by preventing the AST walker from entering function definitions.
What I Did
This is a simplified scenario for replicability.
# A.py
def foo1(n):
from B import foo2
print("We are in foo1")
if n > 1:
foo2(n-1)
# B.py
from A import foo1
def foo2(n):
print("We are in foo2")
if n>0:
foo1(n-1)
foo2(5)
And in action (forgive the typo in the project name and the lack of __main__ guards to run properly):

Description
First of all, thanks for the great tool!
One strategy to avoid circular imports that I personally use when there is no alternative is to have some imports within function definitions (Python caches the imported modules, so this is quite fast for functions that run rarely). In this case, i would prefer if Ouro only created a warning/no issue.
I think this can be done by preventing the AST walker from entering function definitions.
What I Did
This is a simplified scenario for replicability.
And in action (forgive the typo in the project name and the lack of
__main__guards to run properly):