fix(event-handler): fix ruff lint violations in event_handler module#8208
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>
|
Can you please add the acknowledgement section to the PR? |
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>
|
Hi @svozza, |
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>
|
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>
|
|
Hi @svozza |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8208 +/- ##
========================================
Coverage 96.72% 96.72%
========================================
Files 286 286
Lines 14346 14347 +1
Branches 1201 1201
========================================
+ Hits 13876 13877 +1
Misses 341 341
Partials 129 129 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you so much @svozza for your approval. Hi @leandrodamascena |




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.