Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-128520: Subclassabc.ABC inpathlib._abc#128745

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
barneygale merged 12 commits intopython:mainfrombarneygale:grown-up-abcs
Feb 16, 2025
Merged
Changes from1 commit
Commits
Show all changes
12 commits
Select commitHold shift + click to select a range
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
PrevPrevious commit
NextNext commit
Merge branch 'main' into grown-up-abcs
  • Loading branch information
@barneygale
barneygale committedFeb 8, 2025
commit048f22abbced4d16418ffa6920f1ff77479d52ab
21 changes: 8 additions & 13 deletionsLib/pathlib/_abc.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@

import functools
import io
import operator
from abc import ABC, abstractmethod
from errno import EINVAL
from glob import _PathGlobber, _no_recurse_symlinks
Expand DownExpand Up@@ -375,7 +374,15 @@ class ReadablePath(JoinablePath):
"""
__slots__ = ()

@property
@abstractmethod
def info(self):
"""
A PathInfo object that exposes the file type and other file attributes
of this path.
"""
raise NotImplementedError

def exists(self, *, follow_symlinks=True):
"""
Whether this path exists.
Expand All@@ -386,15 +393,13 @@ def exists(self, *, follow_symlinks=True):
info = self.joinpath().info
return info.exists(follow_symlinks=follow_symlinks)

@abstractmethod
def is_dir(self, *, follow_symlinks=True):
"""
Whether this path is a directory.
"""
info = self.joinpath().info
return info.is_dir(follow_symlinks=follow_symlinks)

@abstractmethod
def is_file(self, *, follow_symlinks=True):
"""
Whether this path is a regular file (also True for symlinks pointing
Expand All@@ -403,7 +408,6 @@ def is_file(self, *, follow_symlinks=True):
info = self.joinpath().info
return info.is_file(follow_symlinks=follow_symlinks)

@abstractmethod
def is_symlink(self):
"""
Whether this path is a symbolic link.
Expand DownExpand Up@@ -433,15 +437,6 @@ def read_text(self, encoding=None, errors=None, newline=None):
with magic_open(self, mode='r', encoding=encoding, errors=errors, newline=newline) as f:
return f.read()

def _scandir(self):
"""Yield os.DirEntry-like objects of the directory contents.

The children are yielded in arbitrary order, and the
special entries '.' and '..' are not included.
"""
import contextlib
return contextlib.nullcontext(self.iterdir())

@abstractmethod
def iterdir(self):
"""Yield path objects of the directory contents.
Expand Down
You are viewing a condensed version of this merge commit. You can view thefull changes here.

[8]ページ先頭

©2009-2025 Movatter.jp