- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.6k
 
          [pydoclint] Add docstring-missing-parameter and docstring-extraneous-parameter (DOC101, DOC102)
          #13280
        
          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
          
     Open
      
      
            augustelalande
  wants to merge
  30
  commits into
  astral-sh:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
augustelalande:doc10x
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    
  
    [pydoclint] Add docstring-missing-parameter and docstring-extraneous-parameter (DOC101, DOC102)
  
  #13280
                      Changes from 13 commits
      Commits
    
    
            Show all changes
          
          
            30 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      2140312
              
                create violations
              
              
                augustelalande 4d6510c
              
                Merge branch 'main' into doc10x
              
              
                augustelalande 7316554
              
                more work
              
              
                augustelalande 928c0c7
              
                parse parameters from docstring
              
              
                augustelalande 62d447f
              
                finish implementation
              
              
                augustelalande d45967f
              
                clippy and doc
              
              
                augustelalande 04a91fe
              
                group missing params into one violation
              
              
                augustelalande 7c60ddd
              
                simplify fix message
              
              
                augustelalande dcc0065
              
                better extraction of google params
              
              
                augustelalande 352c815
              
                add numpy test without types
              
              
                augustelalande 6c8cc99
              
                simply signature parameter extraction
              
              
                augustelalande 65b9b5b
              
                use dummy_variable_rgx
              
              
                augustelalande 993deb8
              
                better extraction of google params
              
              
                augustelalande 4d47b2d
              
                Nit
              
              
                augustelalande 55aa072
              
                Nit
              
              
                augustelalande 888bcac
              
                Nit
              
              
                augustelalande f0f6ef1
              
                fix
              
              
                augustelalande 03a1182
              
                update violation message
              
              
                augustelalande 76c1e5f
              
                seperate PR
              
              
                augustelalande 2d35922
              
                fix typo
              
              
                augustelalande e0b812e
              
                add comment and test for classmethod
              
              
                augustelalande 2a81315
              
                target section header if available
              
              
                augustelalande 12ec276
              
                format
              
              
                augustelalande 85818bc
              
                Merge branch 'main' into doc10x
              
              
                augustelalande 491fe02
              
                clippy
              
              
                augustelalande 37c4b86
              
                use indentation from first line
              
              
                augustelalande e0b12ca
              
                Merge branch 'main' into doc10x
              
              
                augustelalande 9d12e93
              
                fix test errors
              
              
                augustelalande 9f95db6
              
                Merge branch 'main' into doc10x
              
              
                augustelalande 8639117
              
                update snaps
              
              
                augustelalande File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            372 changes: 372 additions & 0 deletions
          
          372 
        
  crates/ruff_linter/resources/test/fixtures/pydoclint/DOC101_google.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,372 @@ | ||
| # OK | ||
| def add_numbers(a, b): | ||
| """ | ||
| Adds two numbers and returns the result. | ||
| 
     | 
||
| Args: | ||
| a (int): The first number to add. | ||
| b (int): The second number to add. | ||
| 
     | 
||
| Returns: | ||
| int: The sum of the two numbers. | ||
| """ | ||
| return a + b | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def multiply_list_elements(lst, multiplier): | ||
| """ | ||
| Multiplies each element in a list by a given multiplier. | ||
| 
     | 
||
| Args: | ||
| lst (list of int): A list of integers. | ||
| multiplier (int): The multiplier for each element in the list. | ||
| 
     | 
||
| Returns: | ||
| list of int: A new list with each element multiplied. | ||
| """ | ||
| return [x * multiplier for x in lst] | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def find_max_value(numbers): | ||
| """ | ||
| Finds the maximum value in a list of numbers. | ||
| 
     | 
||
| Args: | ||
| numbers (list of int): A list of integers to search through. | ||
| 
     | 
||
| Returns: | ||
| int: The maximum value found in the list. | ||
| """ | ||
| return max(numbers) | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def create_user_profile(name, age, email, location="here"): | ||
| """ | ||
| Creates a user profile with basic information. | ||
| 
     | 
||
| Args: | ||
| name (str): The name of the user. | ||
| age (int): The age of the user. | ||
| email (str): The user's email address. | ||
| location (str): The location of the user. | ||
| 
     | 
||
| Returns: | ||
| dict: A dictionary containing the user's profile. | ||
| """ | ||
| return { | ||
| 'name': name, | ||
| 'age': age, | ||
| 'email': email, | ||
| 'location': location | ||
| } | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def calculate_total_price(item_prices, tax_rate, discount): | ||
| """ | ||
| Calculates the total price after applying tax and a discount. | ||
| 
     | 
||
| Args: | ||
| item_prices (list of float): A list of prices for each item. | ||
| tax_rate (float): The tax rate to apply. | ||
| discount (float): The discount to subtract from the total. | ||
| 
     | 
||
| Returns: | ||
| float: The final total price after tax and discount. | ||
| """ | ||
| total = sum(item_prices) | ||
| total_with_tax = total + (total * tax_rate) | ||
| final_total = total_with_tax - discount | ||
| return final_total | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def send_email(subject, body, to_address, cc_address=None, bcc_address=None): | ||
| """ | ||
| Sends an email to the specified recipients. | ||
| 
     | 
||
| Args: | ||
| subject (str): The subject of the email. | ||
| body (str): The content of the email. | ||
| to_address (str): The recipient's email address. | ||
| cc_address (str, optional): The email address for CC. Defaults to None. | ||
| bcc_address (str, optional): The email address for BCC. Defaults to None. | ||
| 
     | 
||
| Returns: | ||
| bool: True if the email was sent successfully, False otherwise. | ||
| """ | ||
| return True | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def concatenate_strings(separator, *args): | ||
| """ | ||
| Concatenates multiple strings with a specified separator. | ||
| 
     | 
||
| Args: | ||
| separator (str): The separator to use between strings. | ||
| *args (str): Variable length argument list of strings to concatenate. | ||
| 
     | 
||
| Returns: | ||
| str: A single concatenated string. | ||
| """ | ||
| return separator.join(args) | ||
| 
     | 
