Skip to content

Conversation

@LeanderCS
Copy link
Owner

@LeanderCS LeanderCS commented Sep 24, 2025

Summary by Bito

This pull request enhances input filters with improved exception handling and type hints, updates the project version to 0.6.3, and adds new linting rules. Additionally, it adjusts tests to incorporate a timeout feature for API requests, ensuring greater reliability.

Copilot AI review requested due to automatic review settings September 24, 2025 16:39
@LeanderCS LeanderCS merged commit cb4241c into main Sep 24, 2025
6 checks passed
@LeanderCS LeanderCS deleted the enforce-typing-with-ruff branch September 24, 2025 16:39
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds more ruff linting rules to enforce better typing standards and improves code quality through stricter linting. The changes include adding type annotations, security improvements, and better exception handling.

  • Added comprehensive ruff linting rules including security (S), annotations (ANN), and performance (PERF) checks
  • Added explicit type annotations to method signatures and parameters
  • Improved security by adding default timeouts to HTTP requests and using specific exception types

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Added new ruff rules for security, typing, and code quality with appropriate ignores
flask_inputfilter/input_filter.py Added type annotations to wrapper function parameters
flask_inputfilter/filters/to_typed_dict_filter.py Added Type import and type annotation for typed_dict parameter
flask_inputfilter/filters/to_image_filter.py Replaced broad Exception with specific exception types
flask_inputfilter/filters/to_base64_image_filter.py Replaced broad Exception with specific exception types
flask_inputfilter/validators/is_horizontal_image_validator.py Added type annotations and imports
flask_inputfilter/validators/is_vertical_image_validator.py Added return type annotation to init
flask_inputfilter/validators/is_dataclass_validator.py Added type annotation for kwargs parameter
flask_inputfilter/mixins/external_api_mixin/external_api_mixin.py Added default timeout to requests.request call
flask_inputfilter/mixins/external_api_mixin/_external_api_mixin.pyx Added default timeout to requests.request call in Cython version
tests/test_input_filter.py Updated test assertions to include timeout parameter
docs/source/changelog.rst Added changelog entry for version 0.6.3

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

try:
return Image.open(io.BytesIO(base64.b64decode(value)))
except Exception:
except (ValueError, OSError, base64.binascii.Error):
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The exception base64.binascii.Error should be binascii.Error. The base64 module doesn't have a binascii attribute - it should reference the binascii module directly.

Copilot uses AI. Check for mistakes.
Image.open(io.BytesIO(base64.b64decode(value))).verify()
return value
except Exception:
except (ValueError, OSError, base64.binascii.Error):
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The exception base64.binascii.Error should be binascii.Error. The base64 module doesn't have a binascii attribute - it should reference the binascii module directly.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants