This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Remove pathlib flavours
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: pitrou Nosy List: barneygale, pitrou
Priority: normal Keywords: patch

Created on 2021-05-14 18:28 by barneygale, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 26141 closed barneygale, 2021-05-15 08:21
PR 26708 closed barneygale, 2021-06-13 16:55
PR 30320 closed barneygale, 2022-01-01 06:08
PR 30321 closed barneygale, 2022-01-01 06:09
PR 31691 open barneygale, 2022-03-05 02:18
Messages (3)
msg393685 - (view) Author: Barney Gale (barneygale) * Date: 2021-05-14 18:28
Following bpo-39899, bpo-43757 and bpo-43012, `pathlib._Flavour` and its subclasses are looking a bit pointless.

The implementations of `is_reserved()` and `make_uri()` (~`as_uri()`) can be readily moved to into `PurePosixPath` and `PureWindowsPath`, which removes some indirection. This follows the pattern of OS-specific stuff in `PosixPath` and `WindowsPath`.

The remaining methods, such as `splitroot()`, can be pulled into `Pure*Path` with an underscore prefix.

I'm generally a believer in composition over inheritance, but in this case `_Flavour` seems too small and too similar to `PurePath` to separate out into 3 extra classes.

There should be no impact on public APIs or performance.
msg395759 - (view) Author: Barney Gale (barneygale) * Date: 2021-06-13 18:25
Depends: bpo-39899, bpo-43757, bpo-44316, bpo-44403, bpo-44412
msg413857 - (view) Author: Barney Gale (barneygale) * Date: 2022-02-23 21:27
^ just to bring my previous comment up-to-date:

I'm no longer pursuing adding `os.path.isreserved()` and `os.path.fileuri()` functions, or modifying `normpath()`. At least, not for now!

Instead, my plan is to move flavour functionality as follows (as classmethods with underscore prefixes):

  _Flavour        --> PurePath
  _PosixFlavour   --> PurePath
  _WindowsFlavour --> PureWindowsPath

As a result, PurePath will use POSIX syntax by default. This is fully backwards-compatible, as users can't create PurePath objects! PurePath.__new__() instantiates PurePosixPath or PureWindowsPath. But it will matter for future user subclasses of PurePath/Path, where we usually want POSIX syntax.

I think there will be three PRs involved. PR 30320 and PR 30321 move _Flavour.make_uri() and _Flavour.is_reserved() respectively; these are reasonably standalone. If/when they land, I'll make a larger PR that moves the remaining methods into PurePath and PureWindowsPath.
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88302
2022-03-05 02:18:42barneygalesetpull_requests: + pull_request29813
2022-02-23 21:27:45barneygalesetmessages: + msg413857
2022-01-01 06:09:19barneygalesetpull_requests: + pull_request28537
2022-01-01 06:08:39barneygalesetpull_requests: + pull_request28536
2021-06-13 18:25:31barneygalesetmessages: + msg395759
2021-06-13 16:55:20barneygalesetpull_requests: + pull_request25297
2021-05-15 17:55:09rhettingersetassignee: pitrou

nosy: + pitrou
2021-05-15 08:21:18barneygalesetkeywords: + patch
stage: patch review
pull_requests: + pull_request24776
2021-05-14 18:28:58barneygalecreate