Skip to content

Widen Path.write_bytes data param to ReadableBuffer - #1136

Merged
agronholm merged 4 commits into
agronholm:masterfrom
SAY-5:widen-write-bytes-typing
May 7, 2026
Merged

agronholm merged 4 commits into
agronholm:masterfrom
SAY-5:widen-write-bytes-typing

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Changes

Fixes #1135.

Widens the type of the data parameter on anyio.Path.write_bytes() from bytes to ReadableBuffer, matching the signature of pathlib.Path.write_bytes. mypy v2's --strict-bytes (now default) flagged passing bytearray / memoryview as a type error even though the underlying call accepts any buffer.

Checklist

  • You've added tests (in tests/) which would fail without your patch
  • You've updated the documentation (in docs/), in case of behavior changes or new features
  • You've added a new changelog entry (in docs/versionhistory.rst).

SAY-5 and others added 2 commits May 7, 2026 06:13
Matches pathlib.Path.write_bytes, allowing bytearray / memoryview / other
buffer types. Fixes agronholm#1135.
Comment thread tests/test_fileio.py Resolved
@SAY-5

SAY-5 commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Refactored to a single parametrized test_write_bytes over bytes/bytearray/memoryview in e8953be.

@agronholm
agronholm merged commit b979108 into agronholm:master May 7, 2026
18 checks passed
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.

widen Path.write_bytes typing

2 participants