Skip to content

Commit

Permalink
Reapply codemod pep585_imports
Browse files Browse the repository at this point in the history
Summary: I noticed some files weren't obeying this, seems like these probably had diffs in flight that improperly merged and undid some changes from D60976146. No matter, just reran the codemod.

Differential Revision: D64833627
  • Loading branch information
mpolson64 authored and facebook-github-bot committed Oct 23, 2024
1 parent 02c0ce5 commit 5e2b3c1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ax/modelbridge/transition_criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from __future__ import annotations

from abc import abstractmethod
from collections.abc import Collection
from logging import Logger
from typing import Collection

from ax import modelbridge

Expand Down
10 changes: 5 additions & 5 deletions ax/preview/api/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List, Optional, Union
from typing import Optional, Union

from ax.core.types import TParamValue

Expand Down Expand Up @@ -62,9 +62,9 @@ class ParameterConfig:
scaling: Optional[ParameterScaling] = None

# Fields for CHOICE ("FIXED" is Choice with len(values) == 1)
values: Optional[Union[List[float], List[str], List[bool]]] = None
values: Optional[Union[list[float], list[str], list[bool]]] = None
is_ordered: Optional[bool] = None
dependent_parameters: Optional[Dict[TParamValue, str]] = None
dependent_parameters: Optional[dict[TParamValue, str]] = None


@dataclass
Expand All @@ -79,10 +79,10 @@ class ExperimentConfig:
"""

name: str
parameters: List[ParameterConfig]
parameters: list[ParameterConfig]
# Parameter constraints will be parsed via SymPy
# Ex: "num_layers1 <= num_layers2", "compound_a + compound_b <= 1"
parameter_constraints: List[str] = field(default_factory=list)
parameter_constraints: list[str] = field(default_factory=list)

description: str | None = None
owner: str | None = None
Expand Down
6 changes: 3 additions & 3 deletions ax/service/interactive_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from logging import Logger
from queue import Queue
from threading import Event, Lock, Thread
from typing import Any, Tuple
from typing import Any

from ax.core.types import TEvaluationOutcome, TParameterization

Expand Down Expand Up @@ -155,7 +155,7 @@ def interactive_optimize_with_client(


def ax_client_candidate_generator(
queue: "Queue[Tuple[TParameterization, int]]",
queue: Queue[tuple[TParameterization, int]],
stop_event: Event,
num_trials: int,
ax_client: AxClient,
Expand Down Expand Up @@ -188,7 +188,7 @@ def ax_client_candidate_generator(


def ax_client_data_attacher(
queue: "Queue[Tuple[int, TEvaluationOutcome]]",
queue: Queue[tuple[int, TEvaluationOutcome]],
stop_event: Event,
ax_client: AxClient,
lock: Lock,
Expand Down
10 changes: 5 additions & 5 deletions ax/service/tests/scheduler_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from math import ceil
from random import randint
from tempfile import NamedTemporaryFile
from typing import Any, Callable, cast, Dict, List, Optional, Tuple
from typing import Any, Callable, cast, Optional
from unittest.mock import call, Mock, patch, PropertyMock

import pandas as pd
Expand Down Expand Up @@ -283,22 +283,22 @@ class AxSchedulerTestCase(TestCase):
# TODO[@mgarrard]: Change this to `str(GenerationStrategy.__module__)`
# once we are no longer splitting which `GS.gen` to call into based on
# `Trial` vs. `BatchTrial`
PENDING_FEATURES_EXTRACTOR: Tuple[ # pyre-ignore[8]
PENDING_FEATURES_EXTRACTOR: tuple[ # pyre-ignore[8]
str,
Callable[
[...],
Optional[Dict[str, List[ObservationFeatures]]],
Optional[dict[str, list[ObservationFeatures]]],
],
] = (
f"{Scheduler.__module__}."
+ "get_pending_observation_features_based_on_trial_status",
get_pending_observation_features_based_on_trial_status,
)
PENDING_FEATURES_BATCH_EXTRACTOR: Tuple[ # pyre-ignore[8]
PENDING_FEATURES_BATCH_EXTRACTOR: tuple[ # pyre-ignore[8]
str,
Callable[
[...],
Optional[Dict[str, List[ObservationFeatures]]],
Optional[dict[str, list[ObservationFeatures]]],
],
] = (
f"{GenerationStrategy.__module__}.extract_pending_observations",
Expand Down
3 changes: 1 addition & 2 deletions scripts/validate_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import pkgutil
import re
from typing import Set


# Paths are relative to top-level Ax directory (which is passed into fxn below)
Expand All @@ -31,7 +30,7 @@

# NOTE: Can't use set[str] here due to internal call site of this module
# on an ancient (<py3.9) python version.
def parse_rst(rst_filename: str) -> Set[str]:
def parse_rst(rst_filename: str) -> set[str]:
"""Extract automodule directives from rst."""
ret = set()
with open(rst_filename, "r") as f:
Expand Down

0 comments on commit 5e2b3c1

Please sign in to comment.