File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 1212
1313from typing_extensions import deprecated
1414
15- import qcodes ._version
1615import qcodes .configuration as qcconfig
1716from qcodes .logger .logger import conditionally_start_all_logging
1817from qcodes .utils import QCoDeSDeprecationWarning
1918from qcodes .utils .spyder_utils import add_to_spyder_UMR_excludelist
2019
21- __version__ = qcodes ._version .__version__
22-
23-
2420config : qcconfig .Config = qcconfig .Config ()
2521
2622conditionally_start_all_logging ()
@@ -107,3 +103,23 @@ def test(**kwargs: Any) -> int:
107103del deprecated
108104
109105test .__test__ = False # type: ignore[attr-defined] # Don't try to run this method as a test
106+
107+
108+ def __getattr__ (name : str ) -> Any :
109+ """
110+ Getting __version__ is slow in an editable install since we have shell out to run git describe.
111+ Here we only do it lazily if required.
112+
113+ TODO this means that the type of __version__ is Any, which is not ideal.
114+ __version__ is also not listed by dir(qcodes) that could be fixed by overwrting __dir__.
115+ see https://peps.python.org/pep-0562/
116+ """
117+ if name == "__version__" :
118+ import qcodes ._version
119+
120+ __version__ = qcodes ._version .__version__
121+ return __version__
122+ raise AttributeError (f"module { __name__ !r} has no attribute { name !r} " )
123+
124+
125+ __all__ = ["__version___" , "config" ]
You can’t perform that action at this time.
0 commit comments