Skip to content

fix(event-handler): fix ruff lint violations in event_handler module#8208

Open
hirenkumar-n-dholariya wants to merge 7 commits intoaws-powertools:developfrom
hirenkumar-n-dholariya:fix/ruff-lint-event-handler-8088
Open

fix(event-handler): fix ruff lint violations in event_handler module#8208
hirenkumar-n-dholariya wants to merge 7 commits intoaws-powertools:developfrom
hirenkumar-n-dholariya:fix/ruff-lint-event-handler-8088

Conversation

@hirenkumar-n-dholariya
Copy link
Copy Markdown
Contributor

Issue number: fixes #8088

Summary

Fix ruff lint violations in aws_lambda_powertools/event_handler/ after the ruff target bump.

Changes

  • Replace Optional[X] with X | None
  • Replace List[X] with list[X]
  • Replace Dict[X, Y] with dict[X, Y]
  • Replace Set[X] with set[X]
  • Remove unused imports from typing module

Files changed

  • event_handler/openapi/models.py - largest file, 90+ replacements in field annotations
  • event_handler/openapi/swagger_ui/oauth2.py - 3 field annotations + validator signature
  • event_handler/graphql_appsync/base.py - 3 docstring code examples updated
  • event_handler/appsync.py - docstring parameter type hints updated
  • event_handler/graphql_appsync/_registry.py - docstring return type updated
  • event_handler/util.py - docstring parameter type hints updated

User experience

Before: ruff lint violations after target version bump causing CI failures
*

… 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>
@powertools-for-aws-oss-automation
Copy link
Copy Markdown

No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template at .github/PULL_REQUEST_TEMPLATE.md#acknowledgment

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 7, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

@svozza
Copy link
Copy Markdown

svozza commented May 8, 2026

Can you please add the acknowledgement section to the PR?

openapi_extensions: Optional[Dict[str, Any]] = None
openapi_extensions: dict[str, Any] | None = None

# If the 'openapi_extensions' field is present in the 'values' dictionary,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this comment removed?

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

Labels

event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance: Fix ruff lint issues in event_handler module

2 participants