Ignoring noqa lines #4703
-
When writing scripts to interact with django it's quite common to import django and call it's setup function in one line. Typically the top of a file looks like this: #!/usr/bin/env python
import argparse
import sys
import time
import django; django.setup() # noqa
from django.conf import settings Ruff reports a "Module level import not at top of file Ruff (E402)" for the line Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unfortunately no, there isn't a way to tell Ruff to ignore a line for the purpose of determining the "start-of-file" import boundary. The best you can do, I think, is turn off import argparse
import sys
import time
# ruff: noqa: E402
import django; django.setup()
from django.conf import settings |
Beta Was this translation helpful? Give feedback.
Unfortunately no, there isn't a way to tell Ruff to ignore a line for the purpose of determining the "start-of-file" import boundary.
The best you can do, I think, is turn off
E402
for that module, like: