Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.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: '25.1.0'
- repo: https://github.com/psf/black-pre-commit-mirror
rev: '25.9.0'
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 6.0.1
rev: 7.0.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: '7.1.2'
rev: '7.3.0'
hooks:
- id: flake8
additional_dependencies:
- flake8-typing-imports==1.16.0
- flake8-typing-imports==1.17.0
language_version: python3
exclude: "^(build|docs|tests|setup.py)"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.15.0'
rev: 'v1.18.2'
hooks:
- id: mypy
additional_dependencies: [numpy<1.25, pyusb>=1.0]
additional_dependencies: [numpy>=2.0, pyusb>=1.0]
exclude: "^(build|docs|tests|dev|setup.py)"
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.21.0
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.6
rev: v0.18.1
hooks:
- id: cython-lint
- id: double-quote-cython-strings
1 change: 0 additions & 1 deletion src/seabreeze/pyseabreeze/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def _seabreeze_device_factory(
-------
dev : SeaBreezeDevice
"""
global _seabreeze_device_instance_registry
if not isinstance(device, (USBTransportHandle, IPv4TransportHandle)):
raise TypeError(
f"needs to be instance of USBTransportHandle or IPv4TransportHandle and not '{type(device)}'"
Expand Down
14 changes: 7 additions & 7 deletions src/seabreeze/pyseabreeze/features/spectrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_wavelengths(self) -> NDArray[np.float64]:
coeffs.append(
float(self._eeprom_cls._func_eeprom_read_slot(self.protocol, i))
)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore
return sum(wl * (indices**i) for i, wl in enumerate(coeffs))

def get_intensities(self) -> NDArray[np.float64]:
tmp = self._get_spectrum_raw()
Expand Down Expand Up @@ -425,11 +425,11 @@ def get_wavelengths(self) -> NDArray[np.float64]:
coeffs.append(struct.unpack("<f", data)[0])
# and generate the wavelength array
indices = numpy.arange(self._spectrum_length, dtype=numpy.float64)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore
return sum(wl * (indices**i) for i, wl in enumerate(coeffs))

def get_intensities(self) -> NDArray[np.float64]:
tmp = self._get_spectrum_raw()
arr = struct.unpack("<" + "H" * self._spectrum_length, tmp) # type: ignore
arr = struct.unpack("<" + "H" * self._spectrum_length, tmp)
return numpy.array(arr, dtype=numpy.float64)

def _get_spectrum_raw(self) -> NDArray[np.uint8]:
Expand Down Expand Up @@ -489,7 +489,7 @@ def get_wavelengths(self) -> NDArray[np.float64]:
SeaBreezeEEPromFeatureOOI._func_eeprom_read_slot(self.protocol, i)
)
)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore
return sum(wl * (indices**i) for i, wl in enumerate(coeffs))

def get_intensities(self) -> NDArray[np.float64]:
tmp = self._get_spectrum_raw()
Expand Down Expand Up @@ -643,7 +643,7 @@ def get_wavelengths(self) -> NDArray[np.float64]:
coeffs = struct.unpack("<" + "f" * num_coeffs, data)[1:]
# and generate the wavelength array
indices = numpy.arange(self._spectrum_length, dtype=numpy.float64)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore
return sum(wl * (indices**i) for i, wl in enumerate(coeffs))


class SeaBreezeSpectrometerFeatureOBP2(SeaBreezeSpectrometerFeatureOBP):
Expand Down Expand Up @@ -684,7 +684,7 @@ def get_wavelengths(self) -> NDArray[np.float64]:
coeffs = struct.unpack("<" + "f" * num_coeffs, data)[1:]
# and generate the wavelength array
indices = numpy.arange(self._spectrum_length, dtype=numpy.float64)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore
return sum(wl * (indices**i) for i, wl in enumerate(coeffs))


class SeaBreezeSpectrometerFeatureSR4(SeaBreezeSpectrometerFeatureOBP2):
Expand Down Expand Up @@ -737,7 +737,7 @@ def get_wavelengths(self) -> NDArray[np.float64]:
coeffs = struct.unpack("<" + "f" * num_coeffs, data)[1:]
# and generate the wavelength array
indices = numpy.arange(self._spectrum_length, dtype=numpy.float64)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore
return sum(wl * (indices**i) for i, wl in enumerate(coeffs))


class SeaBreezeSpectrometerFeatureHR4(SeaBreezeSpectrometerFeatureOBP2):
Expand Down
4 changes: 2 additions & 2 deletions src/seabreeze/pyseabreeze/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def list_devices(cls, **kwargs: Any) -> Iterable[USBTransportHandle]:
unique pyusb devices for each available spectrometer
"""
# check if a specific pyusb backend is requested
_pyusb_backend = kwargs.get("pyusb_backend", None)
_pyusb_backend: str | None = kwargs.get("pyusb_backend", None)
# get all matching devices
try:
pyusb_devices = usb.core.find(
Expand Down Expand Up @@ -340,7 +340,7 @@ def shutdown(cls, **_kwargs: Any) -> None:
_pyusb_backend_instances: dict[str, usb.backend.IBackend] = {}


def get_pyusb_backend_from_name(name: str) -> usb.backend.IBackend:
def get_pyusb_backend_from_name(name: str | None) -> usb.backend.IBackend:
"""internal: allow requesting a specific pyusb backend for testing"""
if name is None:
# default is pick first that works: ('libusb1', 'libusb0', 'openusb')
Expand Down