FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Signature for `unittest.mock.mock_open` incomplete · Issue #15856 · python/typeshed · GitHub

Repository navigation

Signature for unittest.mock.mock_open incomplete #15856

Closed as not planned
Closed as not planned

Description

After upgrading types-mock to 5.2, pyright is now reporting errors for the signature of mock_open.

My investigation indicates that this is due to #14063.

Reproducer on my local machine:

┬─[enno@framework-enno:/t/types-mock-issue]─[12:22:51]─[V:.venv]
╰─>$ cat test.py 
# pyright: strict

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from pytest_mock import MockerFixture

def test_example(mocker: "MockerFixture"):
    mock_open = mocker.patch("builtins.open", mocker.mock_open())

pytest_mock was chosen as a reproducer because it was the easiest for me. I don't think it is at fault here because of the following call chain:

https://github.com/pytest-dev/pytest-mock/blob/6c558e64867781f2250569adabaada68dd5e4384/src/pytest_mock/plugin.py#L80-L104

https://github.com/pytest-dev/pytest-mock/blob/9025232b574db9ce9acfafb3166361170bd69afd/src/pytest_mock/_util.py#L6-L26

I am aware of the following comment, but having broken type annotations in the standard library seems a bit excessive to me: #14029 (comment)

Activity

  1. srittau commented on Jun 2, 2026

    Collaborator

    Please note that this is a problem in the third-party stubs for mock, not the standard library, which has "fully" annotated (although probably incorrectly):

    def mock_open(mock: Any | None = None, read_data: Any = "") -> Any: ...

    That said, incomplete stubs are expected in typeshed, and we don't keep issues about this open, although we value any contribution to complete our stubs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL