From c6c55b85cfa820b4e671ea42711ed52aa88e04ff Mon Sep 17 00:00:00 2001 From: Constantine Evans Date: Sat, 12 Oct 2024 21:07:10 -0400 Subject: [PATCH] more linting --- .github/workflows/python-publish.yml | 2 +- .github/workflows/python-tests.yml | 2 +- .pre-commit-config.yaml | 8 ++++---- docs/setup.rst | 8 ++++---- src/qslib/experiment.py | 3 --- src/qslib/protocol.py | 25 ++++++++++--------------- src/qslib/qsconnection_async.py | 27 +++++++++------------------ 7 files changed, 29 insertions(+), 46 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f42435d..a922af0 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.9' + python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 70910be..07a5d8a 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - uses: actions/checkout@v3 - name: Install dependencies run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb30c67..216f0cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,26 +5,26 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 24.10.0 hooks: - id: black language_version: python3.12 args: ["--target-version", "py311"] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.281 + rev: v0.6.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/docs/setup.rst b/docs/setup.rst index c75ac35..556f80e 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -41,12 +41,12 @@ certificate, use something like one or more of the following: # For old firmware versions with plain-text network access socat openssl-listen:7443,reuseaddr,fork,cert=server.pem,verify=0 \ - tcp:$MACHINE_IP_ADDRESS:7000 + tcp:$MACHINE_IP_ADDRESS:7000 # For newer firmware versions with SSL network access socat openssl-listen:7443,reuseaddr,fork,cert=server.pem,verify=0 \ openssl:$MACHINE_IP_ADDRESS:7443,openssl-min-proto-version=SSLv3,verify=0 - socat openssl-listen:7443,reuseaddr,fork,cert=server.pem,verify=0,bind=$SERVER_NETWORK_IP \ + socat openssl-listen:7443,reuseaddr,fork,cert=server.pem,verify=0,bind=$SERVER_NETWORK_IP \ openssl:$MACHINE_IP_ADDRESS:7443,openssl-min-proto-version=SSLv3,verify=0 To allow access on a *public*, or otherwise untrusted network, you can @@ -72,8 +72,8 @@ the server certificate, you can also specify ``server_ca_file``. .. code:: python from qslib import Machine - m = Machine('qpcr1.example.com', - client_certificate_path='client.pem', + m = Machine('qpcr1.example.com', + client_certificate_path='client.pem', server_ca_file='ca.pem') print(m.machine_status()) diff --git a/src/qslib/experiment.py b/src/qslib/experiment.py index 3c05feb..66d8dde 100644 --- a/src/qslib/experiment.py +++ b/src/qslib/experiment.py @@ -62,7 +62,6 @@ from .version import __version__ if TYPE_CHECKING: # pragma: no cover - import matplotlib.pyplot as plt from matplotlib.axes import Axes from matplotlib.lines import Line2D @@ -487,8 +486,6 @@ def info_html(self) -> str: summary = self.info(plate="table") import matplotlib.pyplot as plt - from matplotlib.axes import Axes - from matplotlib.lines import Line2D fig, ax = plt.subplots(figsize=(21.0 / 2.54, 15.0 / 2.54)) self.protocol.plot_protocol(ax) diff --git a/src/qslib/protocol.py b/src/qslib/protocol.py index ace6fee..034a85b 100644 --- a/src/qslib/protocol.py +++ b/src/qslib/protocol.py @@ -442,8 +442,7 @@ def from_scpicommand(cls, sc: SCPICommand) -> Hold: class XMLable(ABC): @abstractmethod - def to_xml(self, **kwargs: Any) -> ET.Element: - ... + def to_xml(self, **kwargs: Any) -> ET.Element: ... G = TypeVar("G") @@ -456,12 +455,10 @@ def __init__(self, val_list: list[G]): self._list = val_list @overload - def _translate_key(self, key: int | str) -> int: - ... + def _translate_key(self, key: int | str) -> int: ... @overload - def _translate_key(self, key: slice) -> slice: - ... + def _translate_key(self, key: slice) -> slice: ... def _translate_key(self, key: int | str | slice) -> int | slice: if isinstance(key, int): @@ -475,12 +472,10 @@ def __getitem__(self, key: int | str | slice) -> G | list[G]: return self._list[self._translate_key(key)] @overload - def __setitem__(self, key: int | str, val: G) -> None: - ... + def __setitem__(self, key: int | str, val: G) -> None: ... @overload - def __setitem__(self, key: slice, val: Sequence[G]) -> None: - ... + def __setitem__(self, key: slice, val: Sequence[G]) -> None: ... def __setitem__(self, key, val): self._list.__setitem__(self._translate_key(key), val) @@ -533,8 +528,8 @@ def duration_at_cycle_point( ) -> IntQuantity: # cycle from 1 return Q_(0, "second") - def temperatures_at_cycle(self, cycle: int) -> ArrayQuantity: - return Q_(np.array(6 * [math.nan]), "degC") + def temperatures_at_cycle(self, cycle: int) -> list[ArrayQuantity]: + return [Q_(np.array(6 * [math.nan]), "degC")] def temperatures_at_cycle_point(self, cycle: int, point: int) -> ArrayQuantity: return Q_(np.array(6 * [math.nan]), "degC") @@ -1899,9 +1894,9 @@ def to_xml( " placeholder for the real protocol, contained as" " an SCPI command in QSLibProtocolCommand." ) - _set_or_create( - qe, "QSLibProtocolCommand" - ).text = self.to_scpicommand().to_string() + _set_or_create(qe, "QSLibProtocolCommand").text = ( + self.to_scpicommand().to_string() + ) _set_or_create(qe, "QSLibProtocol").text = str(attr.asdict(self)) _set_or_create(qe, "QSLibVerson").text = __version__ _set_or_create(e, "CoverTemperature").text = str(covertemperature) diff --git a/src/qslib/qsconnection_async.py b/src/qslib/qsconnection_async.py index ed5cb53..8eb5507 100644 --- a/src/qslib/qsconnection_async.py +++ b/src/qslib/qsconnection_async.py @@ -44,12 +44,10 @@ def _parse_argstring(argstring: str) -> Dict[str, str]: return args -class AlreadyCollectedError(Exception): - ... +class AlreadyCollectedError(Exception): ... -class RunNotFinishedError(Exception): - ... +class RunNotFinishedError(Exception): ... @dataclass(frozen=True, order=True, eq=True) @@ -126,8 +124,7 @@ async def list_files( leaf: str = "FILE", verbose: Literal[True], recursive: bool = False, - ) -> list[dict[str, Any]]: - ... + ) -> list[dict[str, Any]]: ... @overload async def list_files( @@ -137,8 +134,7 @@ async def list_files( leaf: str = "FILE", verbose: Literal[False], recursive: bool = False, - ) -> list[str]: - ... + ) -> list[str]: ... @overload async def list_files( @@ -148,8 +144,7 @@ async def list_files( leaf: str = "FILE", verbose: bool = False, recursive: bool = False, - ) -> list[str] | list[dict[str, Any]]: - ... + ) -> list[str] | list[dict[str, Any]]: ... async def list_files( self, @@ -474,8 +469,7 @@ async def get_filterdata_one( *, run: Optional[str] = None, return_files: Literal[True], - ) -> tuple[data.FilterDataReading, list[tuple[str, bytes]]]: - ... + ) -> tuple[data.FilterDataReading, list[tuple[str, bytes]]]: ... @overload async def get_filterdata_one( @@ -484,8 +478,7 @@ async def get_filterdata_one( *, run: Optional[str] = None, return_files: Literal[False] = False, - ) -> data.FilterDataReading: - ... + ) -> data.FilterDataReading: ... async def get_filterdata_one( self, @@ -527,14 +520,12 @@ async def get_filterdata_one( @overload async def get_all_filterdata( self, run: Optional[str], as_list: Literal[True] - ) -> List[data.FilterDataReading]: - ... + ) -> List[data.FilterDataReading]: ... @overload async def get_all_filterdata( self, run: Optional[str], as_list: Literal[False] - ) -> pd.DataFrame: - ... + ) -> pd.DataFrame: ... async def get_all_filterdata( self, run: str | None = None, as_list: bool = False