pathlib.types
— Types for virtual filesystem paths¶
Added in version 3.14.
Source code: Lib/pathlib/types.py
The pathlib.types
module provides protocols for user-defined types that
resemble pathlib.Path
and its associated classes. This module
includes type annotations, so it’s also useful for static type checking.
- class pathlib.types.PathInfo¶
A
typing.Protocol
that supports fetching and caching information about a path.pathlib.Info
is an implementation of this protocol with additional methods specific to local filesystems.- exists(*, follow_symlinks=True)¶
Return
True
if the path is an existing file or directory, or any other kind of file; returnFalse
if the path doesn’t exist.If follow_symlinks is
False
, returnTrue
for symlinks without checking if their targets exist.
- is_dir(*, follow_symlinks=True)¶
Return
True
if the path is a directory, or a symbolic link pointing to a directory; returnFalse
if the path is (or points to) any other kind of file, or if it doesn’t exist.If follow_symlinks is
False
, returnTrue
only if the path is a directory (without following symlinks); returnFalse
if the path is any other kind of file, or if it doesn’t exist.
- is_file(*, follow_symlinks=True)¶
Return
True
if the path is a file, or a symbolic link pointing to a file; returnFalse
if the path is (or points to) a directory or other non-file, or if it doesn’t exist.If follow_symlinks is
False
, returnTrue
only if the path is a file (without following symlinks); returnFalse
if the path is a directory or other non-file, or if it doesn’t exist.
- is_symlink()¶
Return
True
if the path is a symbolic link (even if broken); returnFalse
if the path is a directory or any kind of file, or if it doesn’t exist.