@@ -640,7 +640,7 @@ def with_suffix(self, suffix):
640
640
return self ._from_parsed_parts (self ._drv , self ._root ,
641
641
self ._parts [:- 1 ] + [name ])
642
642
643
- def relative_to (self , * other ):
643
+ def relative_to (self , other , * args ):
644
644
"""Return the relative path to another path identified by the passed
645
645
arguments. If the operation is not possible (because this is not
646
646
a subpath of the other path), raise ValueError.
@@ -649,16 +649,19 @@ def relative_to(self, *other):
649
649
# separate parts, i.e.:
650
650
# Path('c:/').relative_to('c:') gives Path('/')
651
651
# Path('c:/').relative_to('/') raise ValueError
652
- if not other :
653
- raise TypeError ("need at least one argument" )
652
+ if args :
653
+ warnings .warn ("support for supplying more than one argument to "
654
+ "pathlib.PurePath.relative_to() is deprecated and "
655
+ "scheduled for removal in Python 3.14." ,
656
+ DeprecationWarning , stacklevel = 2 )
654
657
parts = self ._parts
655
658
drv = self ._drv
656
659
root = self ._root
657
660
if root :
658
661
abs_parts = [drv , root ] + parts [1 :]
659
662
else :
660
663
abs_parts = parts
661
- to_drv , to_root , to_parts = self ._parse_args (other )
664
+ to_drv , to_root , to_parts = self ._parse_args (( other ,) + args )
662
665
if to_root :
663
666
to_abs_parts = [to_drv , to_root ] + to_parts [1 :]
664
667
else :
@@ -673,11 +676,17 @@ def relative_to(self, *other):
673
676
return self ._from_parsed_parts ('' , root if n == 1 else '' ,
674
677
abs_parts [n :])
675
678
676
- def is_relative_to (self , * other ):
679
+ def is_relative_to (self , other , * args ):
677
680
"""Return True if the path is relative to another path or False.
678
681
"""
682
+ if args :
683
+ warnings .warn ("support for supplying more than one argument to "
684
+ "pathlib.PurePath.is_relative_to() is deprecated "
685
+ "and scheduled for removal in Python 3.14." ,
686
+ DeprecationWarning , stacklevel = 2 )
687
+ other = self ._from_parts ((other ,) + args )
679
688
try :
680
- self .relative_to (* other )
689
+ self .relative_to (other )
681
690
return True
682
691
except ValueError :
683
692
return False
0 commit comments