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.Protocolthat supports fetching and caching information about a path.pathlib.Infois an implementation of this protocol with additional methods specific to local filesystems.- exists(*, follow_symlinks=True)¶
Return
Trueif the path is an existing file or directory, or any other kind of file; returnFalseif the path doesn’t exist.If follow_symlinks is
False, returnTruefor symlinks without checking if their targets exist.
- is_dir(*, follow_symlinks=True)¶
Return
Trueif the path is a directory, or a symbolic link pointing to a directory; returnFalseif the path is (or points to) any other kind of file, or if it doesn’t exist.If follow_symlinks is
False, returnTrueonly if the path is a directory (without following symlinks); returnFalseif the path is any other kind of file, or if it doesn’t exist.
- is_file(*, follow_symlinks=True)¶
Return
Trueif the path is a file, or a symbolic link pointing to a file; returnFalseif the path is (or points to) a directory or other non-file, or if it doesn’t exist.If follow_symlinks is
False, returnTrueonly if the path is a file (without following symlinks); returnFalseif the path is a directory or other non-file, or if it doesn’t exist.
- is_symlink()¶
Return
Trueif the path is a symbolic link (even if broken); returnFalseif the path is a directory or any kind of file, or if it doesn’t exist.