Skip to content

Instantly share code, notes, and snippets.

@imbolc
Last active March 12, 2020 09:41
Show Gist options
  • Save imbolc/e47632323cd53f4c26514864ecc38460 to your computer and use it in GitHub Desktop.
Save imbolc/e47632323cd53f4c26514864ecc38460 to your computer and use it in GitHub Desktop.

Flake8 complains with 4:5: F401 'pydantic' imported but unused about this code:

from typing import TYPE_CHECKING, Optional, Type

if TYPE_CHECKING:
    import pydantic

def f(*, model: Optional[Type["pydantic.BaseModel"]] = None):
    pass

While it's ok with the whole type wrapped into quotes:

def f(*, model: "Optional[Type[pydantic.BaseModel]]" = None):
    pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment