New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable MultiplexedPath.joinpath to return MultiplexedPath for common subdirectories #272
base: main
Are you sure you want to change the base?
Conversation
jooste
commented
Oct 20, 2022
•
edited by jaraco
edited by jaraco
- When MultiplexedPath.joinpath is passed a subdirectory (tree) that is common to multiple of the parent's paths, joinpath will return a MultiplexedPath. Fixes Possible bug in MultiplexedPath with partially overlapping subdirectory structure #265
Change MultiplexedPath.joinpath to return a MultiplexedPath when descendants refer to a subdirectory that is common to two or more paths in the parent MultiplexedPath
| @@ -83,12 +83,28 @@ def is_file(self): | |||
| return False | |||
|
|
|||
| def joinpath(self, *descendants): | |||
| try: | |||
| return super().joinpath(*descendants) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sad to lose the re-use of the generalized behavior, though I'm not confident there's any other way. I'd like to review the generalized behavior to see if there's yet any opportunity for re-use.
| # One of the paths did not resolve (a directory does not exist). | ||
| # Just return something that will not exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this comment is lost in the rewrite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed. Although I would suggest a modified version of this comment since now there are more possible cases.
| # Just return something that will not exist. | ||
| return self._paths[0].joinpath(*descendants) | ||
| # first try to find child in current paths | ||
| paths = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of the term 'path' is really overloaded in this method. Let's try to come up with some names that are more indicative of which path/paths are represented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true. My first thought is to rename this to 'candidates', since we are exploring all of our base paths for the same sub path. Another synonym might be better though.