Skip to content

Add parent_mode to Path.mkdir on Python 3.15 - #259

Open
BlueX888 wants to merge 1 commit into
Tinche:mainfrom
BlueX888:contrib/pathlib-parent-mode
Open

BlueX888 wants to merge 1 commit into
Tinche:mainfrom
BlueX888:contrib/pathlib-parent-mode

Conversation

@BlueX888

@BlueX888 BlueX888 commented Nov 8, 2026

Copy link
Copy Markdown

What changed

Python 3.15 added a keyword-only parent_mode parameter to pathlib.Path.mkdir():

pathlib.Path.mkdir(self, mode=0o777, parents=False, exist_ok=False, *, parent_mode=None)

aiofiles.pathlib.Path documents that its methods follow the pathlib API of the running interpreter, and 3.15 is covered by CI/tox/changelog, but its hand-written mkdir() still had the pre-3.15 four-argument signature. Calling mkdir(parents=True, parent_mode=0o700) on 3.15 therefore raised:

TypeError: Path.mkdir() got an unexpected keyword argument 'parent_mode'

This adds a version-gated keyword-only parent_mode for Python 3.15+, forwarded to the wrapped pathlib.Path.mkdir. The signature on Python 3.9-3.14 is unchanged (unconditional forwarding would itself raise TypeError there).

Fixes #258.

Tests

  • New test_mkdir_parent_mode (3.15+ only) asserts that non-leaf parents receive parent_mode and the leaf receives mode, accounting for the process umask on POSIX.
  • Existing test_mkdir_and_rmdir continues to cover the ordinary parents/exist_ok paths.
  • Python 3.15.0: pytest -q -> 285 passed, 8 skipped; pytest -q tests/test_pathlib.py -k mkdir -> 2 passed.
  • Python 3.14.7: ordinary mkdir(parents=True) works, and parent_mode is rejected as expected for that interpreter.
  • ruff format --check src tests and ruff check src tests pass.

Notes

Prepared with Claude Code, an LLM agent operating the BlueX888 account.

This branch has not been deployed

No deployments
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.

aiofiles.pathlib.Path.mkdir does not accept Python 3.15's parent_mode

1 participant