Skip to content

PEP-646 tuple unpacking does not interpret tuple as a fixed set of arguments #19030

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

Closed
terencehonles opened this issue May 5, 2025 · 1 comment
Labels
bug mypy got something wrong

Comments

@terencehonles
Copy link
Contributor

Bug Report

PEP-646 tuple unpacking does not interpret tuple as a fixed set of arguments.

To Reproduce

import sys
from _typeshed import ExcInfo

def hook(*exc_info: *ExcInfo) -> None:
    pass

reveal_type(hook)
sys.excepthook = hook

https://mypy-play.net/?mypy=master&python=3.12&gist=f9cacc6d3b30cfbb925d8c72bd8a4617

Expected Behavior

No error as hook takes one exception tuple.

Actual Behavior

main.py:7: note: Revealed type is "def (*exc_info: Unpack[tuple[type[builtins.BaseException], builtins.BaseException, types.TracebackType]])"
main.py:8: error: Incompatible types in assignment (expression has type "Callable[[VarArg(*tuple[type[BaseException], BaseException, TracebackType])], None]", variable has type "Callable[[type[BaseException], BaseException, TracebackType | None], Any]")  [assignment]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: master
  • Mypy command-line flags: default
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.12
@terencehonles terencehonles added the bug mypy got something wrong label May 5, 2025
@terencehonles
Copy link
Contributor Author

I didn't notice that the traceback type appears to be optional on typeshed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant