mirror of https://github.com/python/cpython
bpo-46483: Remove `__class_getitem__` from `pathlib.PurePath` (GH-30848)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
0cbdd21311
commit
7ffe7ba30f
|
@ -545,6 +545,9 @@ Removed
|
||||||
Python 3.4 but has been broken since Python 3.7.
|
Python 3.4 but has been broken since Python 3.7.
|
||||||
(Contributed by Inada Naoki in :issue:`23882`.)
|
(Contributed by Inada Naoki in :issue:`23882`.)
|
||||||
|
|
||||||
|
* Remove ``__class_getitem__`` method from :class:`pathlib.PurePath`,
|
||||||
|
because it was not used and added by mistake in previous versions.
|
||||||
|
(Contributed by Nikita Sobolev in :issue:`46483`.)
|
||||||
|
|
||||||
Porting to Python 3.11
|
Porting to Python 3.11
|
||||||
======================
|
======================
|
||||||
|
|
|
@ -12,7 +12,6 @@ from errno import ENOENT, ENOTDIR, EBADF, ELOOP
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
|
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
|
||||||
from urllib.parse import quote_from_bytes as urlquote_from_bytes
|
from urllib.parse import quote_from_bytes as urlquote_from_bytes
|
||||||
from types import GenericAlias
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
@ -604,8 +603,6 @@ class PurePath(object):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
return self._cparts >= other._cparts
|
return self._cparts >= other._cparts
|
||||||
|
|
||||||
__class_getitem__ = classmethod(GenericAlias)
|
|
||||||
|
|
||||||
drive = property(attrgetter('_drv'),
|
drive = property(attrgetter('_drv'),
|
||||||
doc="""The drive prefix (letter or UNC path), if any.""")
|
doc="""The drive prefix (letter or UNC path), if any.""")
|
||||||
|
|
||||||
|
|
|
@ -2450,15 +2450,6 @@ class _BasePathTest(object):
|
||||||
def test_complex_symlinks_relative_dot_dot(self):
|
def test_complex_symlinks_relative_dot_dot(self):
|
||||||
self._check_complex_symlinks(os.path.join('dirA', '..'))
|
self._check_complex_symlinks(os.path.join('dirA', '..'))
|
||||||
|
|
||||||
def test_class_getitem(self):
|
|
||||||
from types import GenericAlias
|
|
||||||
|
|
||||||
alias = self.cls[str]
|
|
||||||
self.assertIsInstance(alias, GenericAlias)
|
|
||||||
self.assertIs(alias.__origin__, self.cls)
|
|
||||||
self.assertEqual(alias.__args__, (str,))
|
|
||||||
self.assertEqual(alias.__parameters__, ())
|
|
||||||
|
|
||||||
|
|
||||||
class PathTest(_BasePathTest, unittest.TestCase):
|
class PathTest(_BasePathTest, unittest.TestCase):
|
||||||
cls = pathlib.Path
|
cls = pathlib.Path
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
Change :meth:`pathlib.PurePath.__class_getitem__` to return
|
|
||||||
:class:`types.GenericAlias`.
|
|
|
@ -0,0 +1 @@
|
||||||
|
Remove :meth:`~object.__class_getitem__` from :class:`pathlib.PurePath` as this class was not supposed to be generic.
|
Loading…
Reference in New Issue