Skip to content

Commit

Permalink
chore: linting with black and ruff (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
zarath authored Jan 26, 2025
1 parent 9ca8d0f commit 428ecb0
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ disable=W0614,C0410,C0321,C0111,I0011,C0103
# allow ls for list
good-names=_,a,b,c,dt,db,e,f,fn,fd,i,j,k,v,kv,kw,l,m,n,ls,t,t0,t1,t2,t3,w,h,x,y,z,it,op
[MASTER]
extension-pkg-allow-list=PyQt6.QtWidgets,PyQt6.QtGui,PyQt6.QtCore
extension-pkg-allow-list=PySide6.QtWidgets,PySide6.QtGui,PySide6.QtCore
1 change: 0 additions & 1 deletion src/NanoVNASaver/Controls/SerialControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from PySide6 import QtWidgets
from PySide6.QtCore import Signal


from NanoVNASaver.Controls.Control import Control
from NanoVNASaver.Hardware.Hardware import Interface, get_interfaces, get_VNA

Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Hardware/Hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from NanoVNASaver.Hardware.AVNA import AVNA
from NanoVNASaver.Hardware.JNCRadio_VNA_3G import JNCRadio_VNA_3G
from NanoVNASaver.Hardware.LiteVNA64 import LiteVNA64
from NanoVNASaver.Hardware.NanoVNA import NanoVNA
from NanoVNASaver.Hardware.NanoVNA_F import NanoVNA_F
from NanoVNASaver.Hardware.NanoVNA_F_V2 import NanoVNA_F_V2
Expand All @@ -38,7 +39,6 @@
from NanoVNASaver.Hardware.SV4401A import SV4401A
from NanoVNASaver.Hardware.SV6301A import SV6301A
from NanoVNASaver.Hardware.TinySA import TinySA, TinySA_Ultra
from NanoVNASaver.Hardware.LiteVNA64 import LiteVNA64
from NanoVNASaver.Hardware.VNA import VNA

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions src/NanoVNASaver/Hardware/NanoVNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from NanoVNASaver.Hardware.Serial import Interface, drain_serial
from NanoVNASaver.Hardware.VNA import VNA

from ..utils import Version

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions src/NanoVNASaver/Hardware/NanoVNA_V2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from NanoVNASaver.Hardware.Serial import Interface
from NanoVNASaver.Hardware.VNA import VNA

from ..utils import Version

if platform.system() != "Windows":
Expand Down
1 change: 1 addition & 0 deletions src/NanoVNASaver/Hardware/TinySA.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from NanoVNASaver.Hardware.Serial import Interface, drain_serial
from NanoVNASaver.Hardware.VNA import VNA

from ..utils import Version

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions src/NanoVNASaver/Hardware/VNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from PySide6 import QtGui

from NanoVNASaver.Hardware.Serial import Interface, drain_serial

from ..utils import Version

logger = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion src/NanoVNASaver/Windows/About.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self, app: QtWidgets.QWidget):

self.ui.btn_updates.clicked.connect(self.find_updates)


def show(self):
super().show()
self.update_labels()
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Windows/Screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from PySide6 import QtCore, QtGui, QtWidgets

#from .ui import get_window_icon
# from .ui import get_window_icon

logger = logging.getLogger(__name__)

Expand Down
7 changes: 3 additions & 4 deletions src/NanoVNASaver/Windows/SweepSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
)
from NanoVNASaver.Settings.Sweep import SweepMode
from NanoVNASaver.Windows.Defaults import make_scrollable

from .ui import get_window_icon

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -230,12 +231,10 @@ def update_band(self, apply: bool = False):
self.band_list.currentIndex(), 2
)
start = int(
self.band_list.model()
.data(index_start, Qt.ItemDataRole.EditRole)
self.band_list.model().data(index_start, Qt.ItemDataRole.EditRole)
)
stop = int(
self.band_list.model()
.data(index_stop, Qt.ItemDataRole.EditRole)
self.band_list.model().data(index_stop, Qt.ItemDataRole.EditRole)
)

if self.padding > 0:
Expand Down
1 change: 1 addition & 0 deletions src/NanoVNASaver/Windows/TDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from scipy.signal import convolve # type: ignore

from NanoVNASaver.Windows.Defaults import make_scrollable

from .ui import get_window_icon

logger = logging.getLogger(__name__)
Expand Down
7 changes: 6 additions & 1 deletion src/NanoVNASaver/Windows/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ def get_window_icon() -> QIcon:
return icon


__all__ = ["qInitResources", "Ui_DialogAbout", "WINDOW_ICON_RES", "get_window_icon"]
__all__ = [
"qInitResources",
"Ui_DialogAbout",
"WINDOW_ICON_RES",
"get_window_icon",
]
2 changes: 1 addition & 1 deletion src/NanoVNASaver/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
from PySide6 import QtWidgets

from NanoVNASaver.About import INFO, VERSION
from NanoVNASaver.utils import get_runtime_information
from NanoVNASaver.NanoVNASaver import NanoVNASaver
from NanoVNASaver.Touchstone import Touchstone
from NanoVNASaver.utils import get_runtime_information


def main():
Expand Down
9 changes: 6 additions & 3 deletions src/NanoVNASaver/utils/app_versions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import platform
from functools import cache
from importlib.metadata import PackageNotFoundError, distributions, version

UNKNOWN_VERSION = "unknown"


@cache
def get_app_version() -> str:
try:
Expand All @@ -13,13 +13,16 @@ def get_app_version() -> str:
except PackageNotFoundError: # pragma: no cover
return UNKNOWN_VERSION


@cache
def get_lib_versions() -> list[str]:
return [f"{dist.name}: {dist.version}" for dist in distributions()]
return [f"{dist.name}: {dist.version}" for dist in distributions()]


@cache
def get_host_platform() -> list[str]:
return [ f"Platform: {platform.platform()}", f"CPU: {platform.processor()}"]
return [f"Platform: {platform.platform()}", f"CPU: {platform.processor()}"]


def get_runtime_information() -> list[str]:
return get_host_platform() + get_lib_versions()
12 changes: 6 additions & 6 deletions src/tools/project_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ def main() -> None:
rm_dir("build")

print("Removing '*.egg-info' dir...")
for dir in glob.glob('./src/**/*.egg-info', recursive=True):
for dir in glob.glob("./src/**/*.egg-info", recursive=True):
rm_dir(dir)

print("Removing '__pycache__' dirs...")
for dir in glob.glob('./src/**/__pycache__', recursive=True):
for dir in glob.glob("./src/**/__pycache__", recursive=True):
rm_dir(dir)
for dir in glob.glob('./tests/**/__pycache__', recursive=True):
for dir in glob.glob("./tests/**/__pycache__", recursive=True):
rm_dir(dir)

print("Removing log files...")
for file in glob.glob('./**/*.log', recursive=True):
for file in glob.glob("./**/*.log", recursive=True):
rm_dir(file)


def rm_dir(dir_or_file: str|Path) -> None:
if isinstance(dir_or_file,str):
def rm_dir(dir_or_file: str | Path) -> None:
if isinstance(dir_or_file, str):
dir_or_file = Path(dir_or_file)
if dir_or_file.is_file():
dir_or_file.unlink()
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 428ecb0

Please sign in to comment.