Skip to content

Conversation

@cgoldberg
Copy link
Member

@cgoldberg cgoldberg commented Nov 26, 2025

User description

💥 What does this PR do?

This PR updates generate.py to use an f-string instead of the older format() syntax for string formatting.

With this change, all Python files under ./py/ are upgraded to Python 3.10+ syntax using pyupgrade: https://github.com/asottile/pyupgrade

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Enhancement


Description

  • Convert string formatting from .format() to f-string syntax

  • Modernize Python code to use Python 3.10+ conventions

  • Improve code readability and consistency across codebase


Diagram Walkthrough

flowchart LR
  A["Old format() syntax"] -- "pyupgrade conversion" --> B["Modern f-string syntax"]
  B -- "improves" --> C["Code readability & consistency"]
Loading

File Walkthrough

Relevant files
Enhancement
generate.py
Convert format() to f-string in type annotation                   

py/generate.py

  • Replaced .format() method call with f-string in py_annotation property
  • Updated line 232 to use f-string for typing.List type annotation
    formatting
  • Maintains identical functionality while improving code style
+1/-1     

@cgoldberg cgoldberg self-assigned this Nov 26, 2025
@cgoldberg cgoldberg added the C-py Python Bindings label Nov 26, 2025
@qodo-merge-pro
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit change: The new code only replaces format() with an f-string and does not introduce or modify any
logging of critical actions, so audit trail compliance cannot be assessed from this diff.

Referred Code
        ann = f"typing.List[{CdpPrimitiveType.get_annotation(self.items.type)}]"
else:

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
No error logic: The change is a stylistic f-string update and does not affect or add error handling,
making robustness unassessable from this diff alone.

Referred Code
        ann = f"typing.List[{CdpPrimitiveType.get_annotation(self.items.type)}]"
else:

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
No input validation: This diff only updates string formatting and does not introduce or modify input validation
or data handling, so security posture cannot be determined from the change.

Referred Code
        ann = f"typing.List[{CdpPrimitiveType.get_annotation(self.items.type)}]"
else:

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-merge-pro
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Learned
best practice
Use f-string for docstring formatting

Update the function to use an f-string consistently, as done elsewhere in this
PR, to improve readability and consistency without changing behavior.

py/generate.py [133-139]

 def docstring(description):
 ... (clipped 5 lines)
-    return dedent("'''\n{}\n'''").format(description)
+    return dedent(f"'''\n{description}\n'''")

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Enforce accurate and consistent documentation to match behavior and types.

Low
  • More

@cgoldberg cgoldberg merged commit d764938 into SeleniumHQ:trunk Nov 26, 2025
7 checks passed
@cgoldberg cgoldberg deleted the py-generate-use-f-string branch November 26, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant