-
Notifications
You must be signed in to change notification settings - Fork 16
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
simplified the as_start_path function and remove the #todo as it it ca… #61
Open
jasonbrackman
wants to merge
6
commits into
chendaniely:main
Choose a base branch
from
jasonbrackman:simplified_as_start_path
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d7595da
siplified the as_start_path function and remove the #todo as it it ca…
jasonbrackman 02e742d
Added an expanduser() before returning path to ensure that any input …
jasonbrackman 71cb1f0
removed space from end of lines.
jasonbrackman decaf66
- add .resolve() to handle the '.' and '..' normalization for the Pat…
jasonbrackman 84ad46a
removed white space
jasonbrackman 428b331
Looks like I need to have the tests run from pyprojroot. I'll need t…
jasonbrackman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 pretty sure that we need to do something like
resolve
orexpanduser
. So the TODO still stands.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.
Hi James,
I was wondering what the usecase was. The Path returned can have the caller call resolve(). Is there a reason for doing this step at this time?
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 also realizing I wrote that it is using the 'common working directory -- but its the 'current working directory'. Would also need to fix that depending on how this conversation goes :). I'm interested to understand the resolve aspect though.
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.
What happens if you call
find_root(criterion, start=".")
orfind_root(criterion, start="~/project")
?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 asked the above question by creating a script called examination and placed it here:
/usr/local/bin/python3 /Users/jasonbrackman/PycharmProjects/pyprojroot/tests/examination.py
Demo Code:
Resulted in:
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 answer will of course depend on the criteria and the files/directories present, but I don't think it should the user to expand or resolve the input in advance. Otherwise we would also require the user to pass a Path object rather than anything PathLike.
The biggest issue is with
start="."
since the current implementation will not look any further up the heirarchy than"."
. For"~"
, it's unlikely that anyone will look for a root that is in a parent of the"~"
directory.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.
E.g.
Using v0.3.0, calling
find_root(".here", start=".")
from thenotebooks
directory will raiseRuntimeError
rather than"/user/projects/big_analysis"
.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.
Updated the review to take advantage of .expanduser() before return the path. Here is my input/output:
Produces:
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.
You haven't addressed normalising the
.
and..
parts.find_root('.here', start='.')
only works for you because there's a.here
file in that directory. If you call it from a sub-directory, then it will raise a RuntimeError. Similarly if you runfind_root('.here', start='..')
, then it returns"."
!