Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PEP 593 Annotated containing string literal is marked incorrect #9868

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

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

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions