python / python/mypy

MyPy treats `Placeholder` as `_PlaceholderType`

Open
#21,313 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-plugins
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the mypy example.py reproduction from the issue with Python 3.14 and inspect how functools.Placeholder is typed and handled by partial-function analysis. Done means the example accepts both placeholders as string positions without the reported arg-type errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.