Skip to content

Commit

Permalink
linting with black (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
zarath authored Jan 19, 2025
1 parent 49fcbd8 commit 12f958b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/NanoVNASaver/Controls/SerialControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SerialControl(Control):

# true when serial port was connected and false when it was disconnected
connected = QtCore.pyqtSignal(bool)

def __init__(self, app: QtWidgets.QWidget):
super().__init__(app, "Serial port control")

Expand Down Expand Up @@ -118,7 +118,7 @@ def connect_device(self):
self.btn_toggle.repaint()

self.connected.emit(True)

try:
frequencies = self.app.vna.read_frequencies()
except ValueError:
Expand Down Expand Up @@ -164,10 +164,10 @@ def update_connect_btn_state(self) -> None:
port_selected = self.inp_port.currentData() is not None
self.btn_toggle.setEnabled(self.is_vna_connected() or port_selected)

def is_vna_connected(self) -> bool:
def is_vna_connected(self) -> bool:
return self.app.vna and self.app.vna.connected()

def update_settings_state(self, was_connected: bool) -> None:
self.btn_rescan.setEnabled(not was_connected)
self.btn_settings.setEnabled(was_connected)
self.update_connect_btn_state()
self.update_connect_btn_state()
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Controls/SweepControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,4 @@ def update_sweep(self):
)

def update_sweep_btn(self, enabled: bool) -> None:
self.btn_start.setEnabled(enabled)
self.btn_start.setEnabled(enabled)
1 change: 1 addition & 0 deletions src/NanoVNASaver/Hardware/Hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def get_VNA(iface: Interface) -> VNA:
# serial_port.timeout = TIMEOUT
return NAME2DEVICE[iface.comment](iface)


def get_comment(iface: Interface) -> str:
logger.info("Finding correct VNA type...")
with iface.lock:
Expand Down
10 changes: 7 additions & 3 deletions src/NanoVNASaver/Hardware/NanoVNA_F_V3.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ def getScreenshot(self) -> QPixmap:
except serial.SerialException as exc:
logger.exception("Exception while capturing screenshot: %s", exc)
return QPixmap()

def read_features(self):
super().read_features()
result = " ".join(self.exec_command("help")).split()
if "sn:" or "SN:" in result:
self.features.add("SN")
self.SN = self.getSerialNumber()

def getSerialNumber(self) -> str:
return " ".join(list(self.exec_command("SN"))) if 'SN:' in " ".join(self.exec_command("help")).split() else " ".join(list(self.exec_command("sn")))
return (
" ".join(list(self.exec_command("SN")))
if "SN:" in " ".join(self.exec_command("help")).split()
else " ".join(list(self.exec_command("sn")))
)
15 changes: 8 additions & 7 deletions src/NanoVNASaver/Hardware/TinySA.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,22 @@ def __init__(self, iface: Interface):
# version 0.3.x is for tinySA
self.name = "tinySA"
self.sweep_max_freq_Hz = 0.96e9



def read_firmware_version(self) -> "Version":
'''For example, command version in TinySA returns as this
"""For example, command version in TinySA returns as this
tinySA4_v1.4-193-g6ff182b
HW Version:V0.5.4 max2871
'''
"""
result = list(self.exec_command("version"))
logger.debug("firmware version result:\n%s", result[0])
# transform from tinySA4_v1.4-193-g6ff182b to 1.4.193
major_minor_version, revision_version, hash = result[0].split("_v")[1].split("-")
major_minor_version, revision_version, hash = (
result[0].split("_v")[1].split("-")
)
revision_version = revision_version.split("-")[0]
return Version(major_minor_version+"."+revision_version)
return Version(major_minor_version + "." + revision_version)

def read_hardware_revision(self) -> str:
result = list(self.exec_command("version"))
logger.debug("hardware version result:\n%s", result[1])
return Version(result[1])
return Version(result[1])
6 changes: 4 additions & 2 deletions src/NanoVNASaver/NanoVNASaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ def __init__(self) -> None:

self.interface = Interface("serial", "None")
self.vna: type[VNA] = VNA(self.interface)

self.sweep_control = SweepControl(self)
self.marker_control = MarkerControl(self)
self.serial_control = SerialControl(self)
self.serial_control.connected.connect(self.sweep_control.update_sweep_btn)
self.serial_control.connected.connect(
self.sweep_control.update_sweep_btn
)

self.bands = BandsModel()

Expand Down
3 changes: 2 additions & 1 deletion src/NanoVNASaver/app_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
except importlib.metadata.PackageNotFoundError: # pragma: no cover
# Looks like we neded this case for apps out of pyinstaller packages
from ._version import version
APP_VERSION = version

APP_VERSION = version

0 comments on commit 12f958b

Please sign in to comment.