Skip to content

Update typing in Run's __exit__ to match what Python expects#933

Merged
kzscisoft merged 1 commit intodevfrom
james/tweak_exit_typing
Mar 23, 2026
Merged

Update typing in Run's __exit__ to match what Python expects#933
kzscisoft merged 1 commit intodevfrom
james/tweak_exit_typing

Conversation

@james-panayis
Copy link
Collaborator

@james-panayis james-panayis commented Mar 23, 2026

Tweak typing in Run's __exit__ to satisfy typeshed

Python Version(s) Tested: 3.13

Operating System(s): Ubuntu 25.10

📝 Summary

This tweaks the typing of Run's __exit__ function to make it match the typing expected by type-checkers and typeshed, as specifiec eg here: https://github.com/python/typeshed/blob/222da0600fbea86bbc5b3f8c98c24d7ef1ed5187/stdlib/contextlib.pyi#L52

🔍 Diagnosis

This issue was found after enabling some extra type-checking on the optSim code (where ty complained that Run was not a valid context manager).

🔄 Changes

Fixes an error that occurs when running mypy on the code:

error: Argument 3 to "format_exception" has incompatible type "type[BaseException] | BaseException | None"; expected "TracebackType | None" [arg-type]

✔️ Checklist

  • Unit and integration tests passing.
  • Pre-commit hooks passing.
  • Quality checks passing.

@james-panayis james-panayis requested a review from kzscisoft March 23, 2026 08:39
@kzscisoft kzscisoft merged commit c010679 into dev Mar 23, 2026
22 checks passed
@kzscisoft kzscisoft deleted the james/tweak_exit_typing branch March 23, 2026 09:47
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