Skip to content

bpo-44136: remove pathlib._Flavour#26141

Closed
barneygale wants to merge 14 commits intopython:mainfrom
barneygale:bpo-44136-remove-pathlib-flavour
Closed

bpo-44136: remove pathlib._Flavour#26141
barneygale wants to merge 14 commits intopython:mainfrom
barneygale:bpo-44136-remove-pathlib-flavour

Conversation

@barneygale
Copy link
Contributor

@barneygale barneygale commented May 15, 2021

For bpo-24132, we'd like subclasses of AbstractPath to be able to customize flavour behaviour (like as_uri()) without needing to promote _Flavour to a public class.

(Copy-pasted bug description:)

Following #18841, #25264 and #25701, 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.

I've tried to split the changes up across commits; it may be easier to browse the diff that way.

https://bugs.python.org/issue44136

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants