Skip to content

Commit 3be1ff2

Browse files
authored
Merge pull request optuna#6086 from AdrianStrymer/use-type-checking
Implement Type-Checking for `optuna/distributions.py`
2 parents 3126551 + 4f9d3bb commit 3be1ff2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

optuna/distributions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
from __future__ import annotations
22

33
import abc
4-
from collections.abc import Sequence
54
import copy
65
import decimal
76
import json
87
import math
98
from numbers import Real
109
from typing import Any
1110
from typing import cast
11+
from typing import TYPE_CHECKING
1212
from typing import Union
1313
import warnings
1414

1515
from optuna._deprecated import deprecated_class
1616

1717

18+
if TYPE_CHECKING:
19+
from collections.abc import Sequence
20+
21+
1822
CategoricalChoiceType = Union[None, bool, int, float, str]
1923

2024

@@ -304,7 +308,7 @@ def q(self) -> float:
304308
:class:`~optuna.distributions.FloatDistribution`.
305309
This property is a proxy for its ``step`` attribute.
306310
"""
307-
return cast(float, self.step)
311+
return cast("float", self.step)
308312

309313
@q.setter
310314
def q(self, v: float) -> None:

0 commit comments

Comments
 (0)