Skip to content

Unused submodule imports are left if the top level module is used #282

Description

@Anthchirp
from __future__ import annotations

import os
import os.path

print(os)

running autoflake 2.2.1 with
--in-place --remove-all-unused-imports --expand-star-imports --remove-duplicate-keys --remove-unused-variables

Expected result:

from __future__ import annotations

import os

print(os)

Actual result:

from __future__ import annotations

import os
import os.path

print(os)

With removed print(os) this works as expected - both imports are removed.
Giving the import its own symbol (ie. import os.path as op) also works as expected, and the line is removed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions