Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cgevans committed Oct 13, 2024
1 parent 025df6f commit c6c55b8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
8 changes: 4 additions & 4 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down
3 changes: 0 additions & 3 deletions src/qslib/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
25 changes: 10 additions & 15 deletions src/qslib/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 9 additions & 18 deletions src/qslib/qsconnection_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c6c55b8

Please sign in to comment.