-
Notifications
You must be signed in to change notification settings - Fork 0
🧹 [code health] Centralize sys.path modifications #147
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||
| scripts_dir = Path(__file__).parent | ||||||||||||||||||||||||
| if str(scripts_dir) not in sys.path: | ||||||||||||||||||||||||
| sys.path.insert(0, str(scripts_dir)) | ||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
|
||||||||||||||||||||||||
| import sys | |
| from pathlib import Path | |
| scripts_dir = Path(__file__).parent | |
| if str(scripts_dir) not in sys.path: | |
| sys.path.insert(0, str(scripts_dir)) | |
| """Package initializer for the Scripts module. | |
| This file is intentionally kept free of side effects such as mutating | |
| sys.path. Importers should rely on standard Python packaging and | |
| relative imports instead of path manipulation. | |
| """ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,9 +2,6 @@ | |||||
| import sys | ||||||
| from pathlib import Path | ||||||
|
Comment on lines
2
to
3
|
||||||
| import sys | |
| from pathlib import 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.
For greater robustness, it's a good practice to resolve the path to an absolute path before adding it to
sys.path. This ensures that you're always working with a canonical path, which prevents potential issues related to the current working directory, relative paths, or symlinks.