Skip to content

Tech debt: remove duplicated code in data class #6293

@leandrodamascena

Description

@leandrodamascena

Why is this needed?

The data_classes module contains instances of duplicated code, which can lead to increased maintenance effort, potential bugs, and reduced code clarity. This issue proposes refactoring the module to eliminate redundant code by consolidating shared logic and improving overall code quality.

Which area does this relate to?

Event Source Data Classes

Suggestion

No response

Acknowledgment

  • Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET

Activity

leandrodamascena

leandrodamascena commented on Mar 18, 2025

@leandrodamascena
ContributorAuthor

Hi @ericbn! I'm assigning this issue to you.

added
event_sourcesEvent Source Data Class utility
and removed
triagePending triage from maintainers
on Mar 18, 2025
ericbn

ericbn commented on Mar 18, 2025

@ericbn
Contributor

Oi @leandrodamascena. Cool, thanks! I wish there was a linter that would check this automatically, but I’m not aware of any. I just manually checked a few base classes.

EDIT: Actually I’ll give this a try locally: https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/duplicate-code.html

leandrodamascena

leandrodamascena commented on Mar 18, 2025

@leandrodamascena
ContributorAuthor

Ei @ericbn! We have some report about code duplication here: https://sonarcloud.io/component_measures?metric=duplicated_lines&selected=aws-powertools_powertools-lambda-python%3Aaws_lambda_powertools&id=aws-powertools_powertools-lambda-python

The reason that we don't add a linter to check code duplication is because sometimes it's necessary for some reason. I think make sense we try to reduce the number of duplicated code, if possible.

ericbn

ericbn commented on Mar 18, 2025

@ericbn
Contributor

Cool, I see now. I've used pylint locally to double check overriding code that is duplicate and updated the PR.

I see there's potential to refactor ClaimsOverrideDetails, ClaimsAndScopeOverrideDetails and TokenClaimsAndScopeOverrideDetails to have one or two common bases. But can we merge #6289 first?

7 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

event_sourcesEvent Source Data Class utilitytech-debtTechnical Debt tasks

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

    Participants

    @ericbn@leandrodamascena

    Issue actions

      Tech debt: remove duplicated code in data class · Issue #6293 · aws-powertools/powertools-lambda-python