||
| 
     | 
||
| # OK | ||
| def process_order(order_id, *items, **details): | ||
| """ | ||
| Processes an order with a list of items and optional order details. | ||
| 
     | 
||
| Args: | ||
| order_id (int): The unique identifier for the order. | ||
| *items (str): Variable length argument list of items in the order. | ||
| **details (dict): Additional details such as shipping method and address. | ||
| 
     | 
||
| Returns: | ||
| dict: A dictionary containing the order summary. | ||
| """ | ||
| return { | ||
| 'order_id': order_id, | ||
| 'items': items, | ||
| 'details': details | ||
| } | ||
| 
     | 
||
| 
     | 
||
| class Calculator: | ||
| """ | ||
| A simple calculator class that can perform basic arithmetic operations. | ||
| """ | ||
| 
     | 
||
| # OK | ||
| def __init__(self, value=0): | ||
| """ | ||
| Initializes the calculator with an initial value. | ||
| 
     | 
||
| Args: | ||
| value (int, optional): The initial value of the calculator. Defaults to 0. | ||
| """ | ||
| self.value = value | ||
| 
     | 
||
| # OK | ||
| def add(self, number): | ||
| """ | ||
| Adds a number to the current value. | ||
| 
     | 
||
| Args: | ||
| number (int or float): The number to add to the current value. | ||
| 
     | 
||
| Returns: | ||
| int or float: The updated value after addition. | ||
| """ | ||
| self.value += number + number2 | ||
| return self.value | ||
| 
     | 
||
| # OK | ||
| @classmethod | ||
| def from_string(cls, value_str): | ||
| """ | ||
| Creates a Calculator instance from a string representation of a number. | ||
| 
     | 
||
| Args: | ||
| value_str (str): The string representing the initial value. | ||
| 
     | 
||
| Returns: | ||
| Calculator: A new instance of Calculator initialized with the value from the string. | ||
| """ | ||
| value = float(value_str) | ||
| return cls(value) | ||
| 
     | 
