Skip to content

Missing exception for module-import-not-at-top-of-file-e402 #15886

@janosh

Description

@janosh

Description

the following two codes are practically equivalent but the 2nd one gets a E402 error in ruff v0.9.4

import os
import sys

sys.path.append(os.path.dirname(__file__))  # sys.path.append gets special exception when appearing above imports

from package import module
import os
import sys

sys.path += [os.path.dirname(__file__)] # get E402 here

from package import module

i think the bottom code should be treated same as the top, i.e. not raise an error

Metadata

Metadata

Assignees

Labels

help wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions