E402 triggered after sys.path.append #15133
-
Hey there fellows, I have quite a large python project with flask, with a main app (a directory called A with many directories inside). In addition to A, I have several directories that are called Is this intended? If feel like it is a false positive. example:
In nice_script.py I have the following:
but You are much wiser and more experiences people of python, any advice? is it false positive? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 14 replies
-
That Ruff triggers E402 on your example does make sense to me. E402 enforces that all imports are at the top of the file. This isn't the case here because of your path-manipulation statements
Now, if it isn't important to you that imports are at the top, then I suggest to disable |
Beta Was this translation helpful? Give feedback.
Oh nice find. I wasn't aware of this behavior. I had a quick look at the implementation and I suspect the problem is that you have two statements. Can you try inlining
ROOT_DIR
like this