-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
E402 currently allows sys.path and os.environ modifications before imports. I'd like to propose adding warnings.filterwarnings() (and related warning module functions) to this exception list.
Rationale:
- It's a common pattern to filter warnings before importing modules that emit warnings during import
- Like
sys.pathmodifications, warning filters affect import-time behavior - Currently requires verbose
# noqa: E402comments on every subsequent import
Example:
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import some_module # Currently triggers E402Proposed: Treat warnings.filterwarnings(), warnings.simplefilter(), and warnings.resetwarnings() the same as sys.path modifications.
Metadata
Metadata
Assignees
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule