cycle not detected
- Lingua principale
- Python
- Stelle
- 363
- Fork
- 24
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
A rather primitive module cycle is not detected. Minimal working example:
```
reproduction
├── __init__.py
├── moduleA
│ ├── __init__.py
│ └── a_class.py
└── moduleB
├── __init__.py
└── b_class.py
```
`reproduction > moduleA > __init__.py`:
```python
from .a_class import ClassA
```
`reproduction > moduleA > a_class.py`:
```python
import reproduction.moduleB
class ClassA:
pass
```
`reproduction > moduleB > __init__.py`:
```python
from .b_class import ClassB
```
`reproduction > moduleB > b_class.py`:
```python
from ..moduleA import ClassA
class ClassB:
pass
```
When running pycycle:
```console
> pycycle --here --verbose
Trying to parse file: /private/tmp/reproduction/reproduction/__init__.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleB/__init__.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleB/b_class.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleA/a_class.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleA/__init__.py
Project successfully transformed to AST, checking imports for cycles..
No worries, no cycles here!
If you think some cycle was missed, please open an Issue on Github.
Finished.
```
when trying to import moduleA:
```console
> python3 -c 'import reproduction.moduleA'
Traceback (most recent call last):
File "", line 1, in
File "/private/tmp/reproduction/reproduction/moduleA/__init__.py", line 1, in
from .a_class import ClassA
File "/private/tmp/reproduction/reproduction/moduleA/a_class.py", line 1, in
import reproduction.moduleB
File "/private/tmp/reproduction/reproduction/moduleB/__init__.py", line 1, in
from .b_class import ClassB
File "/private/tmp/reproduction/reproduction/moduleB/b_class.py", line 1, in
from ..moduleA import ClassA
ImportError: cannot import name 'ClassA' from partially initialized module 'reproduction.moduleA' (most likely due to a circular import) (/private/tmp/reproduction/reproduction/moduleA/__init__.py)
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.