Skip to content

chore: refresh uv.lock and resolve type errors after upgrading ty#1866

Merged
vdusek merged 2 commits intomasterfrom
chore/fix-ty-0-0-34-type-errors
May 4, 2026
Merged

chore: refresh uv.lock and resolve type errors after upgrading ty#1866
vdusek merged 2 commits intomasterfrom
chore/fix-ty-0-0-34-type-errors

Conversation

@vdusek
Copy link
Copy Markdown
Collaborator

@vdusek vdusek commented May 4, 2026

Summary

The ty type-checker upgrade to 0.0.34 (in uv.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_data now uses a new combined ExportDataKwargs TypedDict that inherits from both ExportDataJsonKwargs and ExportDataCsvKwargs instead of Unpack[ExportDataJsonKwargs | ExportDataCsvKwargs].
  • ExportDataCsvKwargs.quoting tightened from int to Literal[0, 1, 2, 3] — that's what csv.writer actually accepts (the csv.QUOTE_* constants).
  • partial(block_requests, page=...) in PlaywrightCrawler produced a result whose typed signature (functools.partial collapses keyword-bound params into a fully keyword-only signature) didn't satisfy the BlockRequestsFunction protocol. Replaced with a _make_block_requests static helper that returns an explicit closure.
  • Removed two stale # ty: ignore[invalid-argument-type] directives in _adaptive_playwright_crawler.py that ty now flags as unused.
  • Annotated the test cycle default in _SimpleRenderingTypePredictor so it produces Iterator[RenderingType] instead of Iterator[str].
  • Pre-existing runtime bug fix: the CSV export example used quoting='all', which raises TypeError: "quoting" must be an integer, not str at runtime. Replaced with csv.QUOTE_ALL.

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`.
@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels May 4, 2026
@vdusek vdusek self-assigned this May 4, 2026
@vdusek vdusek requested a review from janbuchar May 4, 2026 08:05
@github-actions github-actions Bot added this to the 140th sprint - Tooling team milestone May 4, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label May 4, 2026
@vdusek vdusek changed the title chore: Resolve type errors after upgrading ty to 0.0.34 chore: refresh uv.lock and resolve type errors after upgrading ty May 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.45%. Comparing base (ac66b2a) to head (47953f3).
⚠️ Report is 2 commits behind head on master.

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     
Flag Coverage Δ
unit 92.45% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Collaborator

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

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

LGTM, left two non-blocking comments

Comment thread src/crawlee/crawlers/_playwright/_playwright_crawler.py Outdated
@vdusek vdusek merged commit 6b78f38 into master May 4, 2026
30 checks passed
@vdusek vdusek deleted the chore/fix-ty-0-0-34-type-errors branch May 4, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants