-
Notifications
You must be signed in to change notification settings - Fork 3
fix pip check for optional dependencies #579
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,16 @@ | ||||||||||||||||||
| import tomlkit | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||
| with open("pyproject.toml", "r") as f: | ||||||||||||||||||
| data = tomlkit.load(f) | ||||||||||||||||||
|
|
||||||||||||||||||
| lst = [] | ||||||||||||||||||
| for sub_lst in data["project"]["optional-dependencies"].values(): | ||||||||||||||||||
| for el in sub_lst: | ||||||||||||||||||
| lst.append(el) | ||||||||||||||||||
|
|
||||||||||||||||||
| data["project"]["dependencies"] += list(set(lst)) | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainValidate dependency format before adding. The script should validate the dependency format before adding it to the main dependencies list. Run this script to check the dependency format in the codebase: 🏁 Script executed: #!/bin/bash
# Description: Check dependency format in pyproject.toml
# Expected format: package[extras]>=version or package[extras]==version
rg -A 5 'dependencies\s*=\s*\[' pyproject.tomlLength of output: 137 Action Required: Enforce Dependency Format Validation Currently, in data["project"]["dependencies"] += list(set(lst))without any validation. Although the dependency format in
|
||||||||||||||||||
|
|
||||||||||||||||||
| with open("pyproject.toml", "w") as f: | ||||||||||||||||||
| f.writelines(tomlkit.dumps(data)) | ||||||||||||||||||
|
Comment on lines
+15
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for file write operations. The script should handle potential file write errors gracefully. Apply this diff to add error handling: - with open("pyproject.toml", "w") as f:
- f.writelines(tomlkit.dumps(data))
+ try:
+ with open("pyproject.toml", "w") as f:
+ f.writelines(tomlkit.dumps(data))
+ except IOError as e:
+ print(f"Error writing to pyproject.toml: {e}")
+ sys.exit(1)📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -95,7 +95,9 @@ jobs: | |||||||||||||||||||||||||
| - name: Setup | ||||||||||||||||||||||||||
| shell: bash -l {0} | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| pip install versioneer[toml]==0.29 | ||||||||||||||||||||||||||
| pip install versioneer[toml]==0.29 tomlkit | ||||||||||||||||||||||||||
| python .ci_support/check.py | ||||||||||||||||||||||||||
| cat pyproject.toml | ||||||||||||||||||||||||||
|
Comment on lines
+98
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Pin tomlkit version and add error handling. The script execution should be resilient to failures, and dependencies should have fixed versions for reproducibility. Apply this diff to improve the code: - pip install versioneer[toml]==0.29 tomlkit
- python .ci_support/check.py
- cat pyproject.toml
+ pip install versioneer[toml]==0.29 tomlkit==0.12.3
+ if ! python .ci_support/check.py; then
+ echo "Error: Failed to process dependencies"
+ exit 1
+ fi
+ if ! cat pyproject.toml; then
+ echo "Error: Failed to display pyproject.toml"
+ exit 1
+ fi📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
| pip install . --no-deps --no-build-isolation | ||||||||||||||||||||||||||
| pip check | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Add error handling for file operations.
The script should handle potential file operation errors and missing TOML keys gracefully.
Apply this diff to add error handling:
Don't forget to add the required import:
🧰 Tools
🪛 Ruff (0.8.2)
5-5: Unnecessary open mode parameters
Remove open mode parameters
(UP015)