Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-125413: Add pathlib.Path.info attribute #127730

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6046a27
GH-125413: pathlib ABCs: replace `_scandir()` with `_info`
barneygale Dec 7, 2024
a57c4a8
Merge branch 'main' into gh-125413-info
barneygale Dec 9, 2024
76ef028
Rename `_info` to `_status`
barneygale Dec 9, 2024
5d92785
Add `Status` protocol.
barneygale Dec 9, 2024
dc403c6
Make `Path.status` public.
barneygale Dec 9, 2024
5a128b9
Fix docs typos
barneygale Dec 9, 2024
cac77a6
Docs fixes
barneygale Dec 9, 2024
6e09ada
Fix whatsnew
barneygale Dec 9, 2024
1d8713e
Fix _PathStatus repr, exception handling
barneygale Dec 9, 2024
f8ffbbd
Docs improvements
barneygale Dec 9, 2024
0a86e68
Move PathGlobber into glob.py, now that it uses the public path inter…
barneygale Dec 9, 2024
b0b621d
Simplify _PathStatus implementation a little
barneygale Dec 10, 2024
ef650fd
Add some tests
barneygale Dec 10, 2024
7b990c6
Add news
barneygale Dec 10, 2024
cf1073c
Docs tweaks
barneygale Dec 10, 2024
28bcf00
Merge branch 'main' into gh-125413-info
barneygale Dec 11, 2024
764b8ae
Wrap `os.DirEntry` in `_DirEntryStatus`
barneygale Dec 11, 2024
fa8931b
Add `Status.exists()`
barneygale Dec 11, 2024
2bb6221
Fix test name
barneygale Dec 11, 2024
923542b
Use status.exists() in docs example
barneygale Dec 11, 2024
68377c4
Docs editing
barneygale Dec 12, 2024
4f3f434
Few more test cases
barneygale Dec 12, 2024
2f4da5d
Merge branch 'main' into gh-125413-info
barneygale Dec 12, 2024
a7cffe7
Merge branch 'main' into gh-125413-info
barneygale Dec 12, 2024
dc6edc8
Merge branch 'main' into gh-125413-info
barneygale Dec 12, 2024
530771d
Suppress OSErrors
barneygale Dec 17, 2024
89ff6d4
Add Windows implementation using os.path.isdir() etc
barneygale Dec 17, 2024
592603b
Docstrings
barneygale Dec 17, 2024
bd6332a
Optimise Windows implementation a bit
barneygale Dec 17, 2024
f0ee0e9
More tidying of _PathStatus and friends
barneygale Dec 17, 2024
5ae8b06
`status` --> `info`
barneygale Dec 21, 2024
6e25d2d
`Parser` --> `_PathParser`
barneygale Dec 21, 2024
c93237d
Merge branch 'main' into gh-125413-info
barneygale Dec 22, 2024
2624363
Merge branch 'main' into gh-125413-info
barneygale Dec 29, 2024
662fd2d
Merge branch 'main' into gh-125413-info
barneygale Jan 5, 2025
dbc312c
Merge branch 'main' into gh-125413-info
barneygale Jan 8, 2025
ee7da1d
Update Lib/pathlib/_local.py
barneygale Jan 10, 2025
47ed3de
Merge branch 'main' into gh-125413-info
barneygale Jan 11, 2025
d2e254a
Move path info from `pathlib._local` to `pathlib._os`.
barneygale Jan 20, 2025
60b3ac4
Merge branch 'main' into gh-125413-info
barneygale Jan 21, 2025
7658dc8
Merge branch 'main' into gh-125413-info
barneygale Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix docs typos
  • Loading branch information
barneygale committed Dec 9, 2024
commit 5a128b98f9ef517c9bfb4e4cfdd2d4b011e90478
10 changes: 5 additions & 5 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1179,28 +1179,28 @@

.. attribute:: Path.status

A :class:`Status` object that supports querying file type information. The

Check warning on line 1182 in Doc/library/pathlib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:class reference target not found: Status [ref.class]

Check warning on line 1182 in Doc/library/pathlib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:meth reference target not found: Status.is_dir [ref.meth]
object exposes methods like :meth:`~Status.is_dir` that cache their
results, which can help reduce the number of system calls needed when
switching on file type. Care must be taken to avoid incorrectly using
cached results::

>>> p = Path('setup.py')
>>> p.info.is_file()
>>> p.status.is_file()
True
>>> p.unlink()
>>> p.info.is_file() # returns stale info
>>> p.status.is_file() # returns stale status
True
>>> p = Path(p) # get fresh info
>>> p.info.is_file()
>>> p = Path(p) # get fresh status
>>> p.status.is_file()
False

The value is a :class:`os.DirEntry` instance if the path was generated by
:meth:`Path.iterdir`. These objects are initialized with some information
about the file type; see the :func:`os.scandir` docs for more. In other
cases, this attribute is an instance of an internal pathlib class which
initially knows nothing about the file status. In either case, merely
accessing :attr:`Path.info` does not perform any filesystem queries.
accessing :attr:`Path.status` does not perform any filesystem queries.

.. versionadded:: 3.14

Expand Down Expand Up @@ -1947,7 +1947,7 @@

.. class:: Status()

A :class:`typing.Protocol` describing the :attr:`Path.status` attribute.

Check warning on line 1950 in Doc/library/pathlib.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:attr reference target not found: Path.status [ref.attr]
Implementations may return cached results from their methods.

.. method:: is_dir(*, follow_symlinks=True)
Expand Down
Loading