Add _BaseSegment to simplify type annotations. #109
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.
_BaseSegment is a private type alias for either PathSegment or Move classes.
It simplifies the type annotations and resolves most of the typing issue.
This commit also fixes the typing issues for slices (as in getitem).
Adding typing for slices make the behaviour of the Path class a bit more official.
Path behaves here a bit differently from most mutable sequences.
For example, a slice of an array is an array:
Therefore it would make sense that a slice of a Path would also be a Path
and not a list.
We could make any usage of slice raise a NotImplementedError.
It would brake backward compatibility, but I would be surprised if anyone
is using slices of Path.
The other option is to apply this PR as is.