-
Notifications
You must be signed in to change notification settings - Fork 93
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
Out of Scope Variable in Exception Block in constants.py #2283
Conversation
@@ -34,11 +34,12 @@ | |||
# ToDo refactor to generic functions, keep only constants | |||
HOME = os.path.expanduser(f"~{os.path.sep}") | |||
MSUI_CONFIG_PATH = os.getenv("MSUI_CONFIG_PATH", os.path.join(HOME, ".config", "msui")) | |||
_fs = None |
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.
This doesn't solve the issue. Now it is possible that .makedirs
is called on None
.
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.
Ok
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.
Please remove this _fs = None
line, it should not be necessary.
if '://' in MSUI_CONFIG_PATH: | ||
try: | ||
_fs = fs.open_fs(MSUI_CONFIG_PATH) | ||
_fs = fs.open_fs(fs.path.dirname(MSUI_CONFIG_PATH)) |
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.
look at the idea in the issue. There should be only one attempt for the fs.errors.CreateFailed because it could be a remote system,
and it would be good to have a test for describing the problem and evaluating the fix by that
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.
Ok
Kindly checkout the changes @ReimarBauer @matrss |
_fs = fs.open_fs(MSUI_CONFIG_PATH) | ||
except fs.errors.CreateFailed: | ||
_fs.makedirs(MSUI_CONFIG_PATH) | ||
_fs = fs.open_fs(fs.path.dirname(MSUI_CONFIG_PATH)) |
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 am not convinced that fs.path.dirname is correct there. For the default value of ~/.config/msui
defined above this would open ~/.config
, which seems wrong to me.
The code seems to get more complicated than it needs to be (but I am not completely sure). Therefore, I would like to take a step back and ask this: what is this code intended to do? What is the intended outcome of the code that was found to be buggy in #2274? Because I am not sure on that yet, and I can't properly review a PR without having that knowledge... This is probably a question for @ReimarBauer. |
I provide tom. a testcase. This looks now a bit too much for a constant |
This shows an example to illustrate the problem"s". There can be a lot cases why a remote address can fail. I prefer to crash here, without catching all unknown possibilities dependent on the potential used module. We should just not try to create a remote folder.
The error looks now like
|
there is a different solution #2343 |
Purpose of PR?:
Fixes #2274
Does this PR introduce a breaking change?
If the changes in this PR are manually verified, list down the scenarios covered::
Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs
Does this PR results in some Documentation changes?
If yes, include the list of Documentation changes
Checklist:
<type>: <subject>