Skip to content

Type the optional readlines size hint - #3541

Closed
xiehuanyi wants to merge 2 commits into
python-trio:mainfrom
xiehuanyi:fix/readlines-hint-annotation-20261014
Closed

xiehuanyi wants to merge 2 commits into
python-trio:mainfrom
xiehuanyi:fix/readlines-hint-annotation-20261014

Conversation

@xiehuanyi

Copy link
Copy Markdown

Type checkers currently reject await file.readlines(10) even though the wrapped synchronous file and Trio's runtime accept the optional size hint. Add the positional-only hint: int = -1 parameter to AsyncIOWrapper.readlines.

The type regressions cover text and binary results and positive/default hints. A runtime regression verifies that the hint is forwarded and subsequent reads return the remaining lines. A news fragment is included.

Validation:

  • The new calls produce five mypy errors before the annotation change and pass afterward; targeted pyright reports zero errors.
  • All 18 file I/O tests pass, and the installed-wheel suite passes with the CI plugin ordering (826 passed, 71 skipped, 2 xfailed).
  • Configured mypy passes for all 144 source files, and all applicable pre-commit checks pass.
  • The whole-repository mypy invocation has one unchanged error in docs/source/conf.py with this environment's Sphinx version; the same error is reproduced on the original base.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@xiehuanyi xiehuanyi closed this Oct 14, 2026
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (4630d02) to head (14225ac).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3541   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             128          128           
  Lines           19474        19481    +7     
  Branches         1323         1323           
===============================================
+ Hits            19474        19481    +7     
Files with missing lines Coverage Δ
src/trio/_file_io.py 100.00000% <ø> (ø)
src/trio/_tests/test_file_io.py 100.00000% <100.00000%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants