Skip to content

GH-74033: Drop deprecated pathlib.Path keyword arguments #118793

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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`.
Loading