-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix #457: Make --exclude
option follow symlinked directories
#458
fix #457: Make --exclude
option follow symlinked directories
#458
Conversation
exclude
option follow symlinks--exclude
option follow symlinks
--exclude
option follow symlinks--exclude
option follow symlinked directories
except IndexError: | ||
# for some reason Path.glob(".") raises an index error, | ||
# although glob.glob(".") returns ["."] | ||
pass |
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 wonder if we can remove this error handling block given that we're no longer calling Path.glob()
at all?
# latter would be more concise, since Path.glob() does not | ||
# resolve symlinks properly in Python <3.13 | ||
exclude_set.update( | ||
[Path(g) for g in glob(str(exclude_root / s), recursive=True)] |
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 feels a bit hacky to cast the Path
object to a string here, but it's the only way to get it to work with glob.glob()
, which expects a string. It's probably fine, and hopefully the tests would tell us if it wasn't, but part of me is a bit nervous about the platform compatibility of this change -- It works fine on my Ubuntu machine, but I can't help being nervous that e.g. Windows may handle this string conversion incorrectly.
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.
Should be safe to do it this way, but thanks for calling out this change!
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.
Great job with this! Thanks so much
# latter would be more concise, since Path.glob() does not | ||
# resolve symlinks properly in Python <3.13 | ||
exclude_set.update( | ||
[Path(g) for g in glob(str(exclude_root / s), recursive=True)] |
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.
Should be safe to do it this way, but thanks for calling out this change!
This PR updates the globbing behavior for the
--exclude
option inapi.get_matching_paths()
to rely only onglob.glob()
instead ofPath.glob()
, the latter of which contains a bug on Python <3.13 such that it does not always follow symlinked directories correctly.