Skip to content

Type hinting example from 3.9.0 docs don't work (v0.79) #9740

Closed
@tekinozbek

Description

@tekinozbek

The following example from the 3.9.0 type hinting docs:
Vector = list[float]
makes mypy complain that:
"list" is not subscriptable, use "typing.List" instead

This differs from 3.8 docs in that they actually use typing.List instead. Is this a doc issue or a mypy issue?

I am aware that I can use typing.List for this case, but if there's an option to not include a module, I would rather take that option.

To Reproduce

  1. Create a Python file with the content above
  2. Run through mypy
  3. Observe that it complains about how "list is not subscriptable" and that I should use typing.List instead

Expected Behavior

I expect it to not complain.

Actual Behavior

It complains.

Your Environment

VSCode with mypy as linter.

  • Mypy version used: 0.79
  • Python version used: 3.9
  • Operating system and version: Win10

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