-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Add new ruff lint rules, fix violations and type annotations #16789
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
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:
|
||||||||||||||||||
navin772
left a comment
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.
LGTM!
User description
💥 What does this PR do?
This is a general cleanup for the Python bindings:
Adds new rules and expands existing rules for the Python linter (ruff) and fixes all violations:
A few specific rules are ignored in
pyproject.tomlbecause they seemed overly pedantic.Adds some missing type annotations
Updates several type annotations to use newer 3.10+ syntax instead of Unions
Removes the
./selenium/types.pytype definition file and moves explicit type annotations into their respective modules. This file only contained a few types that weren't shared across many files and it's not really necessary to maintain a central file for this.Makes test assertions more clear
Converts old string formatting to f-strings
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Remove centralized
selenium/types.pyand inline type definitionsUpdate Python 3.10+ syntax: replace
Unionwith|operatorAdd ruff lint rules (pydocstyle, pytest-style, pyupgrade, ruff-specific)
Fix pytest fixture scopes and improve test assertions
Modernize string formatting and simplify conditional logic
Diagram Walkthrough
File Walkthrough
17 files
Remove centralized type definitions fileInline SubprocessStdAlias type definitionInline SubprocessStdAlias type definitionRemove Union import, inline AnyDevice typeUpdate string formatting to f-stringSimplify dictionary checks with .get() methodInline SubprocessStdAlias, modernize Union syntaxInline AnyKey type definitionInline SubprocessStdAlias type definitionInline SubprocessStdAlias type definitionInline SubprocessStdAlias type definitionInline AnyKey type definitionModernize Union syntax and string formattingModernize Union syntax to pipe operatorInline WaitExcTypes, modernize Union syntaxRemove unused Union import, modernize f-stringsRemove Python 2 compatibility imports, modernize error handling1 files
Remove noqa comments from imports20 files
Remove fixture scope, fix pytest assertionsFix pytest parametrize tuple syntaxUpdate string formatting to f-stringSplit compound assertions into separate statementsUpdate string formatting to f-stringModernize string formattingConvert tuple to list in parametrizeSplit compound assertions into separate statementsAdd noqa comment for pyupgrade ruleFix variable naming and simplify assertionsSplit compound assertions into separate statementsSplit compound assertions into separate statementsRemove empty parentheses from fixture decoratorRemove empty parentheses from fixture decoratorUpdate string formatting to f-stringSplit compound assertion into separate statementsChange fixture from yield to returnChange fixture from yield to returnRemove fixture scope, change yield to returnFix variable naming and simplify assertions1 files
Expand ruff lint rules and add ignore exceptions