Skip to content
Draft
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
28 changes: 23 additions & 5 deletions src/qcodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@

# config
import warnings
from typing import Any
from typing import TYPE_CHECKING, Any

import qcodes._version
import qcodes.configuration as qcconfig
from qcodes.logger.logger import conditionally_start_all_logging
from qcodes.utils import QCoDeSDeprecationWarning

__version__ = qcodes._version.__version__


config: qcconfig.Config = qcconfig.Config()

conditionally_start_all_logging()
Expand Down Expand Up @@ -81,3 +77,25 @@
"Please avoid setting this in your `qcodesrc.json` config file.",
QCoDeSDeprecationWarning,
)

if not TYPE_CHECKING:

def __getattr__(name: str) -> Any:
"""
Getting __version__ is slow in an editable install since we have shell out to run git describe.
Here we only do it lazily if required.

"""
if name == "__version__":
import qcodes._version # noqa: PLC0415 # lazy import since getting version is slow in editable install.

__version__ = qcodes._version.__version__
return __version__
raise AttributeError(f"module {__name__} has no attribute {name}")
else:
__version__ = "not_set"

__all__ = [
"__version__",
"config",
]
Loading