Skip to content

Commit 98b5dac

Browse files
Merge pull request #1198 from glados-verma:unused_imports
PiperOrigin-RevId: 696639286
2 parents c7cd2b7 + f9209cf commit 98b5dac

22 files changed

+27
-43
lines changed

openhtf/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import importlib.metadata
1717
import signal
18-
import typing
1918

2019
from openhtf.core import phase_executor
2120
from openhtf.core import test_record

openhtf/core/base_plugs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(self, my_config_key)
9494
"""
9595

9696
import logging
97-
from typing import Any, Dict, Set, Text, Type, Union
97+
from typing import Any, Dict, Text, Type, Union
9898

9999
import attr
100100

@@ -128,17 +128,17 @@ def tearDown(self):
128128
via TestApi.
129129
"""
130130
# Override this to True in subclasses to support remote Plug access.
131-
enable_remote = False # type: bool
131+
enable_remote: bool = False
132132
# Allow explicitly disabling remote access to specific attributes.
133-
disable_remote_attrs = set() # type: Set[Text]
133+
disable_remote_attrs = set()
134134
# Override this to True in subclasses to support using with_plugs with this
135135
# plug without needing to use placeholder. This will only affect the classes
136136
# that explicitly define this; subclasses do not share the declaration.
137-
auto_placeholder = False # type: bool
137+
auto_placeholder: bool = False
138138
# Default logger to be used only in __init__ of subclasses.
139139
# This is overwritten both on the class and the instance so don't store
140140
# a copy of it anywhere.
141-
logger = _LOG # type: logging.Logger
141+
logger: logging.Logger = _LOG
142142

143143
@util.classproperty
144144
def placeholder(cls) -> 'PlugPlaceholder': # pylint: disable=no-self-argument
@@ -185,7 +185,7 @@ class FrontendAwareBasePlug(BasePlug, util.SubscribableStateMixin):
185185
Since the Station API runs in a separate thread, the _asdict() method of
186186
frontend-aware plugs should be written with thread safety in mind.
187187
"""
188-
enable_remote = True # type: bool
188+
enable_remote: bool = True
189189

190190

191191
@attr.s(slots=True, frozen=True)

openhtf/core/diagnoses_lib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ def possible_results(self) -> List[Text]:
324324

325325
def _check_definition(self) -> None:
326326
"""Internal function to verify that the diagnoser is completely defined."""
327-
pass
328327

329328

330329
class BasePhaseDiagnoser(_BaseDiagnoser, abc.ABC):

openhtf/core/measurements.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def WidgetTestPhase(test):
6363
import enum
6464
import functools
6565
import logging
66-
import time
6766
import typing
6867
from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, Union
6968

openhtf/core/phase_collections.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import abc
2424
import collections
2525
from collections.abc import Iterable as CollectionsIterable
26-
from typing import Any, Callable, DefaultDict, Dict, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
26+
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
2727

2828
import attr
2929
from openhtf import util
@@ -221,16 +221,18 @@ def check_for_duplicate_subtest_names(sequence: PhaseSequence):
221221
Raises:
222222
DuplicateSubtestNamesError: when duplicate subtest names are found.
223223
"""
224-
names_to_subtests = collections.defaultdict(
225-
list) # type: DefaultDict[Text, List[Subtest]]
224+
names_to_subtests: collections.defaultdict[str, list[Subtest]] = (
225+
collections.defaultdict(list)
226+
)
226227
for subtest in sequence.filter_by_type(Subtest):
227228
names_to_subtests[subtest.name].append(subtest)
228229

229-
duplicates = [] # type: List[Text]
230+
duplicates: list[str] = []
230231
for name, subtests in names_to_subtests.items():
231232
if len(subtests) > 1:
232-
duplicates.append('Name "{}" used by multiple subtests: {}'.format(
233-
name, subtests))
233+
duplicates.append(
234+
'Name "{}" used by multiple subtests: {}'.format(name, subtests)
235+
)
234236
if not duplicates:
235237
return
236238
duplicates.sort()

openhtf/output/callbacks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class OutputToFile(object):
8080

8181
def __init__(self, filename_pattern_or_file: Union[Text, Callable[..., Text],
8282
BinaryIO]):
83-
self.filename_pattern = None # type: Optional[Union[Text, Callable[..., Text]]]
84-
self.output_file = None # type: Optional[BinaryIO]
83+
self.filename_pattern: Optional[Union[Text, Callable[..., Text]]] = None
84+
self.output_file: Optional[BinaryIO] = None
8585
if (isinstance(filename_pattern_or_file, str) or
8686
callable(filename_pattern_or_file)):
8787
self.filename_pattern = filename_pattern_or_file # pytype: disable=annotation-type-mismatch

openhtf/output/servers/pub_sub.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ def on_close(self):
6767

6868
def on_subscribe(self, info):
6969
"""Called when new clients subscribe. Subclasses can override."""
70-
pass
7170

7271
def on_unsubscribe(self):
7372
"""Called when clients unsubscribe. Subclasses can override."""
74-
pass

openhtf/plugs/generic/serial_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class SerialCollectionPlug(base_plugs.BasePlug):
5858
# Serial library can raise these exceptions
5959
SERIAL_EXCEPTIONS = (serial.SerialException, ValueError)
6060

61-
_serial = None # type: serial.Serial
62-
_serial_port = None # type: int
63-
_collect = None # type: bool
64-
_collection_thread = None # type: Optional[threading.Thread]
61+
_serial: Optional[serial.Serial] = None
62+
_serial_port: Optional[int] = None
63+
_collect: Optional[bool] = None
64+
_collection_thread: Optional[threading.Thread] = None
6565

6666
@CONF.inject_positional_args
6767
def __init__(self, serial_collection_port, serial_collection_baud):

openhtf/plugs/user_input.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import select
2525
import sys
2626
import threading
27-
from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
27+
from typing import Any, Callable, Dict, Optional, Text, Union
2828
import uuid
2929

3030
import attr
@@ -142,10 +142,10 @@ class UserInput(base_plugs.FrontendAwareBasePlug):
142142

143143
def __init__(self):
144144
super(UserInput, self).__init__()
145-
self.last_response = None # type: Optional[Tuple[Text, Text]]
146-
self._prompt = None # type: Optional[Prompt]
147-
self._console_prompt = None # type: Optional[ConsolePrompt]
148-
self._response = None # type: Optional[Text]
145+
self.last_response: Optional[tuple[str, str]] = None
146+
self._prompt: Optional[Prompt] = None
147+
self._console_prompt: Optional[ConsolePrompt] = None
148+
self._response: Optional[Text] = None
149149
self._cond = threading.Condition(threading.RLock())
150150

151151
def _asdict(self) -> Optional[Dict[Text, Any]]:

openhtf/util/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import threading
1919
import time
2020
import typing
21-
from typing import Any, Callable, Dict, Iterator, Optional, Text, Tuple, Type, TypeVar, Union
21+
from typing import Any, Callable, Dict, Iterator, Optional, Text, Tuple, TypeVar
2222
import weakref
2323

2424
import attr

0 commit comments

Comments
 (0)