Skip to content

pyseabreeze: Lazy loading of SeaBreezeError results in warning #248

@hperrey

Description

@hperrey

spectrometer and system information

  • model: HDX
  • operating system: CentOS Linux release 7.9.2009
  • python version: Python 3.9.16 or 3.11.9
  • python-seabreeze version: 2.9.0
  • installed-via: conda

current problem

When issuing seabreeze.use() after importing SeaBreezeError, the following warning will be shown:

 UserWarning: seabreeze.use has to be called before instantiating a spectrometer

steps to reproduce

The following code will trigger the warning:

import seabreeze
from seabreeze.spectrometers import SeaBreezeError
seabreeze.use("pyseabreeze", network_adapter="192.168.254.200")

On the other hand, just importing the Spectrometer works fine:

import seabreeze
from seabreeze.spectrometers import Spectrometer
seabreeze.use("pyseabreeze", network_adapter="192.168.254.200")

I have not investigated the cause further, but from cross-reading the code, I expected that SeaBreezeError would be lazy-loaded as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions