diff --git a/pyvisa_py/__init__.py b/pyvisa_py/__init__.py index 46d33941..5abeb937 100644 --- a/pyvisa_py/__init__.py +++ b/pyvisa_py/__init__.py @@ -10,6 +10,12 @@ import logging from importlib.metadata import PackageNotFoundError, version +# we need to import so that __init_subclass__() is executed once (hence the noqa) +from . import attributes # noqa: F401 +from .highlevel import PyVisaLibrary + +# Global pyvisa-py logger used to provide more details on errors (VISA error code +# can make some report rather terse). LOGGER = logging.getLogger("pyvisa.pyvisa-py") __version__ = "unknown" @@ -19,8 +25,4 @@ # package is not installed pass -# we need to import so that __init_subclass__() is executed once (hence the noqa) -from . import attributes # noqa: F401 -from .highlevel import PyVisaLibrary - WRAPPER_CLASS = PyVisaLibrary diff --git a/pyvisa_py/highlevel.py b/pyvisa_py/highlevel.py index d9eba98c..baf29ed9 100644 --- a/pyvisa_py/highlevel.py +++ b/pyvisa_py/highlevel.py @@ -168,7 +168,7 @@ def open( try: sess = cls(session, resource_name, parsed, open_timeout) except sessions.OpenError as e: - return 0, e.error_code + return VISASession(0), e.error_code return self._register(sess), StatusCode.success diff --git a/pyvisa_py/tcpip.py b/pyvisa_py/tcpip.py index d7ce29b7..be4c1446 100644 --- a/pyvisa_py/tcpip.py +++ b/pyvisa_py/tcpip.py @@ -18,11 +18,10 @@ from pyvisa import attributes, constants, errors, rname from pyvisa.constants import BufferOperation, ResourceAttribute, StatusCode -from . import common, LOGGER +from . import LOGGER, common from .protocols import hislip, rpc, vxi11 from .sessions import OpenError, Session, UnknownAttribute, VISARMSession - # Let psutil be optional dependency try: import psutil # type: ignore diff --git a/pyvisa_py/testsuite/test_sessions.py b/pyvisa_py/testsuite/test_sessions.py index 9124a191..7618d7de 100644 --- a/pyvisa_py/testsuite/test_sessions.py +++ b/pyvisa_py/testsuite/test_sessions.py @@ -10,7 +10,6 @@ from pyvisa.constants import InterfaceType from pyvisa.testsuite import BaseTestCase -import pyvisa_py.highlevel from pyvisa_py.sessions import Session