diff --git a/.github/workflows/run_test_build_deploy.yaml b/.github/workflows/run_test_build_deploy.yaml index 8ea51a9a..a04c84f0 100644 --- a/.github/workflows/run_test_build_deploy.yaml +++ b/.github/workflows/run_test_build_deploy.yaml @@ -15,7 +15,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 @@ -44,10 +44,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 - name: Setup libusb-dev run: | sudo apt-get install -y libusb-dev diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2acf82a1..8c4000cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: hooks: - id: flake8 additional_dependencies: - - flake8-typing-imports==1.14.0 + - flake8-typing-imports==1.16.0 language_version: python3 exclude: "^(build|docs|tests|setup.py)" - repo: https://github.com/pre-commit/mirrors-mypy @@ -37,7 +37,7 @@ repos: rev: v3.19.0 hooks: - id: pyupgrade - args: [--py38-plus] + args: [--py39-plus] - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.16.2 hooks: diff --git a/dev/pretty_print_obp_pcapng.py b/dev/pretty_print_obp_pcapng.py index f299e0af..ae240461 100644 --- a/dev/pretty_print_obp_pcapng.py +++ b/dev/pretty_print_obp_pcapng.py @@ -4,8 +4,8 @@ import enum import struct +from collections.abc import Iterable from typing import Any -from typing import Iterable try: from pcapng import FileScanner diff --git a/pyproject.toml b/pyproject.toml index 188d683a..688e7825 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires = [ ] [tool.black] -target-version = ['py38'] +target-version = ['py39'] include = '\.pyi?$' exclude = ''' ( @@ -27,7 +27,7 @@ exclude = ''' [tool.isort] profile = "black" -py_version = "38" +py_version = "39" force_single_line = true [tool.cibuildwheel] @@ -45,7 +45,7 @@ test-command = [ before-build = "yum install -y libusb-devel" [tool.mypy] -python_version = "3.8" +python_version = "3.9" no_implicit_optional = true warn_redundant_casts = true warn_unused_ignores = true diff --git a/setup.py b/setup.py index 4b921e62..884f5f7f 100644 --- a/setup.py +++ b/setup.py @@ -216,7 +216,7 @@ def win_spawn(_, cmd, *args, **kwargs): "pytest>=6.2.4; python_version>'3.9'", ], }, - python_requires=">=3.8", + python_requires=">=3.9", cmdclass={"build_ext": sb_build_ext}, ext_modules=extensions, packages=find_packages(where="src"), @@ -232,10 +232,10 @@ def win_spawn(_, cmd, *args, **kwargs): long_description_content_type="text/markdown", classifiers=[ "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", + "Programming Language :: Python :: 3.13", ], ) diff --git a/src/seabreeze/backends.py b/src/seabreeze/backends.py index 205fcec4..b73b3658 100644 --- a/src/seabreeze/backends.py +++ b/src/seabreeze/backends.py @@ -2,7 +2,6 @@ import sys import warnings from typing import Any -from typing import Dict from typing import Literal from typing import Optional from typing import cast @@ -18,7 +17,7 @@ class BackendConfig: requested = "cseabreeze" # default is cseabreeze available = ("cseabreeze", "pyseabreeze") allow_fallback = False - api_kwargs: Dict[str, Any] = {} # for pytests + api_kwargs: dict[str, Any] = {} # for pytests def use( diff --git a/src/seabreeze/pyseabreeze/config.py b/src/seabreeze/pyseabreeze/config.py index 68d14d10..759c186f 100644 --- a/src/seabreeze/pyseabreeze/config.py +++ b/src/seabreeze/pyseabreeze/config.py @@ -3,9 +3,9 @@ from __future__ import annotations import os +from collections.abc import Iterator from contextlib import contextmanager from typing import Callable -from typing import Iterator from typing import TypeVar __all__ = [ diff --git a/src/seabreeze/pyseabreeze/devices.py b/src/seabreeze/pyseabreeze/devices.py index 201b93d4..66487dea 100644 --- a/src/seabreeze/pyseabreeze/devices.py +++ b/src/seabreeze/pyseabreeze/devices.py @@ -8,9 +8,8 @@ import enum import itertools from collections import defaultdict +from collections.abc import Iterable from typing import Any -from typing import Iterable -from typing import Tuple from typing import TypeVar from seabreeze.pyseabreeze import features as sbf @@ -242,7 +241,7 @@ def __init__( self.secondary_in2 = self.highspeed_in2 = highspeed_in2 -class DarkPixelIndices(Tuple[int, ...]): +class DarkPixelIndices(tuple[int, ...]): """internal dark pixel range class""" def __new__( diff --git a/src/seabreeze/pyseabreeze/features/introspection.py b/src/seabreeze/pyseabreeze/features/introspection.py index eefd9485..952c3446 100644 --- a/src/seabreeze/pyseabreeze/features/introspection.py +++ b/src/seabreeze/pyseabreeze/features/introspection.py @@ -1,5 +1,3 @@ -from typing import Tuple - from seabreeze.pyseabreeze.features._base import SeaBreezeFeature @@ -14,11 +12,11 @@ class SeaBreezeIntrospectionFeature(SeaBreezeFeature): def number_of_pixels(self) -> int: raise NotImplementedError("implement in derived class") - def get_active_pixel_ranges(self) -> Tuple[Tuple[int, int], ...]: + def get_active_pixel_ranges(self) -> tuple[tuple[int, int], ...]: raise NotImplementedError("implement in derived class") - def get_optical_dark_pixel_ranges(self) -> Tuple[Tuple[int, int], ...]: + def get_optical_dark_pixel_ranges(self) -> tuple[tuple[int, int], ...]: raise NotImplementedError("implement in derived class") - def get_electric_dark_pixel_ranges(self) -> Tuple[Tuple[int, int], ...]: + def get_electric_dark_pixel_ranges(self) -> tuple[tuple[int, int], ...]: raise NotImplementedError("implement in derived class") diff --git a/src/seabreeze/pyseabreeze/features/nonlinearity.py b/src/seabreeze/pyseabreeze/features/nonlinearity.py index a07f3887..1e85eff1 100644 --- a/src/seabreeze/pyseabreeze/features/nonlinearity.py +++ b/src/seabreeze/pyseabreeze/features/nonlinearity.py @@ -1,5 +1,4 @@ import struct -from typing import List from seabreeze.pyseabreeze.features._base import SeaBreezeFeature from seabreeze.pyseabreeze.features.eeprom import SeaBreezeEEPromFeatureOOI @@ -14,7 +13,7 @@ class SeaBreezeNonlinearityCoefficientsFeature(SeaBreezeFeature): identifier = "nonlinearity_coefficients" - def get_nonlinearity_coefficients(self) -> List[float]: + def get_nonlinearity_coefficients(self) -> list[float]: raise NotImplementedError("implement in derived class") @@ -27,7 +26,7 @@ class NonlinearityCoefficientsEEPromFeatureOOI( _required_protocol_cls = OOIProtocol _required_features = ("eeprom",) - def get_nonlinearity_coefficients(self) -> List[float]: + def get_nonlinearity_coefficients(self) -> list[float]: # The spectrometers store the wavelength calibration in slots 6..13 coeffs = [] # noinspection PyProtectedMember @@ -50,7 +49,7 @@ def get_nonlinearity_coefficients(self) -> List[float]: class NonlinearityCoefficientsFeatureOBP(SeaBreezeNonlinearityCoefficientsFeature): _required_protocol_cls = OBPProtocol - def get_nonlinearity_coefficients(self) -> List[float]: + def get_nonlinearity_coefficients(self) -> list[float]: # get number of nonlinearity coefficients data = self.protocol.query(0x00181100) N = struct.unpack(" List[float]: class NonlinearityCoefficientsFeatureOBP2(SeaBreezeNonlinearityCoefficientsFeature): _required_protocol_cls = OBP2Protocol - def get_nonlinearity_coefficients(self) -> List[float]: + def get_nonlinearity_coefficients(self) -> list[float]: # get nonlinearity coefficients data = self.protocol.query(0x000_012_00) num_coeffs = len(data) // 4 diff --git a/src/seabreeze/pyseabreeze/features/straylightcoefficients.py b/src/seabreeze/pyseabreeze/features/straylightcoefficients.py index 0b8a5b2d..6fecc083 100644 --- a/src/seabreeze/pyseabreeze/features/straylightcoefficients.py +++ b/src/seabreeze/pyseabreeze/features/straylightcoefficients.py @@ -1,5 +1,3 @@ -from typing import List - from seabreeze.pyseabreeze.features._base import SeaBreezeFeature @@ -11,5 +9,5 @@ class SeaBreezeStrayLightCoefficientsFeature(SeaBreezeFeature): identifier = "stray_light_coefficients" - def get_stray_light_coefficients(self) -> List[float]: + def get_stray_light_coefficients(self) -> list[float]: raise NotImplementedError("implement in derived class") diff --git a/src/seabreeze/pyseabreeze/features/temperature.py b/src/seabreeze/pyseabreeze/features/temperature.py index d1448236..1f5bf52d 100644 --- a/src/seabreeze/pyseabreeze/features/temperature.py +++ b/src/seabreeze/pyseabreeze/features/temperature.py @@ -1,5 +1,3 @@ -from typing import List - from seabreeze.pyseabreeze.features._base import SeaBreezeFeature @@ -17,5 +15,5 @@ def count_temperatures(self) -> int: def read_temperature(self, index: int) -> float: raise NotImplementedError("implement in derived class") - def temperature_get_all(self) -> List[float]: + def temperature_get_all(self) -> list[float]: raise NotImplementedError("implement in derived class") diff --git a/src/seabreeze/pyseabreeze/transport.py b/src/seabreeze/pyseabreeze/transport.py index 43928e40..95c72063 100644 --- a/src/seabreeze/pyseabreeze/transport.py +++ b/src/seabreeze/pyseabreeze/transport.py @@ -14,11 +14,10 @@ import struct import warnings import weakref +from collections.abc import Iterable from functools import partialmethod from typing import TYPE_CHECKING from typing import Any -from typing import Iterable -from typing import Tuple import usb.backend import usb.core @@ -50,7 +49,7 @@ class USBTransportDeviceInUse(Exception): pass -DeviceIdentity = Tuple[int, int, int, int] +DeviceIdentity = tuple[int, int, int, int] # this can and should be opaque to pyseabreeze diff --git a/src/seabreeze/pyseabreeze/types.py b/src/seabreeze/pyseabreeze/types.py index 5f835cf4..d29e23f8 100644 --- a/src/seabreeze/pyseabreeze/types.py +++ b/src/seabreeze/pyseabreeze/types.py @@ -3,9 +3,9 @@ import weakref from abc import ABC from abc import abstractmethod +from collections.abc import Iterable from typing import Any from typing import Generic -from typing import Iterable from typing import TypeVar