[build] run ruff on python files outside py directory#16957
[build] run ruff on python files outside py directory#16957titusfortner merged 4 commits intotrunkfrom
Conversation
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 ✨Explore these optional code suggestions:
|
||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR adds a root-level ruff.toml configuration file to enable consistent Python linting across the entire repository, not just the py/ directory. It extends the existing py/pyproject.toml configuration and applies automated formatting fixes to scripts and build tools throughout the codebase. The changes include modernizing string formatting to f-strings, removing deprecated Python 2 compatibility imports, updating type hints to modern Python 3.10+ syntax, and simplifying file operations.
Changes:
- Added root-level
ruff.tomlthat extendspy/pyproject.tomlto lint Python files in scripts, common, dotnet, java, javascript, and rb directories - Modernized string formatting from
%operator and.format()to f-strings throughout scripts - Removed deprecated
from __future__ import print_functionimport (only needed for Python 2) - Updated type hints from
List[T]andTuple[T]to modernlist[T]andtuple[T]syntax - Removed redundant
"r"mode parameter fromopen()calls (default mode) - Refactored list comprehensions with indexing to use
next()for finding first matching elements
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| ruff.toml | Added root-level ruff configuration extending py/pyproject.toml to include scripts and build tools across the repository |
| scripts/update_multitool_binaries.py | Fixed docstring formatting to comply with style guidelines |
| scripts/update_copyright.py | Removed redundant file mode parameters and simplified multi-line expressions |
| scripts/update_cdp.py | Improved docstring formatting, removed redundant parameters, simplified expressions, and converted to f-strings and next() |
| scripts/selenium_manager.py | Converted string formatting from % operator to .format() method |
| scripts/pinned_browsers.py | Converted to f-strings, replaced list comprehensions with next(), simplified expressions |
| javascript/private/gen_file.py | Converted to f-strings throughout, removed redundant file mode parameters |
| dotnet/private/generate_resources_tool.py | Updated type hints to modern syntax (list/tuple instead of List/Tuple), removed redundant file mode parameter |
| common/devtools/pdl.py | Removed deprecated future import, reordered imports, simplified expressions, converted to f-strings |
| common/devtools/convert_protocol_to_json.py | Simplified argument parser description and removed redundant file mode parameter |
35d58da to
6a5d86a
Compare
|
that's just funny. Sure. |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6ba74fb to
5a91c87
Compare
* [build] run ruff on python files outside py directory * [py] Add //py:ruff Bazel target * add it to all:lint
User description
💥 What does this PR do?
Adds a root-level
ruff.tomlto lint Python files outside thepy/directory (scripts, build tools, codegen).Applies the resulting linting fixes to those files.
🔧 Implementation Notes
The config extends
py/pyproject.tomlto maintain consistent Python style across the entire repo.Including common directories and excluding known vendor directories
💡 Additional Considerations
This works with our existing format.sh execution
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Add root-level
ruff.tomlto lint Python files outsidepy/directoryApply ruff formatting fixes across scripts and build tools
Modernize string formatting to f-strings throughout codebase
Remove deprecated imports and update type hints to modern syntax
Simplify file operations by removing redundant mode parameters
Diagram Walkthrough
File Walkthrough
1 files
Add root-level ruff configuration for Python linting9 files
Simplify file operations and formattingModernize imports, type hints, and string formattingUpdate type hints to modern syntax and simplify file operationsConvert string formatting to f-stringsConvert string formatting to f-strings and simplify list operationsConvert string formatting to .format() methodImprove docstrings and convert string formattingSimplify file operations and list comprehensionsImprove docstring formatting