Description
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
- This request meets Powertools for AWS Lambda (Python) TenetsShould this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Type
Projects
Status
Shipped
Activity
leandrodamascena commentedon Mar 18, 2025
Hi @ericbn! I'm assigning this issue to you.
ericbn commentedon Mar 18, 2025
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 commentedon Mar 18, 2025
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 commentedon Mar 18, 2025
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