chore: refresh uv.lock and resolve type errors after upgrading ty#1866
Merged
chore: refresh uv.lock and resolve type errors after upgrading ty#1866
Conversation
The ty type-checker upgrade surfaced several issues that were either silently passing or guarded by stale ignore directives. Fixes: - Replace `Unpack[ExportDataJsonKwargs | ExportDataCsvKwargs]` (now rejected per PEP 692) in `BasicCrawler.export_data` with a combined `ExportDataKwargs` TypedDict that inherits from both. - Tighten `ExportDataCsvKwargs.quoting` from `int` to `Literal[0, 1, 2, 3]` to match what `csv.writer` actually accepts. - Replace `partial(block_requests, page=...)` in `PlaywrightCrawler` with a `_make_block_requests` helper, since `functools.partial` typed with keyword binding produces a signature incompatible with the `BlockRequestsFunction` protocol. - Drop two now-unused `ty: ignore[invalid-argument-type]` directives in the adaptive Playwright crawler. - Annotate the test cycle default with `list[RenderingType]` so the `_SimpleRenderingTypePredictor` test predictor matches the expected type. - Fix a pre-existing runtime bug in the CSV export example: `quoting='all'` would raise `TypeError` at runtime; replace with `csv.QUOTE_ALL`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1866 +/- ##
=======================================
Coverage 92.44% 92.45%
=======================================
Files 158 158
Lines 11026 11027 +1
=======================================
+ Hits 10193 10195 +2
+ Misses 833 832 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
janbuchar
approved these changes
May 4, 2026
Collaborator
janbuchar
left a comment
There was a problem hiding this comment.
LGTM, left two non-blocking comments
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
The
tytype-checker upgrade to 0.0.34 (inuv.lock) surfaced several issues that were either silently passing or guarded by stale ignore directives.Changes
Unpack[Union[...]]is no longer accepted (per PEP 692):BasicCrawler.export_datanow uses a new combinedExportDataKwargsTypedDict that inherits from bothExportDataJsonKwargsandExportDataCsvKwargsinstead ofUnpack[ExportDataJsonKwargs | ExportDataCsvKwargs].ExportDataCsvKwargs.quotingtightened frominttoLiteral[0, 1, 2, 3]— that's whatcsv.writeractually accepts (thecsv.QUOTE_*constants).partial(block_requests, page=...)inPlaywrightCrawlerproduced a result whose typed signature (functools.partialcollapses keyword-bound params into a fully keyword-only signature) didn't satisfy theBlockRequestsFunctionprotocol. Replaced with a_make_block_requestsstatic helper that returns an explicit closure.# ty: ignore[invalid-argument-type]directives in_adaptive_playwright_crawler.pythat ty now flags as unused.cycledefault in_SimpleRenderingTypePredictorso it producesIterator[RenderingType]instead ofIterator[str].quoting='all', which raisesTypeError: "quoting" must be an integer, not strat runtime. Replaced withcsv.QUOTE_ALL.