tox formatting for python files in `format.sh`
User description
Thanks for contributing to Selenium! A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines. Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
It would be contributor friendly if we can have python formatting in ./scripts/format.sh.
Currently due to lack of formatting support from rules_python, bazel targets were not configurable (Added it as a TODO)
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
- [x] I have read the contributing document.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.
PR Type
enhancement, configuration changes
Description
- Introduced Python formatting in the
format.shscript usingtox. - Configured
toxto applyisort,black,flake8, anddocformatterfor Python files. - Added a TODO note for using Bazel targets when
rules_pythonsupports formatting.
Changes walkthrough 📝
| Relevant files | |||
|---|---|---|---|
| Enhancement |
|
💡 PR-Agent usage: Comment
/helpon the PR to get a list of all available PR-Agent tools and their descriptions
PR Reviewer Guide 🔍
(Review updated until commit https://github.com/SeleniumHQ/selenium/commit/7d084534055bb8a46243abdee5bf75ee6fb464b5)
Here are some key observations to aid the review process:
| ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
| 🧪 No relevant tests |
| 🔒 No security concerns identified |
| ⚡ Recommended focus areas for review Dependency Management Environment Variable |
PR Code Suggestions ✨
Latest suggestions up to 7d08453 Explore these optional code suggestions:
| Category | Suggestion | Score |
| Best practice |
Implement a more robust method for installing and running tox in an isolated environmentConsider using a virtual environment or checking if tox is already installed before
Suggestion importance[1-10]: 9Why: This suggestion significantly improves the robustness of the script by ensuring that tox is installed in a virtual environment, preventing potential conflicts with system-wide packages. It also checks if tox is already installed, which is a best practice for managing dependencies. | 9 |
| Enhancement |
Add error handling for the tox command to improve script robustnessAdd error handling to check if the tox command was successful. This can help
Suggestion importance[1-10]: 8Why: Adding error handling for the tox command enhances the script's robustness by providing feedback if the command fails. This is a valuable improvement for debugging and maintaining the script. | 8 |
💡 Need additional feedback ? start a PR chat
Previous suggestions
Suggestions up to commit d1215ea
| Category | Suggestion | Score |
| Error handling |
Add error handling for the formatting commandAdd error handling to check if the tox command was successful. This will help catch
Suggestion importance[1-10]: 9Why: Adding error handling for the | 9 |
| Best practice |
Use a virtual environment for managing Python dependenciesConsider using a virtual environment or a requirements file to manage dependencies
Suggestion importance[1-10]: 8Why: Using a virtual environment or a requirements file is a best practice for managing dependencies, ensuring reproducibility, and avoiding conflicts with system-wide packages. This suggestion significantly improves the maintainability and reliability of the script. | 8 |
| Optimization |
Check if the required tool is already installed before installationConsider adding a check to verify if tox is already installed before attempting to
Suggestion importance[1-10]: 7Why: Checking if | 7 |
This seems to not work on the CI. Can you look into it?
I will take a look, from the CI logs it seems like selenium py package failed to build.
For now, I will convert this to draft.
Persistent review updated to latest commit https://github.com/SeleniumHQ/selenium/commit/7d084534055bb8a46243abdee5bf75ee6fb464b5
@AutomatedTester I have updated the PR, can you please trigger the CI?
The RBE test failures are unrelated to the changes.