2

I am currently using the default python linter in VSCode. However, the linter (Format Document) keeps changing the importing order of modules like below. Since the module (project_settings.py) is in the parent directory of the current script(preprocess.py), I believe I have to add the system path before importing (following this_01).

Am I not following correct PEP8 rules? (following this_02) How can I import the modules in a different directory while linter not changing the importing order? Do I need to put some kind of ignore rules for the linter?

Inside preprocess.py

(Before Formatter)

import sys
sys.path.insert(0, './scripts/')
from project_settings import *

(After Formatter)

from project_settings import *
import sys
sys.path.insert(0, './scripts/')

Project Structure

root
└── scripts
    ├── data-preparation
    │   └── **preprocess.py**
    ├── ...
    ├── main.py
    ├── project_settings.py
    └── utils.py

p.s. I still want to use the Python linter, but want to use it correctly so that the linter won't change the importing order

Jiho Choi
  • 1,083
  • 1
  • 10
  • 26

1 Answers1

1

I am not really sure this answers your question but you could disable lint on Vscode in the JSON settings.

"[python]": {
    "editor.formatOnPaste": false
}

Edual Feliz
  • 892
  • 6
  • 7