Skip to content

refactor: replace string-based getattr loop in VSCodeLogSummary.__post_init__ (#873)#877

Merged
microsasa merged 1 commit intomainfrom
fix/873-vscode-post-init-no-getattr-ea2289b517536f7a
Apr 9, 2026
Merged

refactor: replace string-based getattr loop in VSCodeLogSummary.__post_init__ (#873)#877
microsasa merged 1 commit intomainfrom
fix/873-vscode-post-init-no-getattr-ea2289b517536f7a

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #873

Summary

VSCodeLogSummary.__post_init__ used a for loop over string attribute names with object.__getattribute__(self, attr) to read mapping fields before wrapping them in MappingProxyType. This is semantically equivalent to getattr and violates the "No getattr / 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). The object.__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 MappingProxyType wrapping still occurs correctly for all four mapping fields.

Generated by Issue Implementer · ● 4M ·

…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>
@microsasa microsasa added the aw Created by agentic workflow label Apr 9, 2026
@microsasa microsasa enabled auto-merge April 9, 2026 05:01
Copilot AI review requested due to automatic review settings April 9, 2026 05:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into MappingProxyType.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Apr 9, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@microsasa microsasa merged commit 67498da into main Apr 9, 2026
8 checks passed
@microsasa microsasa deleted the fix/873-vscode-post-init-no-getattr-ea2289b517536f7a branch April 9, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][code health] VSCodeLogSummary.__post_init__ uses string-based attribute access, violating "no getattr/hasattr" guideline

2 participants