-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
Currently we have this behaviour:
from collections.abc import ( # Y057 flagged on this line for the forbidden ByteString import
AsyncIterator,
Awaitable,
ByteString,
Collection,
Container,
MutableMapping,
MutableSequence,
)
It would be nice if we could have this behaviour instead, where import-related errors were flagged on the line where the import actually occurs when it's part of a multiline import statement:
from collections.abc import (
AsyncIterator,
Awaitable,
ByteString, # Y057 flagged on this line for the forbidden ByteString import
Collection,
Container,
MutableMapping,
MutableSequence,
)
As discussed in #411, however, this is pretty hard to do on Python <3.10 due to the fact that ast.alias
nodes only have lineno
and col_offset
attributes on 3.10+. And while we still support Python <3.10, it's good to consistently flag errors on the same line regardless of the Python version being used. So this can't be addressed for now.
Once we drop support for Python 3.9, however, we should change our behaviour to use the more precise line numbers from the ast.alias
nodes.
tomasr8