0

Hello I'm trying to import routes to init.py and I'm keep getting circular import error because probably formatter moves up my import statement and I'm wondering what can I do with it my code should look like this

from flask import Flask
app = Flask(__name__)
from .config import Config
app.config.from_object(Config)
from app import routes

But because of this "bug" I'm getting this

from app import routes
from .config import Config
from flask import Flask
app = Flask(__name__)

app.config.from_object(Config)

When I removed formatter code stays good but I want to have formatter

Ciastelix
  • 17
  • 5

1 Answers1

0

I tried autopep8, black and yapf, only autopep8 has this problem.

I have checked the official docs of autopep8, but I can't find any configuration that can disable it.

So, switch to black or yapf?

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • I think yapf would be the best – Ciastelix May 28 '21 at 18:32
  • Having this in the settings prevents imports move: "python.formatting.autopep8Args": ["--ignore","E402"] https://stackoverflow.com/questions/54015604/disable-python-import-sorting-in-vscode – Marcos May 06 '22 at 20:21