-
Notifications
You must be signed in to change notification settings - Fork 47
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
Return empty tuple for no selected files #415
Conversation
This change makes the FileEdit in EXISTING_FILES mode return an empty tuple if no files are selected. The ability to detect "no selected file" is important to prevent parsing files that don't exist. The FileEdit has three possibilities, either it always has a Path value, or it is nullable and the neutral value should be None, or it is in multiple file selection mode and according to the signature, the neutral element should be an empty tuple. However, since `""`.split(some_delimiter)` always gives `[""]`, it currently returns a tuple with an empty path `Path(".")` which equals the home directory and is very impractical to distinguish from an intentionally selected path.
thanks! can you add a test somewhere? Also, what about |
Good point! I was looking at the code that explicitly sets the line edit to an empty string. My version wouldn't have caught spaces |
I also fixed two more issues:
Also, is |
Codecov Report
@@ Coverage Diff @@
## main #415 +/- ##
==========================================
+ Coverage 88.74% 88.90% +0.15%
==========================================
Files 30 30
Lines 3838 3839 +1
==========================================
+ Hits 3406 3413 +7
+ Misses 432 426 -6
Continue to review full report at Codecov.
|
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.
thanks! this looks great! and thank you for the tests!
The mypy hook complained because the annotation is Path (although the TypeError in the code allows str). Should I change annotations to PathLike?
which annotation? in the getter? (things look good to me as is)
This change makes the FileEdit in EXISTING_FILES mode return an empty tuple if no files are selected.
The ability to detect "no selected file" is important to prevent parsing invalid/non existing files. The FileEdit has three possibilities, either it always has a Path value, or it is nullable and the neutral value should be None, or it is in multiple file selection mode and according to the signature the neutral value should be a tuple of zero length.
However, since
"".split(some_delimiter)
always gives[""]
instead of[]
, it currently returns a tuple with an empty pathPath(".")
which equals the home directory and is rather impractical to distinguish from an intentionally selected path.