chore: fix main#1613
Conversation
Replace typing.Optional/Dict with PEP 604 union syntax and built-in dict annotations to modernize type hints (requires Python 3.10+). Update annotations in DoclingStatusSnapshot (detail/raw), DoclingService.__init__ and fetch_task_result. Clean up and reorder imports (platform moved up, removed unused typing names) for clarity.
Switch DoclingTaskState to StrEnum (imported from enum) so enum members are proper string enums. Also preserve the original error context in LangflowFileService by raising the upload exception with "from e" to keep exception chaining and traceback information.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughType annotations are modernized across two service modules: ChangesType Annotation Modernization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Modernizes Python typing syntax in Docling/Langflow services, switches Docling task state enums to StrEnum, and improves Docling submission error chaining.
Changes:
- Updated type hints to Python 3.10+ union/generic syntax (
str | None,dict[str, Any]) - Switched
DoclingTaskStatefromEnumtoStrEnum - Added exception chaining (
raise ... from e) for Docling submission failures
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/services/langflow_file_service.py | Updates function signatures to modern type hints; improves Docling submission exception chaining |
| src/services/docling_service.py | Migrates enum to StrEnum and modernizes several type hints |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from enum import Enum | ||
| import platform | ||
| from dataclasses import dataclass | ||
| from enum import StrEnum |
|
|
||
|
|
||
| class DoclingTaskState(str, Enum): | ||
| class DoclingTaskState(StrEnum): |
| extra={"error": str(e), "filename": filename}, | ||
| ) | ||
| raise Exception(f"Docling upload failed: {str(e)}") | ||
| raise Exception(f"Docling upload failed: {str(e)}") from e |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/langflow_file_service.py`:
- Around line 600-602: The call to submit_to_docling uses invalid keyword args
user_id and auth_header which that function does not accept; update the call at
the submit_to_docling invocation to match its actual signature by removing those
kwargs and passing the correct parameters (e.g., use the positional/keyword
names defined in submit_to_docling or pass only filename and content), or
alternatively update submit_to_docling to accept owner/jwt_token if that was
intended; reference submit_to_docling and the variables owner and jwt_token when
making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 149170f6-3c29-448c-b4e1-3c546398ed91
📒 Files selected for processing (2)
src/services/docling_service.pysrc/services/langflow_file_service.py
| task_id = await self.submit_to_docling( | ||
| filename, content, user_id=owner, auth_header=jwt_token | ||
| ) |
There was a problem hiding this comment.
Fix mismatched keyword arguments in submit_to_docling call (Line 600).
submit_to_docling does not accept user_id/auth_header; this currently fails mypy and will raise TypeError at runtime.
Proposed fix
- task_id = await self.submit_to_docling(
- filename, content, user_id=owner, auth_header=jwt_token
- )
+ task_id = await self.submit_to_docling(
+ filename, content, owner=owner, jwt_token=jwt_token
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| task_id = await self.submit_to_docling( | |
| filename, content, user_id=owner, auth_header=jwt_token | |
| ) | |
| task_id = await self.submit_to_docling( | |
| filename, content, owner=owner, jwt_token=jwt_token | |
| ) |
🧰 Tools
🪛 GitHub Actions: Lint Backend / 0_Ruff and mypy on changed files.txt
[error] 600-600: mypy error: Unexpected keyword argument "user_id" for "submit_to_docling" of "LangflowFileService" [call-arg]
[error] 600-600: mypy error: Unexpected keyword argument "auth_header" for "submit_to_docling" of "LangflowFileService" [call-arg]
🪛 GitHub Actions: Lint Backend / Ruff and mypy on changed files
[error] 600-600: mypy: Unexpected keyword argument "user_id" for "submit_to_docling" of "LangflowFileService" [call-arg]
[error] 600-600: mypy: Unexpected keyword argument "auth_header" for "submit_to_docling" of "LangflowFileService" [call-arg]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/services/langflow_file_service.py` around lines 600 - 602, The call to
submit_to_docling uses invalid keyword args user_id and auth_header which that
function does not accept; update the call at the submit_to_docling invocation to
match its actual signature by removing those kwargs and passing the correct
parameters (e.g., use the positional/keyword names defined in submit_to_docling
or pass only filename and content), or alternatively update submit_to_docling to
accept owner/jwt_token if that was intended; reference submit_to_docling and the
variables owner and jwt_token when making the change.
✅ Addressed in commit 8cdcc34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| import platform | ||
| from dataclasses import dataclass | ||
| from enum import StrEnum | ||
| from pathlib import Path |
* fix imports * ruff fix * Use PEP 604 types and modernize imports Replace typing.Optional/Dict with PEP 604 union syntax and built-in dict annotations to modernize type hints (requires Python 3.10+). Update annotations in DoclingStatusSnapshot (detail/raw), DoclingService.__init__ and fetch_task_result. Clean up and reorder imports (platform moved up, removed unused typing names) for clarity. * Use StrEnum for DoclingTaskState; chain exception Switch DoclingTaskState to StrEnum (imported from enum) so enum members are proper string enums. Also preserve the original error context in LangflowFileService by raising the upload exception with "from e" to keep exception chaining and traceback information. * style: ruff format (auto) * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * style: ruff format (auto) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Rico Furtado <hfurtado@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This pull request modernizes type hinting throughout the
docling_service.pyandlangflow_file_service.pymodules by adopting Python 3.10+ syntax (e.g.,str | Noneinstead ofOptional[str],dict[str, Any]instead ofDict[str, Any]). It also updates enum usage to leverageStrEnumfor better type safety and string handling, and improves error handling in Docling submission. These changes enhance code readability, maintainability, and take advantage of newer Python features.Type hint modernization
Optional[str]andDict[str, Any]with Python 3.10+ syntax (str | None,dict[str, Any]) across function signatures and class attributes in bothsrc/services/docling_service.pyandsrc/services/langflow_file_service.py. [1] [2] [3] [4] [5] [6]Enum improvements
DoclingTaskStatefrom inheritingEnumtoStrEnumfor more robust string-based enum handling insrc/services/docling_service.py. [1] [2]Error handling
submit_to_doclingby usingraise ... from eto preserve the original error context insrc/services/langflow_file_service.py.Summary by CodeRabbit