Skip to content

Commit

Permalink
Merge pull request #124 from NTIA/drop-python-3.8
Browse files Browse the repository at this point in the history
Drop support for Python 3.8, add support for Python 3.12
  • Loading branch information
aromanielloNTIA authored Nov 7, 2024
2 parents 177d6a1 + b04bdf0 commit c1314e7
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 88 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
py:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Set up Python ${{ matrix.py }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Checkout scos-actions
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install tox-gh
run: python -m pip install tox-gh
- name: Set up test suite
Expand Down
12 changes: 5 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
types: [file, python]
Expand All @@ -18,10 +16,10 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.19.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
args: ["--py39-plus"]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
Expand All @@ -30,12 +28,12 @@ repos:
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
hooks:
- id: black
types: [file, python]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.42.0
hooks:
- id: markdownlint
types: [file, markdown]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ if the new functionality can be supported by most signal analyzers.
### Requirements and Configuration

Set up a development environment using a tool like [Conda](https://docs.conda.io/en/latest/)
or [venv](https://docs.python.org/3/library/venv.html#module-venv), with `python>=3.8`. Then,
or [venv](https://docs.python.org/3/library/venv.html#module-venv), with `python>=3.9`. Then,
from the cloned directory, install the development dependencies by running:

```bash
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "scos-actions"
dynamic = ["version"]
description = "The base plugin providing common actions and interfaces for SCOS Sensor plugins"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = { file = "LICENSE.md" }

authors = [
Expand Down Expand Up @@ -35,32 +35,32 @@ classifiers = [
"Environment :: Plugins",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

dependencies = [
"environs>=9.5.0",
"django>=4.2,<5.0",
"django>=4.2.8,<5.0", # As of 4.2.8, Python 3.13 is not supported.
"its_preselector @ git+https://github.com/NTIA/[email protected]",
"msgspec>=0.16.0,<1.0.0",
"numexpr>=2.8.3",
"numpy>=1.22.0",
"numpy>=1.25.0",
"psutil>=5.9.4",
"python-dateutil>=2.0",
"ray>=2.10.0",
"ruamel.yaml>=0.15",
"scipy>=1.8.0",
"scipy>=1.11.4",
"sigmf @ git+https://github.com/NTIA/SigMF@multi-recording-archive",
]

[project.optional-dependencies]
test = [
"pytest>=7.3.1,<8.0",
"pytest-cov>=4.0.0,<5.0",
"tox>=4.5.1,<5.0",
"pytest>=8.0,<9.0",
"pytest-cov>=6.0,<7.0",
"tox>=4.5.1,<5.0", # Keep in sync with min_version in tox.ini
]
dev = [
"hatchling>=1.14.1,<2.0",
Expand Down
5 changes: 2 additions & 3 deletions scos_actions/actions/acquire_sea_data_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import sys
from enum import EnumMeta
from time import perf_counter
from typing import Tuple

import numpy as np
import psutil
Expand Down Expand Up @@ -261,7 +260,7 @@ def __init__(
self.detector = detector
self.impedance_ohms = impedance_ohms

def run(self, iq: ray.ObjectRef) -> Tuple[np.ndarray, np.ndarray]:
def run(self, iq: ray.ObjectRef) -> tuple[np.ndarray, np.ndarray]:
"""
Compute power versus time results from IQ samples.
Expand Down Expand Up @@ -399,7 +398,7 @@ class IQProcessor:
The ``run`` method can be called to filter and process IQ samples.
Filtering happens before the remote workers are called, which run
concurrently. The ``run`` method returns Ray object references
immediately, which can be later used to retrieve the procesed results.
immediately, which can be later used to retrieve the processed results.
"""

def __init__(self, params: dict, iir_sos: np.ndarray):
Expand Down
6 changes: 3 additions & 3 deletions scos_actions/calibration/interfaces/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from abc import abstractmethod
from pathlib import Path
from typing import List, get_origin
from typing import get_origin

from scos_actions.calibration.utils import (
CalibrationParametersMissingException,
Expand All @@ -28,7 +28,7 @@ class Calibration:
updates (if allowed) will be saved.
"""

calibration_parameters: List[str]
calibration_parameters: list[str]
calibration_data: dict
calibration_reference: str
file_path: Path
Expand All @@ -43,7 +43,7 @@ def __post_init__(self):
def _validate_fields(self) -> None:
"""Loosely check that the input types are as expected."""
for f_name, f_def in self.__dataclass_fields__.items():
# Note that nested types are not checked: i.e., "List[str]"
# Note that nested types are not checked: i.e., "list[str]"
# will surely be a list, but may not be filled with strings.
f_type = get_origin(f_def.type) or f_def.type
actual_value = getattr(self, f_name)
Expand Down
3 changes: 1 addition & 2 deletions scos_actions/calibration/tests/test_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import dataclasses
import json
from pathlib import Path
from typing import List

import pytest

Expand Down Expand Up @@ -57,7 +56,7 @@ def test_calibration_dataclass_fields(self):
fields = {f.name: f.type for f in dataclasses.fields(Calibration)}
# Note: does not check field order
assert fields == {
"calibration_parameters": List[str],
"calibration_parameters": list[str],
"calibration_reference": str,
"calibration_data": dict,
"file_path": Path,
Expand Down
12 changes: 6 additions & 6 deletions scos_actions/hardware/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import hashlib
import json
import logging
from typing import Any, Dict, List, Optional
from typing import Any, Optional

import numpy as np
from its_preselector.preselector import Preselector
Expand Down Expand Up @@ -38,7 +38,7 @@ def __init__(
capabilities: dict,
gps: Optional[GPSInterface] = None,
preselector: Optional[Preselector] = None,
switches: Optional[Dict[str, WebRelay]] = {},
switches: Optional[dict[str, WebRelay]] = {},
location: Optional[dict] = None,
sensor_cal: Optional[SensorCalibration] = None,
differential_cal: Optional[DifferentialCalibration] = None,
Expand Down Expand Up @@ -93,15 +93,15 @@ def preselector(self, preselector: Preselector):
self._preselector = preselector

@property
def switches(self) -> Dict[str, WebRelay]:
def switches(self) -> dict[str, WebRelay]:
"""
Dictionary of WebRelays, indexed by name. WebRelays may enable/disable other
components within the sensor and/or provide a variety of sensors.
"""
return self._switches

@switches.setter
def switches(self, switches: Dict[str, WebRelay]):
def switches(self, switches: dict[str, WebRelay]):
self._switches = switches

@property
Expand Down Expand Up @@ -213,12 +213,12 @@ def last_calibration_time(self) -> str:
)

@property
def sensor_calibration_data(self) -> Dict[str, Any]:
def sensor_calibration_data(self) -> dict[str, Any]:
"""Sensor calibration data for the current sensor settings."""
return self._sensor_calibration_data

@property
def differential_calibration_data(self) -> Dict[str, float]:
def differential_calibration_data(self) -> dict[str, float]:
"""Differential calibration data for the current sensor settings."""
return self._differential_calibration_data

Expand Down
4 changes: 2 additions & 2 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import time
from abc import ABC, abstractmethod
from typing import Dict, Optional
from typing import Optional

from its_preselector.web_relay import WebRelay

Expand All @@ -13,7 +13,7 @@
class SignalAnalyzerInterface(ABC):
def __init__(
self,
switches: Optional[Dict[str, WebRelay]] = None,
switches: Optional[dict[str, WebRelay]] = None,
):
self._model = "Unknown"
self._api_version = "Unknown"
Expand Down
4 changes: 2 additions & 2 deletions scos_actions/hardware/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import subprocess
from typing import Dict, Tuple, Union
from typing import Union

import psutil
from its_preselector.web_relay import WebRelay
Expand Down Expand Up @@ -127,7 +127,7 @@ def get_max_cpu_temperature(fahrenheit: bool = False) -> float:
raise e


def power_cycle_sigan(switches: Dict[str, WebRelay]):
def power_cycle_sigan(switches: dict[str, WebRelay]):
"""
Performs a hard power cycle of the signal analyzer. This method requires power to the signal analyzer is
controlled by a Web_Relay (see https://www.github.com/ntia/Preselector) and that the switch id of that
Expand Down
16 changes: 8 additions & 8 deletions scos_actions/metadata/sigmf_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from typing import List, Union
from typing import Union

import msgspec
from sigmf import SigMFFile
Expand Down Expand Up @@ -268,15 +268,15 @@ def set_collection(self, collection: str) -> None:

### ntia-algorithm v2.0.1 ###

def set_data_products(self, data_products: List[Graph]) -> None:
def set_data_products(self, data_products: list[Graph]) -> None:
"""
Set the value of the Global "ntia-algorithm:data_products" field.
:param data_products: List of data products produced for each capture.
"""
self.sigmf_md.set_global_field("ntia-algorithm:data_products", data_products)

def set_processing(self, processing: List[str]) -> None:
def set_processing(self, processing: list[str]) -> None:
"""
Set the value of the Global "ntia-algorithm:processing" field.
Expand All @@ -286,7 +286,7 @@ def set_processing(self, processing: List[str]) -> None:
self.sigmf_md.set_global_field("ntia-algorithm:processing", processing)

def set_processing_info(
self, processing_info: List[Union[DigitalFilter, DFT]]
self, processing_info: list[Union[DigitalFilter, DFT]]
) -> None:
"""
Set the value of the Global "ntia-algorithm:processing_info" field.
Expand Down Expand Up @@ -324,7 +324,7 @@ def set_diagnostics(self, diagnostics: Diagnostics) -> None:
### ntia-nasctn-sea v0.6.0 ###

def set_max_of_max_channel_powers(
self, max_of_max_channel_powers: List[float]
self, max_of_max_channel_powers: list[float]
) -> None:
"""
Set the value of the Global "ntia-nasctn-sea:max_of_max_channel_powers" field.
Expand All @@ -335,7 +335,7 @@ def set_max_of_max_channel_powers(
"ntia-nasctn-sea:max_of_max_channel_powers", max_of_max_channel_powers
)

def set_mean_channel_powers(self, mean_channel_powers: List[float]) -> None:
def set_mean_channel_powers(self, mean_channel_powers: list[float]) -> None:
"""
Set the value of the Global "ntia-nasctn-sea:mean_channel_powers" field.
Expand All @@ -345,7 +345,7 @@ def set_mean_channel_powers(self, mean_channel_powers: List[float]) -> None:
"ntia-nasctn-sea:mean_channel_powers", mean_channel_powers
)

def set_median_channel_powers(self, median_channel_powers: List[float]) -> None:
def set_median_channel_powers(self, median_channel_powers: list[float]) -> None:
"""
Set the value of the Global "ntia-nasctn-sea:median_channel_powers" field.
Expand All @@ -356,7 +356,7 @@ def set_median_channel_powers(self, median_channel_powers: List[float]) -> None:
)

def set_median_of_mean_channel_powers(
self, median_of_mean_channel_powers: List[float]
self, median_of_mean_channel_powers: list[float]
) -> None:
"""
Set the value of the Global "ntia-nasctn-sea:median_of_mean_channel_powers" field.
Expand Down
Loading

0 comments on commit c1314e7

Please sign in to comment.