bpo-44136: remove pathlib._Flavour#26141
Closed
barneygale wants to merge 14 commits intopython:mainfrom
Closed
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For bpo-24132, we'd like subclasses of
AbstractPathto be able to customize flavour behaviour (likeas_uri()) without needing to promote_Flavourto a public class.(Copy-pasted bug description:)
Following #18841, #25264 and #25701,
pathlib._Flavourand its subclasses are looking a bit pointless.The implementations of
is_reserved()andmake_uri()(~as_uri()) can be readily moved to intoPurePosixPathandPureWindowsPath, which removes some indirection. This follows the pattern of OS-specific stuff inPosixPathandWindowsPath.The remaining methods, such as
splitroot(), can be pulled intoPure*Pathwith an underscore prefix.I'm generally a believer in composition over inheritance, but in this case
_Flavourseems too small and too similar toPurePathto 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