Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Black 2024 to codebase #87

Merged
merged 5 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 12 additions & 10 deletions optuna_integration/_lightgbm_tuner/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def _get_metric_for_objective(self) -> str:

def _get_booster_best_score(self, booster: "lgb.Booster") -> float:
metric = self._get_metric_for_objective()
valid_sets: list["lgb.Dataset"] | tuple[
"lgb.Dataset", ...
] | "lgb.Dataset" | None = self.lgbm_kwargs.get("valid_sets")
valid_sets: list["lgb.Dataset"] | tuple["lgb.Dataset", ...] | "lgb.Dataset" | None = (
self.lgbm_kwargs.get("valid_sets")
)

if self.lgbm_kwargs.get("valid_names") is not None:
if isinstance(self.lgbm_kwargs["valid_names"], str):
Expand Down Expand Up @@ -172,9 +172,9 @@ def __init__(

self.trial_count = 0
self.best_score = best_score
self.best_booster_with_trial_number: tuple[
"lgb.Booster" | "lgb.CVBooster", int
] | None = None
self.best_booster_with_trial_number: tuple["lgb.Booster" | "lgb.CVBooster", int] | None = (
None
)
self.step_name = step_name
self.model_dir = model_dir

Expand Down Expand Up @@ -945,10 +945,12 @@ def __init__(
params: dict[str, Any],
train_set: "lgb.Dataset",
num_boost_round: int = 1000,
folds: Generator[tuple[int, int], None, None]
| Iterator[tuple[int, int]]
| "BaseCrossValidator"
| None = None,
folds: (
Generator[tuple[int, int], None, None]
| Iterator[tuple[int, int]]
| "BaseCrossValidator"
| None
) = None,
nfold: int = 5,
stratified: bool = True,
shuffle: bool = True,
Expand Down
20 changes: 7 additions & 13 deletions optuna_integration/chainermn.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,30 +199,24 @@
return self._call_with_mpi(func)

@overload
def suggest_categorical(self, name: str, choices: Sequence[None]) -> None:
...
def suggest_categorical(self, name: str, choices: Sequence[None]) -> None: ... # noqa: E704

Check warning on line 202 in optuna_integration/chainermn.py

View check run for this annotation

Codecov / codecov/patch

optuna_integration/chainermn.py#L202

Added line #L202 was not covered by tests

@overload
def suggest_categorical(self, name: str, choices: Sequence[bool]) -> bool:
...
def suggest_categorical(self, name: str, choices: Sequence[bool]) -> bool: ... # noqa: E704

Check warning on line 205 in optuna_integration/chainermn.py

View check run for this annotation

Codecov / codecov/patch

optuna_integration/chainermn.py#L205

Added line #L205 was not covered by tests

@overload
def suggest_categorical(self, name: str, choices: Sequence[int]) -> int:
...
def suggest_categorical(self, name: str, choices: Sequence[int]) -> int: ... # noqa: E704

Check warning on line 208 in optuna_integration/chainermn.py

View check run for this annotation

Codecov / codecov/patch

optuna_integration/chainermn.py#L208

Added line #L208 was not covered by tests

@overload
def suggest_categorical(self, name: str, choices: Sequence[float]) -> float:
...
def suggest_categorical(self, name: str, choices: Sequence[float]) -> float: ... # noqa: E704

Check warning on line 211 in optuna_integration/chainermn.py

View check run for this annotation

Codecov / codecov/patch

optuna_integration/chainermn.py#L211

Added line #L211 was not covered by tests

@overload
def suggest_categorical(self, name: str, choices: Sequence[str]) -> str:
...
def suggest_categorical(self, name: str, choices: Sequence[str]) -> str: ... # noqa: E704

Check warning on line 214 in optuna_integration/chainermn.py

View check run for this annotation

Codecov / codecov/patch

optuna_integration/chainermn.py#L214

Added line #L214 was not covered by tests

@overload
def suggest_categorical(
def suggest_categorical( # noqa: E704

Check warning on line 217 in optuna_integration/chainermn.py

View check run for this annotation

Codecov / codecov/patch

optuna_integration/chainermn.py#L217

Added line #L217 was not covered by tests
self, name: str, choices: Sequence[CategoricalChoiceType]
) -> CategoricalChoiceType:
...
) -> CategoricalChoiceType: ...

def suggest_categorical(
self, name: str, choices: Sequence[CategoricalChoiceType]
Expand Down
14 changes: 8 additions & 6 deletions optuna_integration/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ def _serialize_frozenstudy(study: FrozenStudy) -> dict:
"directions": [d.name for d in study._directions],
"study_id": study._study_id,
"study_name": study.study_name,
"user_attrs": dumps(study.user_attrs) # type: ignore[no-untyped-call]
if study.user_attrs
else {},
"system_attrs": dumps(study.system_attrs) # type: ignore[no-untyped-call]
if study.system_attrs
else {},
"user_attrs": (
dumps(study.user_attrs) if study.user_attrs else {} # type: ignore[no-untyped-call]
),
"system_attrs": (
dumps(study.system_attrs) # type: ignore[no-untyped-call]
if study.system_attrs
else {}
),
}
return data

Expand Down
20 changes: 7 additions & 13 deletions optuna_integration/pytorch_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,30 +191,24 @@ def func() -> float:
return self._call_and_communicate(func, torch.int)

@overload
def suggest_categorical(self, name: str, choices: Sequence[None]) -> None:
...
def suggest_categorical(self, name: str, choices: Sequence[None]) -> None: ... # noqa: E704

@overload
def suggest_categorical(self, name: str, choices: Sequence[bool]) -> bool:
...
def suggest_categorical(self, name: str, choices: Sequence[bool]) -> bool: ... # noqa: E704

@overload
def suggest_categorical(self, name: str, choices: Sequence[int]) -> int:
...
def suggest_categorical(self, name: str, choices: Sequence[int]) -> int: ... # noqa: E704

@overload
def suggest_categorical(self, name: str, choices: Sequence[float]) -> float:
...
def suggest_categorical(self, name: str, choices: Sequence[float]) -> float: ... # noqa: E704

@overload
def suggest_categorical(self, name: str, choices: Sequence[str]) -> str:
...
def suggest_categorical(self, name: str, choices: Sequence[str]) -> str: ... # noqa: E704

@overload
def suggest_categorical(
def suggest_categorical( # noqa: E704
self, name: str, choices: Sequence[CategoricalChoiceType]
) -> CategoricalChoiceType:
...
) -> CategoricalChoiceType: ...

@broadcast_properties
def suggest_categorical(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test = [
"fakeredis[lua]",
]
checking = [
"black<24.0.0",
"black",
"blackdoc",
"hacking",
"isort",
Expand Down