Skip to content

Fix EDF figure type narrowing for mypy - #6906

Merged
c-bata merged 1 commit into
optuna:masterfrom
yen-0:fix-mypy-edf-figure-close
Oct 16, 2026
Merged

c-bata merged 1 commit into
optuna:masterfrom
yen-0:fix-mypy-edf-figure-close

Conversation

@yen-0

@yen-0 yen-0 commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Motivation

To resolve check failure https://github.com/optuna/optuna/actions/runs/38482993742.

Description of the changes

The problem was likely introduced here https://github.com/optuna/optuna/pull/6890/changes#diff-049020facaa2c1f024444a6f8bc72c4e5d6d9b4a0177ed4b038ea409dd68ac0fR156.
figure.figure had Type of [ Figure | SubFigure ], however plt.close() does not except a SubFigure.
Therefore, we explicitly check whether figure.figure is a Figure.

Checklist

  • I used an LLM while working on this PR.

@yen-0 yen-0 added bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. code-fix Change that does not change the behavior, such as code refactoring. and removed bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. labels Oct 14, 2026
@yen-0
yen-0 force-pushed the fix-mypy-edf-figure-close branch from 7f183f6 to 52522b2 Compare October 14, 2026 07:10

@c-bata c-bata left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@c-bata c-bata added this to the v5.1.0 milestone Oct 16, 2026
@c-bata c-bata added test Unit test. and removed code-fix Change that does not change the behavior, such as code refactoring. labels Oct 16, 2026
@c-bata

c-bata commented Oct 16, 2026

Copy link
Copy Markdown
Member

Let me merge this PR since this PR just fixes a test file.

@c-bata
c-bata merged commit c8d040d into optuna:master Oct 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Unit test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants