Skip to content

Commit 27fce61

Browse files
committed
Add type for __version__
1 parent 5a45f03 commit 27fce61

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/qcodes/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,19 @@ def test(**kwargs: Any) -> int:
105105
test.__test__ = False # type: ignore[attr-defined] # Don't try to run this method as a test
106106

107107

108+
__version__: str
109+
108110
def __getattr__(name: str) -> Any:
109111
"""
110112
Getting __version__ is slow in an editable install since we have shell out to run git describe.
111113
Here we only do it lazily if required.
112114
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/
115+
TODO this means that unknown attributes are typed as Any rather than an error
116+
Using Literal["__version__"] as the input type does not seem to result in other attributes being rejected
116117
"""
117118
if name == "__version__":
118119
import qcodes._version
119120

120121
__version__ = qcodes._version.__version__
121122
return __version__
122123
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
123-
124-
125-
__all__ = ["__version___", "config"]

0 commit comments

Comments
 (0)