Skip to content

Tech debt: remove duplicated code in data class #6293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
leandrodamascena opened this issue Mar 18, 2025 · 5 comments · Fixed by #6288 or #6297
Closed
1 of 2 tasks

Tech debt: remove duplicated code in data class #6293

leandrodamascena opened this issue Mar 18, 2025 · 5 comments · Fixed by #6288 or #6297
Assignees
Labels
event_sources Event Source Data Class utility tech-debt Technical Debt tasks

Comments

@leandrodamascena
Copy link
Contributor

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

@leandrodamascena
Copy link
Contributor Author

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

@leandrodamascena leandrodamascena moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Mar 18, 2025
@leandrodamascena leandrodamascena added event_sources Event Source Data Class utility and removed triage Pending triage from maintainers labels Mar 18, 2025
@leandrodamascena leandrodamascena linked a pull request Mar 18, 2025 that will close this issue
7 tasks
@ericbn
Copy link
Contributor

ericbn commented 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
Copy link
Contributor Author

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
Copy link
Contributor

ericbn commented 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?

@leandrodamascena leandrodamascena changed the title Tech debt: remove duplicated code Tech debt: remove duplicated code in data class Mar 18, 2025
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Mar 18, 2025
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_sources Event Source Data Class utility tech-debt Technical Debt tasks
Projects
Status: Shipped
2 participants