Skip to content

Function accepts callable, but a typeshed custom Protocol was passed #13480

@Andrew-Chen-Wang

Description

@Andrew-Chen-Wang

Bug Report

(A clear and concise description of what the bug is.)

To Reproduce

I have some code like:

await asyncio.to_thread(
    shutil.rmtree, connector_folder, ignore_errors=False, onerror=None
)

But I'm getting mypy errors like

Argument 1 to "to_thread" has incompatible type "_RmtreeType"; expected "Callable[[Path, bool, None], None]"  [arg-type]

Expected Behavior

I would assume this is fine this callable is fine and this is passing.

Actual Behavior

Argument 1 to "to_thread" has incompatible type "_RmtreeType"; expected "Callable[[Path, bool, None], None]"  [arg-type]

Your Environment

  • Mypy version used: 1.11.0
  • Mypy command-line flags: pointing to pyproject.toml config
  • Mypy configuration options from mypy.ini (and other config files): ignore_missing_imports = true
  • Python version used: 3.12

I do NOT have Typeshed installed in my pip list, but I saw in typeshed that it may be bundled with mypy? Again I don't see it installed, but curious to know why this wouldn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions