Skip to content

mypy suggests deprecated code #16815

@clo-vis

Description

@clo-vis

To Reproduce

def function(arg: Callable[[], Iterable[int]]) -> Set[int]: return set()

Expected Behavior
error: Name "Callable" is not defined [name-defined]
error: Name "Iterable" is not defined [name-defined]
error: Name "Set" is not defined [name-defined]
and perhaps something like
(for Callable) note: Did you forget to import it from from "collections.abc"? (Suggestion: "from collections.abc import Callable")
(for Iterable) note: Did you forget to import it from from "collections.abc"? (Suggestion: "from collections.abc import Iterable")
(for Set) note: Use set[int] if the set is mutable or import Set from collections.abc if the set is immutable: "from collections.abc import Set"

Actual Behavior

error: Name "Callable" is not defined  [name-defined]
note: Did you forget to import it from "typing"? (Suggestion: "from typing import Callable")
error: Name "Iterable" is not defined  [name-defined]
note: Did you forget to import it from "typing"? (Suggestion: "from typing import Iterable")
error: Name "Set" is not defined  [name-defined]
note: Did you forget to import it from "typing"? (Suggestion: "from typing import Set")

typing.Callable, typing.Iterable, and typing.Set were all deprecated (python 3.9+)

Your Environment

  • Mypy version used: 1.8.0 (compiled: yes)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-585PEP 585 (builtin generics)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions