chore: fix ruff lint findings and refactor read_item - #393
Merged
Conversation
- Fix I001: sort imports in src/consts.py - Fix PLC0415: move `import base64` to top of tests/main_test.py - Fix UP037: remove quotes from LinkResponse return annotation - Fix D213: correct multi-line docstring summary placement - Remove unused `# noqa: BLE001` in src/owui.py - Refactor read_item into helpers: setup_routes, load_page_and_solve, build_response_content, _fetch_pdf_content — resolves C901 and PLR0915 - Add CPY001, BLE001 to ruff ignore list
Resolved conflicts in src/consts.py and src/endpoints.py: - consts.py: take theirs (CHALLENGE_TITLES removed, browser_locale added, CaptchaType import no longer needed — detection is now library-based) - endpoints.py: merge both refactors — keep theirs' detect_cloudflare_challenge + page_html capture, reapply my helper extraction (setup_routes, _navigate_and_solve, _solve_challenge, _wait_for_networkidle, build_response_content, _fetch_pdf_content) on top
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves all 15 ruff lint findings reported by
ruff check ..Changes
Fixed lint violations
I001src/consts.pyPLC0415tests/main_test.pyimport base64to module top-levelUP037src/models.pyLinkResponsereturn annotationD213src/endpoints.pyRUF100src/owui.py# noqa: BLE001directiveRefactored
read_item(resolvesC901+PLR0915)Split the endpoint into focused helpers with clear separation of concerns:
setup_routes— installs media-blocking and CSP-stripping routes, captures final URLload_page_and_solve— navigation, challenge detection, solve or wait-for-networkidlebuild_response_content— dispatches to PDF fetch or HTML content_fetch_pdf_content— base64-encodes PDF bytes with viewer-HTML fallbackread_itemis now a thin orchestrator. No behavioral change.Added to ruff ignore list
CPY001— missing copyright notice (not enforced in this project)BLE001— blind exception catch (PDF fetch fallback catches broadly by design)Verification
Network-dependent tests (
test_bypass,test_health_check,test_pdf_handling) are not run locally.