Skip to content

feat(stdlib): add os.walk, makedirs(exist_ok), getpid, getppid and os.path improvements#287

Merged
dbrattli merged 2 commits intomainfrom
repo-assist/bindings-os-walk-getpid-2026-05-01-86f2525f8e5ada75
May 1, 2026
Merged

feat(stdlib): add os.walk, makedirs(exist_ok), getpid, getppid and os.path improvements#287
dbrattli merged 2 commits intomainfrom
repo-assist/bindings-os-walk-getpid-2026-05-01-86f2525f8e5ada75

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 1, 2026

🤖 This is an automated pull request from Repo Assist, an AI assistant for this repository.

Summary

Extends Os.fs with several commonly-needed functions that were missing from the module, including the most-requested pattern os.makedirs(path, exist_ok=True).

Changes

New os functions

Binding Python API Notes
os.makedirs(path, exist_ok) os.makedirs(path, exist_ok=bool) Keyword-arg emission; fixes the usability gap where exist_ok required mode too
os.makedirs(path, mode, exist_ok) os.makedirs(path, mode, bool) Explicit 3-arg form (replaces old binding)
os.walk(top) os.walk(top) Yields (dirpath, dirnames, filenames) tuples
os.walk(top, topdown) os.walk(top, topdown=bool) Control traversal order
os.getpid() os.getpid() Current process ID
os.getppid() os.getppid() Parent process ID

New os.path functions

Binding Python API
os.path.isabs(path) os.path.isabs(path)
os.path.islink(path) os.path.islink(path)
os.path.realpath(path) os.path.realpath(path)
os.path.getsize(path) os.path.getsize(path)

Tests

7 new tests added to test/TestOs.fs.

Motivation

The most common pain point is os.makedirs(path, exist_ok=True) — the previous binding forced callers to also supply mode, which is unusual. The new overload uses [<Emit("$0.makedirs($1, exist_ok=$2)")>] to pass exist_ok as a keyword argument.

os.walk is one of Python's most widely-used directory traversal functions and was absent entirely.

Trade-offs

  • All changes are additive; no existing signatures were modified.
  • The old makedirs(path * mode * exist_ok) overload is preserved for backward compatibility.

Note

🔒 Integrity filter blocked 10 items

The following items were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Repo Assist · ● 3M ·

….path improvements

Add missing but commonly-needed functions to the Os module:

- os.makedirs(path, exist_ok) overload using keyword arg emission so
  callers can write os.makedirs(dir, true) without specifying mode
- os.walk / os.walk(topdown) for directory tree traversal
- os.getpid() and os.getppid() to query current/parent process IDs
- os.path.isabs to test if a path is absolute
- os.path.islink to test if a path is a symbolic link
- os.path.realpath to resolve symlinks and canonicalize a path
- os.path.getsize to get the size of a file in bytes

Also adds 7 new tests to TestOs.fs covering all new members.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dbrattli dbrattli changed the title [Repo Assist] feat(stdlib): add os.walk, makedirs(exist_ok), getpid, getppid and os.path improvements feat(stdlib): add os.walk, makedirs(exist_ok), getpid, getppid and os.path improvements May 1, 2026
- Change os.path.getsize return type from int to int64 to handle files >= 2 GiB
- Reorder getpid/getppid next to getenv; move walk near rmdir for grouping
- Improve walk test to assert dirpath="." and that subdirs+files match listdir
- Add getppid test
- Add walk(topdown=false) test using a controlled temp dir
- Use unique /tmp paths and clean up after makedirs/walk tests
- Revert CHANGELOG.md addition (AGENTS.md forbids modifying CHANGELOG)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dbrattli dbrattli marked this pull request as ready for review May 1, 2026 08:36
@dbrattli dbrattli merged commit 09cb36b into main May 1, 2026
2 checks passed
@dbrattli dbrattli deleted the repo-assist/bindings-os-walk-getpid-2026-05-01-86f2525f8e5ada75 branch May 1, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant