Skip to content

Improve unittest.mock stubs #14421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 22, 2025
Merged

Improve unittest.mock stubs #14421

merged 6 commits into from
Aug 22, 2025

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Jul 16, 2025

  • Mark _patcher and _patch_pass_arg as @type_check_only.
  • Add patch() default arguments.
  • Forbid certain argument combinations for patch().
  • Reorder patch() overloads.
  • Add unsafe argument.
  • Add overloads for path.multiple().

* Mark `_patcher` and `_patch_pass_arg` as `@type_check_only`.
* Add `patch()` default arguments.
* Forbid certain argument combinations for `patch()`.
* Reorder `patch()` overloads.
* Add `unsafe` argument.
* Add overloads for `path.multiple()`.
@srittau
Copy link
Collaborator Author

srittau commented Jul 16, 2025

We also need to replace many instances of Any with Incomplete.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@JelleZijlstra
Copy link
Member

This has a merge conflict now, could you take a look?

@srittau srittau closed this Aug 22, 2025
@srittau srittau reopened this Aug 22, 2025
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/hybrid.py:834: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command"  [misc]
+ discord/ext/commands/hybrid.py:834: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name"  [misc]
- discord/ext/commands/hybrid.py:858: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command"  [misc]
+ discord/ext/commands/hybrid.py:858: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name"  [misc]
- discord/ext/commands/hybrid.py:883: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command"  [misc]
+ discord/ext/commands/hybrid.py:883: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name"  [misc]
- discord/ext/commands/hybrid.py:935: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command"  [misc]
+ discord/ext/commands/hybrid.py:935: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name"  [misc]
- discord/ext/commands/bot.py:290: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command"  [misc]
+ discord/ext/commands/bot.py:290: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name"  [misc]
- discord/ext/commands/bot.py:314: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command"  [misc]
+ discord/ext/commands/bot.py:314: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name"  [misc]

@srittau srittau merged commit f8773eb into python:main Aug 22, 2025
191 of 221 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants