fix(event-handler): fix ruff lint violations in event_handler module#8208
Open
hirenkumar-n-dholariya wants to merge 13 commits intoaws-powertools:developfrom
Open
Conversation
… list[X] in openapi/models.py Replace deprecated typing aliases with modern Python 3.10+ syntax: - Optional[X] -> X | None - List[X] -> list[X] - Dict[X, Y] -> dict[X, Y] - Set[X] -> set[X] - Remove unused imports: Dict, List, Optional, Set from typing Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
…x in swagger_ui/oauth2.py - Optional[str] -> str | None - Dict[str, str] -> dict[str, str] - Remove unused imports: Dict, Optional from typing Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
…l_appsync/base.py docstrings Update docstring code examples to use modern Python 3.10+ syntax: - Optional[list] -> list | None - Remove unused `from typing import Optional` from examples Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
Update docstring parameter type hints to use modern Python 3.10+ syntax: - List[Dict[str, List[str]]] -> list[dict[str, list[str]]] - Optional[Dict[str, Any]] -> dict[str, Any] | None Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
Update docstring parameter type hints to use modern Python 3.10+ syntax: - Optional[str] -> str | None in field_name parameter descriptions Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
…stry.py docstrings Update docstring return type hints to use modern Python 3.10+ syntax: - Optional[Dict] -> dict | None in Returns section Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
…alidation.py comments Update inline comments to use modern Python 3.10+ syntax: - List[Model] -> list[Model] - Optional[List[Model]] -> list[Model] | None - Optional[RootModel[List[Model]]] -> RootModel[list[Model]] | None Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
2 tasks
|
Can you please add the acknowledgement section to the PR? |
svozza
reviewed
May 8, 2026
Hi @svozza, Thank you for catching that! The comment was accidentally removed during the refactoring. I have restored it now. Also added the Acknowledgment section to the PR description. Sorry for the oversight! Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
Contributor
Author
|
Hi @svozza, |
svozza
reviewed
May 8, 2026
Contributor
Author
Hi @svozza |
…models.py fix(event-handler): restore accidentally removed comments in openapi/models.py Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
…models.py Restore all comments that were accidentally removed during the Optional[X] -> X | None type annotation refactoring in openapi/models.py. Restored comments include: - swagger.io specification links before each class definition e.g. # https://swagger.io/specification/#contact-object - JSON Schema 2020-12 reference links and section headers inside Schema class e.g. # Ref: JSON Schema 2020-12: https://json-schema.org/... - MAINTENANCE notes for future Pydantic v1 deprecation - Inline comments for serialization rules in ParameterBase e.g. # Serialization rules for simple scenarios - "Using Any for Specification Extensions" comments in Operation, Components and OpenAPI classes Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
svozza
previously approved these changes
May 8, 2026
|
LGTM! |
|
@hirenkumar-n-dholariya Can you check the lint failures in the CI? |
… oauth2.py Add `from __future__ import annotations` to enable PEP 604 union syntax (X | None) for Python versions below 3.10. Fixes FA102 ruff lint errors: - aws_lambda_powertools/event_handler/openapi/swagger_ui/oauth2.py:50 Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
Revert client_secret_only_on_dev validator signature from str | None back to Optional[str] to fix FA102 ruff lint error. PEP 604 union syntax in function signatures requires `from __future__ import annotations` which conflicts with the existing FA100 noqa suppression in this file. Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
…ture With `from __future__ import annotations` present, ruff UP045 requires `str | None` instead of `Optional[str]` in the validator signature. - Remove Optional from typing imports - Convert validator signature to str | None syntax Part of aws-powertools#8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
|
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.




Issue number: fixes #8088
Summary
Fix ruff lint violations in
aws_lambda_powertools/event_handler/after the ruff target bump.Changes
Optional[X]withX | NoneList[X]withlist[X]Dict[X, Y]withdict[X, Y]Set[X]withset[X]typingmoduleFiles changed
event_handler/openapi/models.py— largest file, 90+ replacements in field annotationsevent_handler/openapi/swagger_ui/oauth2.py— 3 field annotations + validator signatureevent_handler/graphql_appsync/base.py— 3 docstring code examples updatedevent_handler/appsync.py— docstring parameter type hints updatedevent_handler/graphql_appsync/_registry.py— docstring return type updatedevent_handler/util.py— docstring parameter type hints updatedUser experience
Before: ruff lint violations after target version bump causing CI failures
After: all violations resolved, code uses modern Python 3.10+ type syntax consistently throughout the
event_handlermoduleAcknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.