make qcodes.__version__ lazy#5931
Open
jenshnielsen wants to merge 1 commit into
Open
Conversation
jenshnielsen
marked this pull request as draft
April 5, 2024 09:31
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5931 +/- ##
=======================================
Coverage 71.11% 71.11%
=======================================
Files 305 305
Lines 32004 32004
=======================================
Hits 22760 22760
Misses 9244 9244 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jenshnielsen
force-pushed
the
jenshnielsen/lazy_version
branch
from
June 9, 2024 18:00
9bd9158 to
27fce61
Compare
jenshnielsen
force-pushed
the
jenshnielsen/lazy_version
branch
2 times, most recently
from
May 13, 2026 14:26
55ea07f to
f24d220
Compare
jenshnielsen
marked this pull request as ready for review
May 18, 2026 08:41
jenshnielsen
force-pushed
the
jenshnielsen/lazy_version
branch
2 times, most recently
from
May 18, 2026 15:42
0028cd1 to
737cb3c
Compare
Resolving qcodes.__version__ is slow in an editable install because it shells out to run ``git describe``. Compute it lazily in the module level ``__getattr__`` so it is only evaluated when actually accessed, keeping ``import qcodes`` fast. Under ``TYPE_CHECKING`` ``__version__`` is defined with a placeholder value and added to ``__all__`` so static type checkers still know it exists. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93c35dbe-0d71-45b1-afcb-57ef16eeaa30
jenshnielsen
force-pushed
the
jenshnielsen/lazy_version
branch
from
July 16, 2026 20:46
737cb3c to
58ba339
Compare
jenshnielsen
enabled auto-merge
July 17, 2026 15:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This speeds up importing qcodes from an editable install with ~ 0.6-0.7 s assuming that you do not actually make use of the
__version__attribute. By only doing this in aif not TYPE_CHECKING:block we avoid losing static type information about top level attributes