class-attribute-type-forbidden (PDF714)¶
PDF713 class-attribute-type-required
Next rule →PDF715 class-attribute-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 PDF713 and PDF715.
What it does¶
Checks that parsed class attribute entries in owning class docstrings do not include documented types.
Only entries that match inventoried class or instance attributes are checked. The rule is exact opt-in and cannot be combined with the required-type or type-mismatch class attribute policies.
Why is this useful?¶
Projects that rely on code annotations can prevent duplicated class attribute type documentation.
Ruff compatibility¶
None.
Examples¶
PDF714 reports class attribute entries that include docstring type text:
docstring-convention = "google"
class Client:
"""Client.
Attributes:
timeout (int): Timeout in seconds.
retries: Retry count.
"""
timeout: int = 1
retries: int = 3
PDF714: Line 5: Class attribute 'timeout' docstring entry should not include a type
Class attribute entries without types are accepted:
docstring-convention = "google"
class Client:
"""Client.
Attributes:
timeout: Timeout in seconds.
"""
timeout: int = 1
NumPy entries that document multiple names are checked once per matching attribute:
docstring-convention = "numpy"
class Client:
"""Client.
Attributes
----------
primary, fallback : str
Request endpoints.
"""
primary: str
fallback: str
PDF714: Line 6: Class attribute 'primary' docstring entry should not include a type
PDF714: Line 6: Class attribute 'fallback' docstring entry should not include a type
Options¶
None.
PDF713 class-attribute-type-required
Next rule →PDF715 class-attribute-type-mismatch