Conversation
…t_init__ (#873) Replace the for-loop using object.__getattribute__ with explicit attribute reads to comply with the 'no getattr/hasattr' coding guideline. Behaviour is identical — frozen dataclass still requires object.__setattr__ for writes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors VSCodeLogSummary.__post_init__ to remove string-based attribute reads (object.__getattribute__), aligning with the repo’s “No getattr / hasattr” guideline while preserving existing MappingProxyType immutability behavior.
Changes:
- Replaced the loop over string attribute names with explicit, typed reads of the four mapping fields.
- Kept
object.__setattr__for frozen-dataclass field updates, continuing to snapshot mappings intoMappingProxyType.
Contributor
There was a problem hiding this comment.
Low-impact code-standards refactor. Replaces a string-based object.__getattribute__ loop with four explicit, typed attribute reads — directly addressing the "No getattr/hasattr" coding guideline. No behavioral change; all CI checks pass. Auto-approving for merge.
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.
Closes #873
Summary
VSCodeLogSummary.__post_init__used aforloop over string attribute names withobject.__getattribute__(self, attr)to read mapping fields before wrapping them inMappingProxyType. This is semantically equivalent togetattrand violates the "Nogetattr/hasattr" coding guideline.Changes
Replaced the generic loop with four explicit, typed attribute reads (
self.requests_by_model,self.duration_by_model,self.requests_by_category,self.requests_by_date). Theobject.__setattr__calls remain unchanged since they are required for frozen dataclass field assignment.This is a pure code-standards refactor with no behavioural change. All existing tests pass and confirm
MappingProxyTypewrapping still occurs correctly for all four mapping fields.