||
| # OK | ||
| @staticmethod | ||
| def is_valid_number(number): | ||
| """ | ||
| Checks if a given number is valid (int or float). | ||
| 
     | 
||
| Args: | ||
| number (any): The value to check. | ||
| 
     | 
||
| Returns: | ||
| bool: True if the number is valid, False otherwise. | ||
| """ | ||
| return isinstance(number, (int, float)) | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def add_numbers(a, b): | ||
| """ | ||
| Adds two numbers and returns the result. | ||
| 
     | 
||
| Args: | ||
| a (int): The first number to add. | ||
| 
     | 
||
| Returns: | ||
| int: The sum of the two numbers. | ||
| """ | ||
| return a + b | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def multiply_list_elements(lst, multiplier): | ||
| """ | ||
| Multiplies each element in a list by a given multiplier. | ||
| 
     | 
||
| Args: | ||
| lst (list of int): A list of integers. | ||
| 
     | 
||
| Returns: | ||
| list of int: A new list with each element multiplied. | ||
| """ | ||
| return [x * multiplier for x in lst] | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def find_max_value(numbers): | ||
| """ | ||
| Finds the maximum value in a list of numbers. | ||
| 
     | 
||
| Returns: | ||
| int: The maximum value found in the list. | ||
| """ | ||
| return max(numbers) | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def create_user_profile(name, age, email, location="here"): | ||
| """ | ||
| Creates a user profile with basic information. | ||
| 
     | 
||
| Args: | ||
| email (str): The user's email address. | ||
| location (str): The location of the user. | ||
| 
     | 
||
| Returns: | ||
| dict: A dictionary containing the user's profile. | ||
| """ | ||
| return { | ||
| 'name': name, | ||
| 'age': age, | ||
| 'email': email, | ||
| 'location': location | ||
| } | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def calculate_total_price(item_prices, tax_rate, discount): | ||
| """ | ||
| Calculates the total price after applying tax and a discount. | ||
| 
     | 
||
| Args: | ||
| item_prices (list of float): A list of prices for each item. | ||
| 
     | 
||
| Returns: | ||
| float: The final total price after tax and discount. | ||
| """ | ||
| total = sum(item_prices) | ||
| total_with_tax = total + (total * tax_rate) | ||
| final_total = total_with_tax - discount | ||
| return final_total | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def send_email(subject, body, to_address, cc_address=None, bcc_address=None): | ||
| """ | ||
| Sends an email to the specified recipients. | ||
| 
     | 
||
| Args: | ||
| subject (str): The subject of the email. | ||
| body (str): The content of the email. | ||
| to_address (str): The recipient's email address. | ||
| 
     | 
||
| Returns: | ||
| bool: True if the email was sent successfully, False otherwise. | ||
| """ | ||
| return True | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def concatenate_strings(separator, *args): | ||
| """ | ||
| Concatenates multiple strings with a specified separator. | ||
| 
     | 
||
| Args: | ||
| separator (str): The separator to use between strings. | ||
| 
     | 
||
| Returns: | ||
| str: A single concatenated string. | ||
| """ | ||
| return separator.join(args) | ||
| 
     | 
||
| 
     | 
||
| # DOC101 | ||
| def process_order(order_id, *items, **details): | ||
| """ | ||
| Processes an order with a list of items and optional order details. | ||
| 
     | 
||
| Args: | ||
| order_id (int): The unique identifier for the order. | ||
| 
     | 
||
| Returns: | ||
| dict: A dictionary containing the order summary. | ||
| """ | ||
| return { | ||
| 'order_id': order_id, | ||
| 'items': items, | ||
| 'details': details | ||
| } | ||
| 
     | 
||
| 
     | 
||
| class Calculator: | ||
| """ | ||
| A simple calculator class that can perform basic arithmetic operations. | ||
| """ | ||
| 
     | 
||
| # DOC101 | ||
| def __init__(self, value=0): | ||
| """ | ||
| Initializes the calculator with an initial value. | ||
| 
     | 
||
| Returns: | ||
| None | ||
| """ | ||
| self.value = value | ||
| 
     | 
||
| # DOC101 | ||
| def add(self, number, number2): | ||
| """ | ||
| Adds a number to the current value. | ||
| 
     | 
||
| Args: | ||
| number (int or float): The number to add to the current value. | ||
| 
     | 
||
| Returns: | ||
| int or float: The updated value after addition. | ||
| """ | ||
| self.value += number + number2 | ||
| return self.value | ||
| 
     | 
||
| # DOC101 | ||
| @classmethod | ||
| def from_string(cls, value_str): | ||
| """ | ||
| Creates a Calculator instance from a string representation of a number. | ||
| 
     | 
||
| Returns: | ||
| Calculator: A new instance of Calculator initialized with the value from the string. | ||
| """ | ||
| value = float(value_str) | ||
| return cls(value) | ||
| 
     | 
||
| # DOC101 | ||
| @staticmethod | ||
| def is_valid_number(number): | ||
| """ | ||
| Checks if a given number is valid (int or float). | ||
| 
     | 
||
| Returns: | ||
| bool: True if the number is valid, False otherwise. | ||
| """ | ||
| return isinstance(number, (int, float)) | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.