-
Notifications
You must be signed in to change notification settings - Fork 0
Add more ruff rules, to enforce typing #62
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
Conversation
|
There was a problem hiding this 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): |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
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.
| Image.open(io.BytesIO(base64.b64decode(value))).verify() | ||
| return value | ||
| except Exception: | ||
| except (ValueError, OSError, base64.binascii.Error): |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
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.



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.