Skip to content

Add Path.lchmod for pathlib compatibility - #281

Open
harshaadimulam22-creator wants to merge 1 commit into
jaraco:mainfrom
harshaadimulam22-creator:feat/path-lchmod
Open

harshaadimulam22-creator wants to merge 1 commit into
jaraco:mainfrom
harshaadimulam22-creator:feat/path-lchmod

Conversation

@harshaadimulam22-creator

Copy link
Copy Markdown

Summary

Add Path.lchmod(mode) as a further step toward pathlib compatibility.

The method calls os.chmod(..., follow_symlinks=False) to change a
symbolic link's permissions without following it to its target.
It returns self, following the existing Path.chmod() convention,
and propagates operating-system errors when unsupported.

Refs #214. This addresses the lchmod item only.

Changes

  • Add the method and its documentation.
  • Add five test cases covering delegation, return value, error
    propagation, regular files, and preservation of a symlink's target.
  • Add a Towncrier feature fragment.

Validation

Tested on Windows with Python 3.14.7:

  • Before implementation: five new tests failed because lchmod
    was missing.
  • After implementation: five new tests passed.
  • python -m tox: 166 passed, 7 skipped.
  • Ruff formatting, linting, and mypy checks passed.

The tox run reported two EncodingWarnings from text reads/writes
in the new tests.

AI assistance

I used AI assistance to prepare the implementation and tests.
I ran the checks locally and reviewed the changes before submitting.

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.

1 participant