Repository navigation
Fix lazyproperty re-evaluating getters that return None - #1626
Open
jipeng6036-del wants to merge 1 commit into
Open
jipeng6036-del wants to merge 1 commit into
jipeng6036-del wants to merge 1 commit into
Conversation
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.
Fixes #1600.
lazypropertytreated a cachedNonethe same as "not computed yet", so a getter that legitimately returnsNoneran again on every access. That contradicts the documented "evaluated only on first access" behavior.The lookup now uses key presence in the instance
__dict__instead of comparing the stored value toNone.Testing
uv run pytest tests/test_shared.py— 23 passedNone-returning case fails on unmodifiedmaster(call_count3 vs 1) and passes with this changeNonecaching still holdsruff check/ruff format --checkon the changed filesuv run pyteston Windows: 1555 passed, 56 failed. The failures are existing XML snippet / SHA-1 fixtures (tests/oxml/test_table.py,tests/opc/test_phys_pkg.py, header/footer templates) from CRLF checkout; they are outside the files in this PR.