Skip to content

PEP 593 Annotated containing string literal is marked incorrect #9868

Closed
@Richardk2n

Description

@Richardk2n

Bug Report

Annotated as descirbed by PEP 593 should work according to #7021 but does not if the Annotated is annotating a function parameter and contains a string literal, that is not itself a function parameter. Se examples below.

To Reproduce

a: Annotated[str, "metadata"] is fine
def f(a: Annotated[str, str("metadata")]): is also fine
def f(a: Annotated[str, "metadata"]): gives Name 'metadata' is not defined

Expected Behavior

All thre examples should be valid

Actual Behavior

They are not.

Your Environment

  • Mypy version used:master branch as of time of writing
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used:3.9.1
  • Operating system and version:Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions