In general remove_redundent_aliases is a nice setting, and it makes sense to have it enabled across a large code base in general.
However, type checkers use redundant module or redundant symbol aliases (see second bullet point) to communicate information about whether a symbol should be considered private or public by the type checker. This feature is quite convenient, because it can avoid having to double-maintain the good old __all__ list.
This means that turning off remove_redundent_aliases is valuable for package-level __init__.py that deal with symbol forwarding to the outside. But turning of remove_redundent_aliases globally just for the usages in __init__.py's would allow truely redundant aliases to sneak in where they aren't meaningful. Alternatively, using # isort: off ... # isort: on wrapping fails to leverage isort for the its main purpose of sorting all the imports. So for a large __init__.py turning off isort entirely is also not ideal.
For these reasons it would be great if the redundant alias feature could be turned off locally via an action, e.g.:
# isort: remove-redundent-aliases-off
from . import PublicThingA as PublicThingA
from . import PublicThingB as PublicThingB
from . import PrivateThing
# isort: remove-redundent-aliases-on
In general
remove_redundent_aliases
is a nice setting, and it makes sense to have it enabled across a large code base in general.However, type checkers use redundant module or redundant symbol aliases (see second bullet point) to communicate information about whether a symbol should be considered private or public by the type checker. This feature is quite convenient, because it can avoid having to double-maintain the good old
__all__
list.This means that turning off
remove_redundent_aliases
is valuable for package-level__init__.py
that deal with symbol forwarding to the outside. But turning ofremove_redundent_aliases
globally just for the usages in__init__.py
's would allow truely redundant aliases to sneak in where they aren't meaningful. Alternatively, using# isort: off
...# isort: on
wrapping fails to leverage isort for the its main purpose of sorting all the imports. So for a large__init__.py
turning off isort entirely is also not ideal.For these reasons it would be great if the redundant alias feature could be turned off locally via an action, e.g.: