Repository navigation
Add missing keyword-only arguments to anyio.Path methods - #1286
Merged
Merged
Conversation
Mirror the newer stdlib pathlib.Path signatures: - exists(follow_symlinks=...) on Python 3.12+ - is_dir(follow_symlinks=...) / is_file(follow_symlinks=...) on Python 3.13+ - read_text(newline=...) on Python 3.13+ These were previously rejected with TypeError, breaking drop-in parity with pathlib.Path. Gated by sys.version_info so older interpreters keep the original signatures.
jaideeppyne
force-pushed
the
path-kwarg-parity
branch
from
August 21, 2026 07:04
774b4da to
c6ae8a0
Compare
for more information, see https://pre-commit.ci
Document new features and changes in version history.
jaideeppyne
added a commit
to jaideeppyne/anyio
that referenced
this pull request
Aug 25, 2026
agronholm
pushed a commit
that referenced
this pull request
Aug 25, 2026
The standard library gained a keyword-only ``follow_symlinks`` argument on ``pathlib.Path.owner()`` and ``pathlib.Path.group()`` in Python 3.13, but ``anyio.Path`` did not expose it, so passing the argument raised ``TypeError``. This is the same class of parity gap fixed in #1286, which covered exists()/is_dir()/is_file()/read_text() but missed owner()/group().
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.
Changes
anyio.Pathaims to be a drop-in async mirror ofpathlib.Path, but a few keyword-only arguments that CPython added in recent versions were missing, so passing them raisedTypeError. This adds them, gated bysys.version_infoso older interpreters keep the exact original signatures:exists()follow_symlinksis_dir()follow_symlinksis_file()follow_symlinksread_text()newlineBefore this change, on Python 3.13:
The new keyword arguments are forwarded to the underlying
pathlib.Pathcall (viapartial/run_sync), so the semantics match the standard library exactly.Tests
Added regression tests in
tests/test_fileio.pycovering each new argument, each guarded with the appropriateskipif(sys.version_info < ...). They fail onmaster(withTypeError) and pass with this change. The existingtest_fileio.pysuite continues to pass, andruff check,ruff format, andmypyare clean.A changelog entry has been added under UNRELEASED.
🤖 This PR was prepared with the assistance of Claude Code.