Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[py] Fix type annotations, make docstrings consistent, centralize dependencies#16821

Merged
cgoldberg merged 5 commits intoSeleniumHQ:trunkfrom
cgoldberg:py-fix-types
Dec 31, 2025
Merged

[py] Fix type annotations, make docstrings consistent, centralize dependencies#16821
cgoldberg merged 5 commits intoSeleniumHQ:trunkfrom
cgoldberg:py-fix-types

Conversation

@cgoldberg
Copy link
Member

@cgoldberg cgoldberg commented Dec 31, 2025

User description

πŸ”— Related Issues

#15697

πŸ’₯ What does this PR do?

This is another cleanup PR:

  • removes deprecated log_path attribute in webkitgtk.Service class
  • moves linting/typechecking/validation dependencies to pyproject.toml to keep them in a central location
  • renames the mypy tox environment to typecheck (more generic name because we might replace mypy)
  • fixes many type annotation issues (we are down to 22 mypy errors)
  • makes docstrings more consistent
  • re-adds tox to dev dependencies that I accidentally removed previously

πŸ”„ Types of changes

  • Cleanup (formatting, renaming)
  • Bug fix (backwards compatible)
  • Breaking change (removed deprecated attribute)

PR Type

Enhancement, Bug fix


Description

  • Fix type annotations across service classes and remove unused imports

  • Centralize linting/typecheck/validation dependencies in pyproject.toml

  • Rename mypy tox environment to typecheck for better generality

  • Remove deprecated log_path attribute from webkitgtk.Service

  • Standardize docstrings across all service classes for consistency

  • Replace ByType with str type hints in element finding methods


Diagram Walkthrough

flowchart LR
  A["Type Annotations<br/>Fixes"] --> B["Service Classes<br/>Consistency"]
  C["Dependencies<br/>Centralization"] --> D["pyproject.toml<br/>Config"]
  E["Deprecated<br/>Attribute Removal"] --> B
  F["Docstring<br/>Standardization"] --> B
  G["ByType to str<br/>Conversion"] --> A
  D --> H["tox.ini<br/>Updates"]
Loading

File Walkthrough

Relevant files
Type annotation fix
8 files
service.py
Convert service_args to list typeΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+1/-1Β  Β  Β 
service.py
Remove IOBase import and fix type annotationsΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+7/-15Β  Β 
browsing_context.py
Replace UNDEFINED type with SentinelΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+2/-2Β  Β  Β 
service.py
Remove cast calls and fix log_output type hintsΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+8/-8Β  Β  Β 
shadowroot.py
Remove ByType import and use str typeΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+2/-3Β  Β  Β 
webdriver.py
Remove ByType import and use str typeΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+3/-3Β  Β  Β 
webelement.py
Remove ByType import and use str typeΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+3/-3Β  Β  Β 
service.py
Update type hints and standardize docstringΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+11/-14Β 
Documentation
3 files
service.py
Standardize docstring format and parametersΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+3/-3Β  Β  Β 
service.py
Move docstring from method to class levelΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+13/-15Β 
service.py
Standardize docstring format and parametersΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+3/-3Β  Β  Β 
Bug fix
1 files
service.py
Remove deprecated log_path and fix typesΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+12/-21Β 
Configuration changes
2 files
ci-python.yml
Rename mypy environment to typecheckΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+1/-1Β  Β  Β 
tox.ini
Use dependency_groups and rename mypy environmentΒ  Β  Β  Β  Β  Β  Β  Β 
+7/-13Β  Β 
Dependencies
3 files
pyproject.toml
Add dependency groups for lint/typecheck/validateΒ  Β  Β  Β  Β  Β  Β  Β 
+16/-5Β  Β 
requirements.txt
Add tox and related dependenciesΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+8/-0Β  Β  Β 
requirements_lock.txt
Update locked versions for new dependenciesΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β 
+58/-1Β  Β 

@cgoldberg cgoldberg self-assigned this Dec 31, 2025
@selenium-ci selenium-ci added C-py Python Bindings B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related labels Dec 31, 2025
@cgoldberg cgoldberg changed the title [py] Fix type annotations, make service classes more consistent, centralize dependencies [py] Fix type annotations, make docstrings consistent, centralize dependencies Dec 31, 2025
@cgoldberg cgoldberg marked this pull request as ready for review December 31, 2025 16:11
@SeleniumHQ SeleniumHQ deleted a comment from qodo-code-review bot Dec 31, 2025
@SeleniumHQ SeleniumHQ deleted a comment from qodo-code-review bot Dec 31, 2025
@cgoldberg cgoldberg merged commit 13af249 into SeleniumHQ:trunk Dec 31, 2025
24 checks passed
@cgoldberg cgoldberg deleted the py-fix-types branch December 31, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related C-py Python Bindings Review effort 3/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants