Pergunta

I git cloned autopep8 (https://github.com/hhatto/autopep8/) but it depends on pep8 (https://github.com/jcrocholl/pep8) so I cloned that [pep8] too inside the autopep8 directory. Then I created a init.py with the contents "from pep8 import *" inside pep8 directory. Then I made sure I could import pep8 inside the autopep8 directory and that worked. However when I try to import autopep8 inside the autopep8 directory I get:

>>> import autopep8
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "autopep8.py", line 328, in <module>
    del pep8._checks['logical_line'][pep8.continued_indentation]
AttributeError: 'module' object has no attribute '_checks'

Any solution to this?

EDIT:

I found the solution. The init.py also needs to be:

from pep8 import *
from pep8 import _checks
Foi útil?

Solução

I was creating a python module out of pep8 and autopep8 in this example with a pep8 folder inside of an autopep8 folder, which in turn was inside of the root folder. I created __init__.py files in both pep8 and autopep8.

The contents were:

autopep8/__init__.py :

from autopep8 import *

pep8/__init__.py :

from pep8 import *

pep8/__init__.py had to be corrected to

from pep8 import *
from pep8 import _checks
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top