Skip to content

Commit

Permalink
Merge pull request #1198 from glados-verma:unused_imports
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696639286
  • Loading branch information
copybara-github committed Nov 14, 2024
2 parents c7cd2b7 + f9209cf commit 98b5dac
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 43 deletions.
1 change: 0 additions & 1 deletion openhtf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import importlib.metadata
import signal
import typing

from openhtf.core import phase_executor
from openhtf.core import test_record
Expand Down
12 changes: 6 additions & 6 deletions openhtf/core/base_plugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, my_config_key)
"""

import logging
from typing import Any, Dict, Set, Text, Type, Union
from typing import Any, Dict, Text, Type, Union

import attr

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

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


@attr.s(slots=True, frozen=True)
Expand Down
1 change: 0 additions & 1 deletion openhtf/core/diagnoses_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ def possible_results(self) -> List[Text]:

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


class BasePhaseDiagnoser(_BaseDiagnoser, abc.ABC):
Expand Down
1 change: 0 additions & 1 deletion openhtf/core/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def WidgetTestPhase(test):
import enum
import functools
import logging
import time
import typing
from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, Union

Expand Down
14 changes: 8 additions & 6 deletions openhtf/core/phase_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import abc
import collections
from collections.abc import Iterable as CollectionsIterable
from typing import Any, Callable, DefaultDict, Dict, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union

import attr
from openhtf import util
Expand Down Expand Up @@ -221,16 +221,18 @@ def check_for_duplicate_subtest_names(sequence: PhaseSequence):
Raises:
DuplicateSubtestNamesError: when duplicate subtest names are found.
"""
names_to_subtests = collections.defaultdict(
list) # type: DefaultDict[Text, List[Subtest]]
names_to_subtests: collections.defaultdict[str, list[Subtest]] = (
collections.defaultdict(list)
)
for subtest in sequence.filter_by_type(Subtest):
names_to_subtests[subtest.name].append(subtest)

duplicates = [] # type: List[Text]
duplicates: list[str] = []
for name, subtests in names_to_subtests.items():
if len(subtests) > 1:
duplicates.append('Name "{}" used by multiple subtests: {}'.format(
name, subtests))
duplicates.append(
'Name "{}" used by multiple subtests: {}'.format(name, subtests)
)
if not duplicates:
return
duplicates.sort()
Expand Down
4 changes: 2 additions & 2 deletions openhtf/output/callbacks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class OutputToFile(object):

def __init__(self, filename_pattern_or_file: Union[Text, Callable[..., Text],
BinaryIO]):
self.filename_pattern = None # type: Optional[Union[Text, Callable[..., Text]]]
self.output_file = None # type: Optional[BinaryIO]
self.filename_pattern: Optional[Union[Text, Callable[..., Text]]] = None
self.output_file: Optional[BinaryIO] = None
if (isinstance(filename_pattern_or_file, str) or
callable(filename_pattern_or_file)):
self.filename_pattern = filename_pattern_or_file # pytype: disable=annotation-type-mismatch
Expand Down
2 changes: 0 additions & 2 deletions openhtf/output/servers/pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def on_close(self):

def on_subscribe(self, info):
"""Called when new clients subscribe. Subclasses can override."""
pass

def on_unsubscribe(self):
"""Called when clients unsubscribe. Subclasses can override."""
pass
8 changes: 4 additions & 4 deletions openhtf/plugs/generic/serial_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class SerialCollectionPlug(base_plugs.BasePlug):
# Serial library can raise these exceptions
SERIAL_EXCEPTIONS = (serial.SerialException, ValueError)

_serial = None # type: serial.Serial
_serial_port = None # type: int
_collect = None # type: bool
_collection_thread = None # type: Optional[threading.Thread]
_serial: Optional[serial.Serial] = None
_serial_port: Optional[int] = None
_collect: Optional[bool] = None
_collection_thread: Optional[threading.Thread] = None

