Skip to content

MyPy treats Placeholder as _PlaceholderType #21313

@StuartBertram

Description

@StuartBertram

Bug Report

Python 3.14 introduced functools.Placeholder so that you can create functions with partial() that choose which position arguments are filled in and which are passed through. However, MyPy rejects the typing of these values.

To Reproduce

From the docs

from functools import partial, Placeholder as _
remove = partial(str.replace, _, _, '')

Expected Behavior

MyPy recognises remove as partial function that takes two strings (the placeholders), accepts the placeholders as being placeholders for string variables, and the checks pass.

Actual Behavior

example.py:2: error: Argument 1 to "replace" of "str" has incompatible type "_PlaceholderType"; expected "str"  [arg-type]
example.py:2: error: Argument 2 to "replace" of "str" has incompatible type "_PlaceholderType"; expected "str"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.19.1
  • Mypy command-line flags: mypy example.py
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.14

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