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

Fix and add CI checks for autoflake, isort #1049

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_PUBLISH_PASSWORD }}
skip_existing: true

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install -U autoflake isort
- run: autoflake .
- run: isort --check --diff --color .
4 changes: 2 additions & 2 deletions examples/all_the_things.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import os.path
import time

import openhtf as htf
from openhtf import util
from examples import example_plugs
from openhtf import util
import openhtf as htf
from openhtf.output import callbacks
from openhtf.output.callbacks import console_summary
from openhtf.output.callbacks import json_factory
Expand Down
2 changes: 1 addition & 1 deletion examples/checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import time

import openhtf as htf
from examples import measurements as measurements_example
import openhtf as htf
from openhtf.output.callbacks import console_summary
from openhtf.output.callbacks import json_factory
from openhtf.util import checkpoints
Expand Down
2 changes: 0 additions & 2 deletions examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
# from it throughout our test scripts. See __all__ at the top of
# openhtf/__init__.py for details on what's in top-of-module namespace.
import openhtf as htf

# Import this output mechanism as it's the specific one we want to use.
from openhtf.output.callbacks import json_factory

from openhtf.plugs import user_input


Expand Down
2 changes: 0 additions & 2 deletions examples/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@
import random

import openhtf as htf

# Import this output mechanism as it's the specific one we want to use.
from openhtf.output.callbacks import json_factory

# You won't normally need to import this, see validators.py example for
# more details. It's used for the inline measurement declaration example
# below, but normally you'll only import it when you want to define custom
Expand Down
5 changes: 2 additions & 3 deletions openhtf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"""The main OpenHTF entry point."""

import signal
import typing

import pkg_resources

from openhtf import plugs
from openhtf.core import phase_executor
Expand All @@ -27,7 +28,6 @@
from openhtf.core.diagnoses_lib import DiagResultEnum
from openhtf.core.diagnoses_lib import PhaseDiagnoser
from openhtf.core.diagnoses_lib import TestDiagnoser

from openhtf.core.measurements import Dimension
from openhtf.core.measurements import Measurement
from openhtf.core.monitors import monitors
Expand Down Expand Up @@ -57,7 +57,6 @@
from openhtf.util import functions
from openhtf.util import logs
from openhtf.util import units
import pkg_resources

conf = configuration.CONF

Expand Down
5 changes: 3 additions & 2 deletions openhtf/core/diagnoses_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ def main():
from collections.abc import Iterable as CollectionsIterable
import enum
import logging
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Text, Type, TYPE_CHECKING, Union
from typing import (Any, Callable, Dict, Iterable, List, Optional, Sequence,
Text, Type, TYPE_CHECKING, Union)

import attr

from openhtf.core import test_record
from openhtf.util import data

Expand Down Expand Up @@ -324,7 +326,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
5 changes: 4 additions & 1 deletion openhtf/core/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ def WidgetTestPhase(test):
import functools
import logging
import typing
from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, Union
from typing import (Any, Callable, Dict, Iterator, List, Optional, Text, Tuple,
Union)

import attr

from openhtf import util
from openhtf.util import data
from openhtf.util import units as util_units
from openhtf.util import validators

if typing.TYPE_CHECKING:
from openhtf.core import diagnoses_lib

try:
# pylint: disable=g-import-not-at-top
import pandas # pytype: disable=import-error

# pylint: enable=g-import-not-at-top
except ImportError:
pandas = None
Expand Down
3 changes: 2 additions & 1 deletion openhtf/core/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ def MyPhase(test):
import time
from typing import Any, Callable, Dict, Optional, Text

import six

import openhtf
from openhtf import plugs
from openhtf.core import measurements
from openhtf.core import phase_descriptor
from openhtf.core import test_state as core_test_state
from openhtf.util import threads
from openhtf.util import units as uom
import six


class _MonitorThread(threads.KillableThread):
Expand Down
5 changes: 3 additions & 2 deletions openhtf/core/phase_branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

import abc
import enum
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterator, Optional,
Text, Tuple, Union)
from typing import (Any, Callable, Dict, Iterator, Optional, Text, Tuple,
TYPE_CHECKING, Union)

import attr

from openhtf import util
from openhtf.core import diagnoses_lib
from openhtf.core import phase_collections
Expand Down
4 changes: 3 additions & 1 deletion openhtf/core/phase_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
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, DefaultDict, Dict, Iterable, Iterator, List,
Optional, Text, Tuple, Type, TypeVar, Union)

import attr

from openhtf import util
from openhtf.core import base_plugs
from openhtf.core import phase_descriptor
Expand Down
3 changes: 2 additions & 1 deletion openhtf/core/phase_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import enum
import inspect
import pdb
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Text, TYPE_CHECKING, Type, Union
from typing import (Any, Callable, Dict, Iterator, List, Optional, Sequence,
Set, Text, Type, TYPE_CHECKING, Union)

import attr
import inflection
Expand Down
1 change: 1 addition & 0 deletions openhtf/core/phase_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from typing import Any, Dict, Optional, Text, Tuple, Type, TYPE_CHECKING, Union

import attr

from openhtf import util
from openhtf.core import phase_branches
from openhtf.core import phase_descriptor
Expand Down
6 changes: 4 additions & 2 deletions openhtf/core/phase_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
"""Contains the abstract interfaces for phase nodes."""

import abc
from typing import Any, Callable, Dict, Optional, Text, Type, TypeVar, TYPE_CHECKING
from typing import (Any, Callable, Dict, Optional, Text, Type, TYPE_CHECKING,
TypeVar)

from openhtf.core import base_plugs
from openhtf.util import data

