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

Remove support for supplying keyword arguments to `pathlib.Path()`. This
has been deprecated since Python 3.12.
This commit is contained in:
Barney Gale 2024-05-14 21:14:07 +01:00 committed by GitHub
parent fbe6a0988f
commit 7d8725ac6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 9 deletions

View file

@ -131,6 +131,8 @@ itertools
pathlib 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 * Remove support for passing additional positional arguments to
:meth:`pathlib.PurePath.relative_to` and :meth:`pathlib.PurePath.relative_to` and
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such :meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such

View file

@ -483,13 +483,6 @@ class Path(PathBase, PurePath):
def _unsupported_msg(cls, attribute): def _unsupported_msg(cls, attribute):
return f"{cls.__name__}.{attribute} is unsupported on this system" 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): def __new__(cls, *args, **kwargs):
if cls is Path: if cls is Path:
cls = WindowsPath if os.name == 'nt' else PosixPath cls = WindowsPath if os.name == 'nt' else PosixPath

View file

@ -1108,8 +1108,8 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
self.assertTrue(R.is_mount()) self.assertTrue(R.is_mount())
self.assertFalse((R / '\udfff').is_mount()) self.assertFalse((R / '\udfff').is_mount())
def test_passing_kwargs_deprecated(self): def test_passing_kwargs_errors(self):
with self.assertWarns(DeprecationWarning): with self.assertRaises(TypeError):
self.cls(foo="bar") self.cls(foo="bar")
def setUpWalk(self): def setUpWalk(self):

View file

@ -0,0 +1 @@
Drop support for passing keyword arguments to :class:`pathlib.Path`.