classification
Title: Add Path.is_relative_to()
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, pitrou, shihai1991
Priority: normal Keywords: easy, patch

Created on 2019-07-26 15:56 by pitrou, last changed 2019-08-13 19:54 by pitrou. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14982 merged shihai1991, 2019-07-27 17:56
Messages (4)
msg348498 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2019-07-26 15:56
Right now, to know whether a Path is relative to another one, you have to call Path.relative_to(), catch ValueError, and act in consequence.

It would be nice to have a Path.is_relative_to() that does the equivalent for you and returns True/False.

This is probably a good easy issue for a beginner contributor.
msg348504 - (view) Author: hai shi (shihai1991) * Date: 2019-07-26 16:36
antoine, let me try it;)
msg348553 - (view) Author: hai shi (shihai1991) * Date: 2019-07-27 18:04
Hi, Antoine, pls review this PR if you have free time.
Looks is_relative_to only catch valueError is good enough.
msg349612 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2019-08-13 19:54
New changeset 82642a052dc46b2180679518bc8d87e1a28a88b5 by Antoine Pitrou (Hai Shi) in branch 'master':
bpo-37689: add Path.is_relative_to() method (GH-14982)
https://github.com/python/cpython/commit/82642a052dc46b2180679518bc8d87e1a28a88b5
History
Date User Action Args
2019-08-13 19:54:35pitrousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-08-13 19:54:06pitrousetmessages: + msg349612
2019-07-29 18:47:27brett.cannonsetnosy: + brett.cannon
2019-07-29 15:46:04vstinnersetnosy: - vstinner
2019-07-27 18:04:06shihai1991setmessages: + msg348553
2019-07-27 17:56:46shihai1991setkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request14749
2019-07-26 16:36:59shihai1991setnosy: + shihai1991
messages: + msg348504
2019-07-26 15:56:04pitroucreate