Skip to content

Use TYPE_CHECKING in optuna/samplers/_random.py#6298

Merged
nabenabe0928 merged 3 commits intooptuna:masterfrom
AddyM:fix/type-checking-samplers-random
Oct 14, 2025
Merged

Use TYPE_CHECKING in optuna/samplers/_random.py#6298
nabenabe0928 merged 3 commits intooptuna:masterfrom
AddyM:fix/type-checking-samplers-random

Conversation

@AddyM
Copy link
Copy Markdown
Contributor

@AddyM AddyM commented Oct 11, 2025

Description

Move distributions, BaseDistribution, and FrozenTrial imports into TYPE_CHECKING block to avoid potential circular import issues.

Changes

  • Moved from optuna import distributions into TYPE_CHECKING block
  • Moved BaseDistribution import into TYPE_CHECKING block
  • Moved FrozenTrial import into TYPE_CHECKING block

Verification

  • Ran flake8 and confirmed no errors
  • Formatted with black and isort

Related to:

Move distribution and trial imports into TYPE_CHECKING block
to avoid potential circular import issues.

Fixes optuna#6029
@nabenabe0928 nabenabe0928 changed the title Use TYPE_CHECKING in optuna/samplers/_random.py Use TYPE_CHECKING in optuna/samplers/_random.py Oct 12, 2025
@nabenabe0928 nabenabe0928 added the code-fix Change that does not change the behavior, such as code refactoring. label Oct 14, 2025
@nabenabe0928 nabenabe0928 added this to the v4.6.0 milestone Oct 14, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.11%. Comparing base (9d13973) to head (fc2215b).
⚠️ Report is 445 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6298      +/-   ##
==========================================
- Coverage   89.23%   89.11%   -0.12%     
==========================================
  Files         209      209              
  Lines       13940    13919      -21     
==========================================
- Hits        12439    12404      -35     
- Misses       1501     1515      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nabenabe0928 nabenabe0928 merged commit d4730cc into optuna:master Oct 14, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-fix Change that does not change the behavior, such as code refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants