- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
[py] fix D105 warn for ruff format rule #16529
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
[py] fix D105 warn for ruff format rule #16529
Conversation
…es, and PointerSourceActions
…ring representation
…larity on equality comparison
…t class for clarity
…ver class for clarity on functionality
…ebElement class for clarity on functionality
…ebDriver and EventFiringWebElement classes for clarity on functionality
…ringWebElement classes for improved readability
| 
           Thank you, @iampopovich 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  | 
    ||||||||||||||||||||||||
| 
           @cgoldberg check please  | 
    
          PR Code Suggestions ✨Explore these optional code suggestions: 
  | 
    ||||||||||||
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.
The changes look fine, but I'd prefer we leave this rule ignored and not add all these docstrings. I think it's kind of ridiculous to have docstrings on every dunder method that's overridden from standard library classes. Everyone familiar with Python knows exactly what they do and this just adds noise to the code.
Forcing you to include a docstring on every __str__ method stating that it returns a string representation of the object doesn't add any value... That's what every __str__ method does on every single object.
| 
           Hmm 
 What's your opinion?  | 
    
| 
           I think we should ignore all missing docstrings... but if they are added, they should follow our formatting rules.  | 
    
| 
           well, let's close this PR and ignore codes  | 
    
User description
🔗 Related Issues
relates #11442
💥 What does this PR do?
This pull request adds comprehensive docstrings to many magic methods and context manager methods throughout the codebase, improving code readability and maintainability. Additionally, it updates the
pyproject.tomlconfiguration to require docstrings for magic methods by removing theD105ignore directive. The most important changes are grouped below.Docstring Enhancements for Magic Methods and Context Managers:
__eq__,__ne__,__hash__,__repr__, and other magic methods in key classes such asWebElement,Color,ScriptKey,ShadowRoot,WebDriver, andWebDriverWait, describing their behavior, arguments, and return values. [1] [2] [3] [4] [5] [6]__enter__and__exit__) in classes likeWebDriver,ActionChains, and others, clarifying their purpose and usage withinwithstatements. [1] [2]Configuration Update:
"D105"from theextend-ignorelist inpyproject.toml, enforcing the requirement for docstrings in magic methods as per the docstring linter configuration.Improved Exception and Utility Method Documentation:
__str__in various exception classes and protocol/container classes, to clarify their output and usage. [1] [2] [3] [4]Dataclass and Attribute Accessor Documentation:
__post_init__methods and attribute accessors, explaining validation logic and side effects. [1] [2] [3]Event Firing Wrapper Improvements:
EventFiringWebDriverandEventFiringWebElement, specifying delegation logic and exception handling. [1] [2] [3] [4]These changes collectively improve the codebase's documentation quality, making it easier for developers to understand the behavior of core classes and methods.
💡 Additional Considerations
🔄 Types of changes
PR Type
Documentation
Description
Add comprehensive docstrings to magic methods across codebase
Document context manager methods (enter, exit)
Add validation docstrings to dataclass post_init methods
Remove D105 rule from ruff configuration to enforce magic method documentation
Diagram Walkthrough
File Walkthrough
13 files
Add type hint and docstring to ContainerProtocol.__contains__Add docstrings to exception __str__ methodsAdd docstrings to context manager methodsAdd validation docstrings to dataclass __post_init__ methodsAdd docstring to Service.__del__ cleanup methodAdd docstring to Credential.__str__ methodAdd docstrings to ScriptKey comparison and repr methodsAdd docstrings to ShadowRoot magic methodsAdd docstrings to WebDriver repr and context manager methodsAdd docstrings to WebElement comparison and hash methodsAdd docstrings to Color comparison and representation methodsAdd docstrings to attribute access magic methodsAdd docstring to WebDriverWait.__repr__ method1 files
Remove D105 rule from ruff extend-ignore list