Skip to content

Commit

Permalink
GH-74033: Drop deprecated pathlib.Path keyword arguments (#118793)
Browse files Browse the repository at this point in the history
Remove support for supplying keyword arguments to `pathlib.Path()`. This
has been deprecated since Python 3.12.
  • Loading branch information
barneygale committed May 14, 2024
1 parent fbe6a09 commit 7d8725a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ itertools
pathlib
-------

* Remove support for passing additional keyword arguments to
:class:`pathlib.Path`. In previous versions, any such arguments are ignored.
* Remove support for passing additional positional arguments to
:meth:`pathlib.PurePath.relative_to` and
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such
Expand Down
7 changes: 0 additions & 7 deletions Lib/pathlib/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,6 @@ class Path(PathBase, PurePath):
def _unsupported_msg(cls, attribute):
return f"{cls.__name__}.{attribute} is unsupported on this system"

def __init__(self, *args, **kwargs):
if kwargs:
msg = ("support for supplying keyword arguments to pathlib.PurePath "
"is deprecated and scheduled for removal in Python {remove}")
warnings._deprecated("pathlib.PurePath(**kwargs)", msg, remove=(3, 14))
super().__init__(*args)

def __new__(cls, *args, **kwargs):
if cls is Path:
cls = WindowsPath if os.name == 'nt' else PosixPath
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,8 @@ def test_is_mount_root(self):
self.assertTrue(R.is_mount())
self.assertFalse((R / '\udfff').is_mount())

def test_passing_kwargs_deprecated(self):
with self.assertWarns(DeprecationWarning):
def test_passing_kwargs_errors(self):
with self.assertRaises(TypeError):
self.cls(foo="bar")

def setUpWalk(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for passing keyword arguments to :class:`pathlib.Path`.

0 comments on commit 7d8725a

Please sign in to comment.