parameter-type-forbidden (PDF702)¶
PDF701 parameter-type-required
Next rule →PDF703 parameter-type-mismatch
Part of the PDF rule category.
View source · View documentation source · Search issues
Fix is not available.
Rule is disabled if docstring-convention is none or pep257, and ignored by broad selectors under google, numpy, and rest.
Rule is incompatible with PDF701 and PDF703.
What it does¶
Checks that parsed parameter entries in owning function docstrings do not include documented types.
Only entries that match real signature parameters are checked. The rule is exact opt-in and cannot be combined with the required-type or type-mismatch parameter policies.
Why is this useful?¶
Projects that rely on code annotations can prevent duplicated parameter type documentation.
Ruff compatibility¶
None.
Examples¶
PDF702 reports parameter entries that include docstring type text:
docstring-convention = "google"
def function(value: int, timeout: float):
"""Connect to the service.
Args:
value (int): Endpoint identifier.
timeout: Timeout in seconds.
"""
PDF702: Line 5: Function parameter 'value' docstring entry should not include a type
Parameter entries without types are accepted:
docstring-convention = "google"
def function(value: int):
"""Connect to the service.
Args:
value: Input value.
"""
reST :type: fields are also forbidden because they provide docstring type text:
docstring-convention = "rest"
def function(value: int):
"""Connect to the service.
:param value: Endpoint identifier.
:type value: int
"""
PDF702: Line 5: Function parameter 'value' docstring entry should not include a type
Options¶
None.
PDF701 parameter-type-required
Next rule →PDF703 parameter-type-mismatch