Skip to content

Conversation

@jaraco
Copy link
Member

@jaraco jaraco commented Apr 17, 2022

Inspired by #248 (comment)

  • Inline the flattening of descendants.
  • Move ResourceContainer.joinpath to Traversable.joinpath, providing a concrete implementation.
  • Refactor to converge descendants to a single type and rely on Path.parts for getting the parts.
  • Replace StopIteration with a TraversalError for use in capturing a failed traversal.
  • In readers.MultiplexedPath, re-use Traversable.joinpath.

Copy link
Member

@FFY00 FFY00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the look at the PR and it seems good. Thank you for splitting each logical change into its own commit.

I only have one note.

try:
return next(matches).joinpath(*names)
except StopIteration:
raise TraversalError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way for this to happen is no arguments being passed, no? Wouldn't checking for that directly make the code easier to read?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's correct. A StopIteration would occur if none of the traversable.name == target in the matches above (including if self.iterdir() yields no results). It's trapping StopIteration on next(matches), not *names. *names can be empty. Maybe only the exception should be trapped for next(matches).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, that makes sense.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants