Repository navigation
Add pathlib-compatible is_symlink - #265
Open
arindamsikder wants to merge 1 commit into
Open
arindamsikder wants to merge 1 commit into
arindamsikder wants to merge 1 commit into
Conversation
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.
Summary
Add
Path.is_symlink()for pathlib compatibility, retainingislink()as a deprecated alias.Problem
The compatibility checklist in #214 includes
is_symlink, butPathcurrently only provides theos.path-styleislink()spelling. Code using the pathlib method therefore raisesAttributeError.Solution
self.module.islink(self)inis_symlink(), preserving the configurable path backend and existing predicate behavior, including dangling symlinks.islink()return the same result through the new method and emitDeprecationWarningat the caller, following the request in Maximize compatibility withpathlib.Path#214 to deprecate duplicate spellings.merge_treecall 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.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-artifactsandpython -m twine check --strict build/staged-artifacts/*: passed; wheel source matches the patch and the sdist includes the news fragment.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=Trueandkeep_going=Truewere retained. Without that cached inventory, unchanged/fixed source has 95/96 unresolved-reference/network warnings; these disappear with the inventory.Path.moduledelegation 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_symlinkitem, 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.