Skip to content

Expose AsyncIOWrapper for public file type annotations - #3507

Closed
vzer200 wants to merge 1 commit into
python-trio:mainfrom
vzer200:fix/public-async-io-wrapper
Closed

Expose AsyncIOWrapper for public file type annotations#3507
vzer200 wants to merge 1 commit into
python-trio:mainfrom
vzer200:fix/public-async-io-wrapper

Conversation

@vzer200

@vzer200 vzer200 commented Sep 8, 2026

Copy link
Copy Markdown

Expose the existing generic file-wrapper type as trio.AsyncIOWrapper, so callers can annotate values returned by open_file(), wrap_file() and Path.open() without importing a private module.

Fixes #3390 and follows the discussion on the closed #2864. The class follows Trio's final-class convention. The documentation describes its wrapped-file type parameter, and runtime/type tests now use the public import. Static class inspection accounts specifically for its existing dynamically supplied methods and properties; unexpected differences still fail the checks.

Validation:

  • The public import failed before the export. All 62 related runtime/export checks pass, including the slow static-tool checks (one optional test skipped).
  • Project typing checks pass: mypy for Linux, macOS and Windows, plus both pyright type-test directories. Sphinx with warnings as errors and all applicable pre-commit hooks pass.
  • On this Chinese-language Windows host, the full runtime suite reports 805 passed, 85 skipped, two expected failures and five failures matching English OS error messages. The unchanged base has exactly the same results. The type-completeness helper likewise reports the same existing platform/docstring diagnostics on both versions, with no new wrapper diagnostic.

AI-assisted implementation, independently reviewed by other coding agents.

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (a3d7cdd) to head (d143d68).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3507   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             128          128           
  Lines           19454        19459    +5     
  Branches         1321         1323    +2     
===============================================
+ Hits            19454        19459    +5     
Files with missing lines Coverage Δ
src/trio/__init__.py 100.00000% <100.00000%> (ø)
src/trio/_file_io.py 100.00000% <100.00000%> (ø)
src/trio/_tests/test_exports.py 100.00000% <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.

@A5rocks

A5rocks commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

I'm not willing to waste my time going through the issues with this PR (I think the testing strategy is wrong w/r/t handling missing attributes and probably this would need a mention in the docs?), given you have a bunch of open PRs + the PR explanation is LLM-generated.

@A5rocks A5rocks closed this Sep 8, 2026
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.

Type annotations for trio.open_file & trio.wrap_file

2 participants