@CONF.inject_positional_args
def __init__(self, serial_collection_port, serial_collection_baud):
Expand Down
10 changes: 5 additions & 5 deletions openhtf/plugs/user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import select
import sys
import threading
from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
from typing import Any, Callable, Dict, Optional, Text, Union
import uuid

import attr
Expand Down Expand Up @@ -142,10 +142,10 @@ class UserInput(base_plugs.FrontendAwareBasePlug):

def __init__(self):
super(UserInput, self).__init__()
self.last_response = None # type: Optional[Tuple[Text, Text]]
self._prompt = None # type: Optional[Prompt]
self._console_prompt = None # type: Optional[ConsolePrompt]
self._response = None # type: Optional[Text]
self.last_response: Optional[tuple[str, str]] = None
self._prompt: Optional[Prompt] = None
self._console_prompt: Optional[ConsolePrompt] = None
self._response: Optional[Text] = None
self._cond = threading.Condition(threading.RLock())

def _asdict(self) -> Optional[Dict[Text, Any]]:
Expand Down
2 changes: 1 addition & 1 deletion openhtf/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import threading
import time
import typing
from typing import Any, Callable, Dict, Iterator, Optional, Text, Tuple, Type, TypeVar, Union
from typing import Any, Callable, Dict, Iterator, Optional, Text, Tuple, TypeVar
import weakref

import attr
Expand Down
1 change: 0 additions & 1 deletion openhtf/util/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def MyPhase(test, helper):
from openhtf.util import argv
from openhtf.util import console_output
from openhtf.util import functions
from openhtf.util import threads

# The number of v's provided as command line arguments to control verbosity.
# Will be overridden if the ARG_PARSER below parses the -v argument.
Expand Down
1 change: 0 additions & 1 deletion openhtf/util/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def test_multiple(self, mock_my_plug):
assertMeasurementFail(phase_or_test_rec, measurement)
"""

import collections
from collections.abc import Callable as CollectionsCallable, Iterator
import functools
import inspect
Expand Down
2 changes: 0 additions & 2 deletions openhtf/util/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# limitations under the License.
"""Thread library defining a few helpers."""

import _thread
import contextlib
import cProfile
import ctypes
import functools
Expand Down
2 changes: 1 addition & 1 deletion openhtf/util/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def MyPhase(test: htf.TestApi) -> None:
import math
import numbers
import re
from typing import Callable, Dict, Optional, Type, TypeVar, Union
from typing import Callable, Dict, Optional, Union

from openhtf import util

Expand Down
1 change: 0 additions & 1 deletion openhtf/util/xmlrpcutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from collections.abc import Callable
import http.client
import socketserver
import sys
import threading
import xmlrpc.client
import xmlrpc.server
Expand Down
1 change: 0 additions & 1 deletion test/core/measurements_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"""

import collections
import unittest
from unittest import mock

import openhtf as htf
Expand Down
1 change: 0 additions & 1 deletion test/output/callbacks/callbacks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import io
import json
import unittest

import openhtf as htf
from openhtf import util
Expand Down
1 change: 0 additions & 1 deletion test/output/callbacks/mfg_inspector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"""
import collections
import io
import unittest
from unittest import mock

import openhtf as htf
Expand Down
1 change: 0 additions & 1 deletion test/phase_descriptor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

def plain_func():
"""Plain Docstring."""
pass


def normal_test_phase():
Expand Down
1 change: 0 additions & 1 deletion test/plugs/plugs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import threading
import time
import unittest

from openhtf import plugs
from openhtf.core import base_plugs
Expand Down
2 changes: 0 additions & 2 deletions test/test_state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import logging
import sys
import tempfile
import unittest
from unittest import mock

from absl.testing import parameterized
Expand All @@ -37,7 +36,6 @@
@openhtf.PhaseOptions(name='test_phase')
def test_phase():
"""Test docstring."""
pass


PHASE_STATE_BASE_TYPE_INITIAL = {
Expand Down
1 change: 0 additions & 1 deletion test/util/text_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sys
import types
import typing
import unittest
from unittest import mock

from absl.testing import parameterized
Expand Down

0 comments on commit 98b5dac

Please sign in to comment.