Skip to content

typing.Literal can cause false-positive import #213

@Jasha10

Description

@Jasha10

Hello,

Unfortunately I have a bug to report. I'm getting a false-positive import with certain typing.Literal usage.

before running autoimport:

from typing import Literal as L

var: L["* time"] = "* time"

after running autoimport:

from typing import Literal as L
import time

var: L["* time"] = "* time"

Importing the library time is not correct.

Context:

This bug came up when using the nptyping library, which encourages liberal use of Literal.

Environment:

$ python -c "import autoimport.version; print(autoimport.version.version_info())"
           autoimport version: 1.2.2
               python version: 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:39:04) [GCC 10.3.0]
                     platform: Linux-5.13.0-35-generic-x86_64-with-glibc2.31

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions