[py] Replace //py:ruff with dedicated ruff-format and ruff-check targets#16998
[py] Replace //py:ruff with dedicated ruff-format and ruff-check targets#16998titusfortner merged 6 commits intotrunkfrom
Conversation
|
Thank you, @titusfortner for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Latest suggestions up to 95e420e
Previous suggestionsSuggestions up to commit e303ab5
|
|||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR splits the previous monolithic Bazel //py:ruff target into dedicated //py:ruff-format and //py:ruff-check targets, updates developer tooling to use them, and adjusts Ruff scope to include py/ alongside other Python-containing directories.
Changes:
- Add dedicated Ruff runner scripts/targets for
ruff formatandruff check. - Update Rake tasks and formatting scripts to call the new targets.
- Apply Ruff-driven formatting cleanup across many Python test files (mostly import-spacing).
Reviewed changes
Copilot reviewed 98 out of 98 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/ci-python.yml |
Switch CI lint command to //py:ruff-check. |
rake_tasks/python.rake |
Add py:format task; update py:lint flow to format → check → mypy. |
scripts/format.ps1 |
Use //py:ruff-format for Python formatting in the repo formatter script. |
scripts/format.sh |
Use //py:ruff-format for Python formatting in the repo formatter script. |
py/BUILD.bazel |
Replace //py:ruff alias with ruff-check and ruff-format aliases. |
py/private/BUILD.bazel |
Split py_binary into ruff_check and ruff_format. |
py/private/ruff_check.py |
New simplified Ruff “check” runner; now includes py/ plus external dirs. |
py/private/ruff_format.py |
New Ruff “format” runner for py/ plus external dirs. |
py/test/selenium/webdriver/common/alerts_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/api_example_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_browser_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_browsing_context_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_emulation_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_input_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_network_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_permissions_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_script_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_session_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_storage_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/bidi_webextension_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/children_finding_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/clear_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/click_scrolling_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/click_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/correct_event_firing_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/devtools_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/driver_element_finding_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/element_aria_label_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/element_aria_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/element_attribute_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/executing_async_javascript_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/executing_javascript_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/fedcm_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/form_handling_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/frame_switching_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/google_one_box.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/implicit_waits_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/interactions_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/interactions_with_device_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/opacity_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/page_load_timeout_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/position_and_size_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/print_pdf_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/proxy_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/rendered_webelement_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/script_pinning_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/select_class_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/stale_reference_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/takes_screenshots_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/text_handling_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/timeout_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/typing_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/upload_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/virtual_authenticator_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/visibility_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/w3c_interaction_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/web_components_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/webdriverwait_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/window_switching_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/common/window_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/edge/edge_service_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/firefox/ff_installs_addons_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/firefox/firefox_context_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/firefox/firefox_service_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/firefox/firefox_sizing_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/remote/remote_connection_tests.py |
Ruff formatting (import ordering/whitespace). |
py/test/selenium/webdriver/remote/remote_downloads_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/remote/remote_hub_connection.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/remote/remote_server_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/remote/remote_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/safari/conftest.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/safari/launcher_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/safari/safari_service_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/support/event_firing_webdriver_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/support/expected_conditions_tests.py |
Ruff formatting (import whitespace). |
py/test/selenium/webdriver/support/relative_by_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/chrome/chrome_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/common/common_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/common/driver_finder_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/common/fedcm/dialog_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/common/print_page_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/common/selenium_manager_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/edge/edge_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/firefox/firefox_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/ie/test_ie_options.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/remote/error_handler_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/remote/new_session_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/remote/remote_connection_tests.py |
Ruff formatting (import ordering/whitespace). |
py/test/unit/selenium/webdriver/remote/remote_server_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/safari/safari_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/virtual_authenticator/credentials_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/virtual_authenticator/virtual_authenticator_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/webkitgtk/webkitgtk_options_tests.py |
Ruff formatting (import whitespace). |
py/test/unit/selenium/webdriver/wpewebkit/wpewebkit_options_tests.py |
Ruff formatting (import whitespace). |
cgoldberg
left a comment
There was a problem hiding this comment.
Why did this remove the extra line separating the import groups from every file? If I run ruff check against this branch, it will show me 90 errors... and if I run ruff check --fix, it will add them back.
User description
The generic ruff target had unnecessary complicated logic for format vs check. This way we can pass the desired arguments directly where we want them
💥 What does this PR do?
Replaces
//py:ruffwith dedicated targets:bazel run //py:ruff-format -- [args]- format, passes args toruff formatbazel run //py:ruff-check -- [args]- lint, passes args toruff checkAlso fixed bug where we were only checking external directories, not adding them to checking
pydirectory (#16957)Rake task changes:
py:formattask using//py:ruff-formatpy:lintto run format, then check with--fix --show-fixes, then mypy (and will modify files)Script changes:
scripts/format.shandscripts/format.ps1now use//py:ruff-format🔧 Implementation Notes
Two dedicated scripts that pass args directly to ruff, allowing full control (e.g.,
--checkfor CI verification,--fixfor auto-fixing).Current CI:
ci-lintworkflow that runsscripts/format.shci-pythonworkflow lint job that runsruff-check).💡 Additional Considerations
This is part of a larger effort to add consistent
:formatand:linttasks across all language bindings.🔄 Types of changes
PR Type
Enhancement, Bug fix
Description
Split monolithic ruff target into dedicated format and check targets
Fixed bug where py directory was excluded from linting checks
Updated rake tasks and scripts to use new ruff-format and ruff-check targets
Applied ruff formatting fixes across 60+ test files (import statement cleanup)
Diagram Walkthrough
File Walkthrough
3 files
Simplified ruff check runner with py directory inclusionNew dedicated ruff format runner scriptUpdated py:lint and added py:format rake tasks4 files
Replaced ruff alias with ruff-check and ruff-formatSplit ruff binary into ruff_check and ruff_formatUpdated to use ruff-format targetUpdated to use ruff-format target70 files
Removed blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after import statementRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after import statementRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importReorganized imports for consistencyRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after import statementRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importReorganized imports for consistencyRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after import statementRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest importRemoved blank line after pytest import20 files