Skip to content

fix(sdk): correct Run.__exit__ type annotations to accept None#11100

Merged
timoffex merged 1 commit intowandb:mainfrom
moldhouse:fix-run-exit-type-annotation
Dec 22, 2025
Merged

fix(sdk): correct Run.__exit__ type annotations to accept None#11100
timoffex merged 1 commit intowandb:mainfrom
moldhouse:fix-run-exit-type-annotation

Conversation

@moldhouse
Copy link
Copy Markdown
Contributor

The __exit__ method receives None for all three arguments when no exception is raised, but the type annotations didn't allow for this.

🤖 Generated with Claude Code

This issue was initially picked up by ty with the following error:

error[invalid-context-manager]: Object of type `Run` cannot be used with `with` because it does not correctly implement `__exit__`
   |
20 |     with wandb.init(project="project", entity="entity", name=run_name) as wandb_run:
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
info: rule `invalid-context-manager` is enabled by default

The `__exit__` method receives `None` for all three arguments when no
exception is raised, but the type annotations didn't allow for this.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@moldhouse moldhouse requested a review from a team as a code owner December 22, 2025 12:23
@timoffex timoffex merged commit 652b68f into wandb:main Dec 22, 2025
3 checks passed
@timoffex
Copy link
Copy Markdown
Contributor

Thank you for the contribution!

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