if TYPE_CHECKING:
from openhtf.core import phase_descriptor # pylint: disable=g-import-not-at-top
from openhtf.core import \
phase_descriptor # pylint: disable=g-import-not-at-top

WithModifierT = TypeVar('WithModifierT', bound='PhaseNode')
ApplyAllNodesT = TypeVar('ApplyAllNodesT', bound='PhaseNode')
Expand Down
1 change: 0 additions & 1 deletion openhtf/core/test_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from openhtf.core import test_executor
from openhtf.core import test_record as htf_test_record
from openhtf.core import test_state

from openhtf.util import configuration
from openhtf.util import console_output
from openhtf.util import logs
Expand Down
3 changes: 2 additions & 1 deletion openhtf/core/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
CONF = configuration.CONF

if TYPE_CHECKING:
from openhtf.core import test_descriptor # pylint: disable=g-import-not-at-top
from openhtf.core import \
test_descriptor # pylint: disable=g-import-not-at-top

_LOG = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions openhtf/core/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
if TYPE_CHECKING:
from openhtf.core import diagnoses_lib # pylint: disable=g-import-not-at-top
from openhtf.core import measurements as htf_measurements # pylint: disable=g-import-not-at-top
from openhtf.core import phase_descriptor # pylint: disable=g-import-not-at-top
from openhtf.core import phase_executor # pylint: disable=g-import-not-at-top
from openhtf.core import phase_branches # pylint: disable=g-import-not-at-top
from openhtf.core import \
phase_descriptor # pylint: disable=g-import-not-at-top
from openhtf.core import phase_executor # pylint: disable=g-import-not-at-top

CONF.declare(
'attachments_directory',
Expand Down
8 changes: 5 additions & 3 deletions openhtf/core/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
import os
import socket
import sys
from typing import Any, Dict, Iterator, List, Optional, Set, Text, TYPE_CHECKING, Union
from typing import (Any, Dict, Iterator, List, Optional, Set, Text,
TYPE_CHECKING, Union)

import attr
from typing_extensions import Literal

import openhtf
from openhtf import plugs
Expand All @@ -48,12 +50,12 @@
from openhtf.util import data
from openhtf.util import logs
from openhtf.util import units
from typing_extensions import Literal

CONF = configuration.CONF

if TYPE_CHECKING:
from openhtf.core import test_descriptor # pylint: disable=g-import-not-at-top
from openhtf.core import \
test_descriptor # pylint: disable=g-import-not-at-top

CONF.declare(
'allow_unset_measurements',
Expand Down
5 changes: 3 additions & 2 deletions openhtf/output/servers/dashboard_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
import threading
import time

import sockjs.tornado
import tornado.web

from openhtf.output.servers import pub_sub
from openhtf.output.servers import station_server
from openhtf.output.servers import web_gui_server
from openhtf.output.web_gui import web_launcher
from openhtf.util import data
from openhtf.util import multicast
import sockjs.tornado
import tornado.web

_LOG = logging.getLogger(__name__)

Expand Down
5 changes: 2 additions & 3 deletions openhtf/output/servers/pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

import logging

from openhtf import util as htf_util
import sockjs.tornado

from openhtf import util as htf_util

_LOG = logging.getLogger(__name__)


Expand Down Expand Up @@ -67,8 +68,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
3 changes: 2 additions & 1 deletion openhtf/output/servers/station_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import types
from typing import Optional, Union

import sockjs.tornado

import openhtf
from openhtf.output.servers import pub_sub
from openhtf.output.servers import web_gui_server
Expand All @@ -25,7 +27,6 @@
from openhtf.util import functions
from openhtf.util import multicast
from openhtf.util import timeouts
import sockjs.tornado

CONF = configuration.CONF

Expand Down
3 changes: 2 additions & 1 deletion openhtf/plugs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"""

import logging
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Text, Tuple, Type, TypeVar, Union
from typing import (Any, Callable, Dict, Iterable, List, Optional, Set, Text,
Tuple, Type, TypeVar, Union)

import attr

Expand Down
1 change: 1 addition & 0 deletions openhtf/plugs/cambrionix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import subprocess
import time

from openhtf.plugs.usb import local_usb


Expand Down
1 change: 1 addition & 0 deletions openhtf/plugs/generic/serial_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
try:
# pylint: disable=g-import-not-at-top
import serial # pytype: disable=import-error

# pylint: enable=g-import-not-at-top
except ImportError:
logging.error(
Expand Down
3 changes: 2 additions & 1 deletion openhtf/plugs/usb/fastboot_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import os
import struct

from . import usb_exceptions
from openhtf.util import argv

from . import usb_exceptions

FASTBOOT_DOWNLOAD_CHUNK_SIZE_KB = 1024

ARG_PARSER = argv.module_parser()
Expand Down
1 change: 1 addition & 0 deletions openhtf/plugs/usb/local_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# pylint: disable=g-import-not-at-top
import libusb1 # pytype: disable=import-error
import usb1 # pytype: disable=import-error

# pylint: enable=g-import-not-at-top
except ImportError:
logging.error('Failed to import libusb, did you pip install '
Expand Down
1 change: 1 addition & 0 deletions openhtf/plugs/usb/usb_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
try:
# pylint: disable=g-import-not-at-top
import libusb1 # pytype: disable=import-error

# pylint: enable=g-import-not-at-top
except ImportError:
logging.error('Failed to import libusb, did you pip install '
Expand Down
1 change: 1 addition & 0 deletions openhtf/plugs/user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import uuid

import attr

import openhtf
from openhtf import plugs
from openhtf.core import base_plugs
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
Loading