Skip to content

Add pathlib-compatible is_symlink - #265

Open
arindamsikder wants to merge 1 commit into
jaraco:mainfrom
arindamsikder:feat/pathlib-is-symlink
Open

arindamsikder wants to merge 1 commit into
jaraco:mainfrom
arindamsikder:feat/pathlib-is-symlink

Conversation

@arindamsikder

Copy link
Copy Markdown

Summary

Add Path.is_symlink() for pathlib compatibility, retaining islink() as a deprecated alias.

Problem

The compatibility checklist in #214 includes is_symlink, but Path currently only provides the os.path-style islink() spelling. Code using the pathlib method therefore raises AttributeError.

Solution

  • Wrap self.module.islink(self) in is_symlink(), preserving the configurable path backend and existing predicate behavior, including dangling symlinks.
  • Have islink() return the same result through the new method and emit DeprecationWarning at the caller, following the request in Maximize compatibility with pathlib.Path #214 to deprecate duplicate spellings.
  • Migrate the internal merge_tree call and existing test callers, add regular-file/directory/missing-path and symlink regression cases, and add a changelog fragment.

Testing

Executed on Linux/Python 3.11.15 in a credential-free Bubblewrap sandbox with networking disabled:

  • python -m pytest tests/test_path.py::TestLinks::test_is_symlink tests/test_path.py::TestLinks::test_islink_deprecated -q -p no:cacheprovider --basetemp=/tmp/pytest --cov-report= --tb=short: 8 passed. The same final tests against unchanged source produce 8 expected failures (missing method or missing warning).
  • python -m pytest tests/test_path.py -k merge -q -p no:cacheprovider --basetemp=/tmp/pytest --cov-report= --tb=short -W error::DeprecationWarning: 6 passed; before migrating the internal caller, 3 failed on its deprecation warning.
  • Canonical checks via python -m pytest -q -p no:cacheprovider --basetemp=/tmp/pytest --cov=path --cov-report=term --tb=short -W error::DeprecationWarning: 141 passed, 1 skipped, 7 existing Ruff file-check failures. Unchanged source: 133 passed, 1 skipped, the same 7 Ruff failures. Raw Ruff results contain the same 34 diagnostics, with no new findings. Mypy passed for 8 source files. New runtime lines are covered.
  • python -m ruff format --check .: passed.
  • python -m build --no-isolation --outdir build/staged-artifacts and python -m twine check --strict build/staged-artifacts/*: passed; wheel source matches the patch and the sdist includes the news fragment.
  • Strict Sphinx HTML build and python -m sphinxlint docs: passed. Because the sandbox is offline, the strict build used Sphinx's API with a pre-fetched Python intersphinx inventory; warningiserror=True and keep_going=True were retained. Without that cached inventory, unchanged/fixed source has 95/96 unresolved-reference/network warnings; these disappear with the inventory.
  • Subclass Path.module delegation and deprecation stacklevel probe, git diff --check, added-line security scan, and independent AI review passed.

Windows, macOS and other Python versions were not run locally. The repository disables module doctests on this Python version through its existing conftest workaround; that was not changed. Symlink tests follow the existing suite's requirement that the platform permits symlink creation.

Related Issue

Refs #214 — this only implements the is_symlink item, not the whole compatibility checklist.

AI disclosure: implementation, validation and this description were prepared by a Hermes AI agent, with independent AI code review. No human pre-review is claimed.

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