-
Notifications
You must be signed in to change notification settings - Fork 189
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
Use only one global var for marking config folder tree #6610
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
0db80ec
to
418cc2a
Compare
e3e89d1
to
d7f3684
Compare
02307b3
to
959a9ad
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6610 +/- ##
==========================================
+ Coverage 77.51% 77.91% +0.41%
==========================================
Files 560 567 +7
Lines 41444 42161 +717
==========================================
+ Hits 32120 32846 +726
+ Misses 9324 9315 -9 ☔ View full report in Codecov by Sentry. |
344fe89
to
1b26044
Compare
30bae8b
to
c4adbec
Compare
for more information, see https://pre-commit.ci
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.
If basedpyright
is happy with the code, there is probably nothing I can add :D
Looks good to me! Just a few minor comments.
Co-authored-by: Julian Geiger <julian.geiger@psi.ch>
DAEMON_DIR: pathlib.Path = AIIDA_CONFIG_FOLDER / DEFAULT_DAEMON_DIR_NAME | ||
DAEMON_LOG_DIR: pathlib.Path = DAEMON_DIR / DEFAULT_DAEMON_LOG_DIR_NAME | ||
ACCESS_CONTROL_DIR: pathlib.Path = AIIDA_CONFIG_FOLDER / DEFAULT_ACCESS_CONTROL_DIR_NAME | ||
glb_aiida_config_folder: pathlib.Path = pathlib.Path(DEFAULT_AIIDA_PATH).expanduser() / DEFAULT_CONFIG_DIR_NAME |
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.
Maybe I am missing something but why not keep the current name? It would be more consistent with the other global vars above, and would reduce the diff in this PR significantly.
glb_aiida_config_folder: pathlib.Path = pathlib.Path(DEFAULT_AIIDA_PATH).expanduser() / DEFAULT_CONFIG_DIR_NAME | |
AIIDA_CONFIG_FOLDER: pathlib.Path = pathlib.Path(DEFAULT_AIIDA_PATH).expanduser() / DEFAULT_CONFIG_DIR_NAME |
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.
Because it is not a constant but a variable. I simply want to distinguish it from real constants above. It is also from pyright regards it as an type error.
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 don't think I agree with this, it is still a constant semantically, it's just being computed from other constants at import time.
I don't think we should change code just because (some) LSP complains. What exactly is pyright complaining about? It's certainly not a type error, perhaps we're just not adhering to pyrights naming standards?
Also I guess using pyright here is not ideal since we're using mypy
as a type checker, so you'll be constantly fighting the differences in behaviour between them.
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.
But it is still not a constant but a global variable. It escape from the module scope anyway.
The name is changed with underscore in front to be only used for the module.
c9a7c04
to
95e305c
Compare
changes applied to not allow glb var escape from module scope
|
||
return os.path.join(AIIDA_CONFIG_FOLDER, DEFAULT_CONFIG_FILE_NAME) | ||
return os.path.join(str(get_configuration_directory()), DEFAULT_CONFIG_FILE_NAME) |
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.
return os.path.join(str(get_configuration_directory()), DEFAULT_CONFIG_FILE_NAME) | |
return os.path.join(get_configuration_directory(), DEFAULT_CONFIG_FILE_NAME) |
The problem is found when I worked on #6609. If the import of
DAEMON_DIR
moved to outside the function, the global var set in module scope and in test contest will not be reset when function is loading.The goal for a better design is to reduce the use of global variable. Now it is only the
glb_aiida_config_folder
(the originalAIIDA_CONFIG_FOLDER
). Other three are derived from this one. This lower the possibility of directly access the global variable without noticing its change.