classFoo:@propertydefget_my_attribute(self,foo):# getter should have only one argumentreturnself.my_attribute@attr.setterdefset_attr(self,v,bar):# setter should have only two argumentsself._attr=v@attr.deleterdefdel_attr(self,foo):# deleter should have only one argumentdelself._attr
Compliant Code Examples
classFoo:defget_my_attribute(self):returnself.my_attributedefget_my_attribute(self,foo):# Not a property or attr, validreturnself.my_attribute@propertydefget_my_attribute(self):returnself.my_attributedefset_my_attribute(self,v):self.my_attribute=v@attr.setterdefset_attr(self,v):self._attr=v@attr.deleterdefdel_attr(self,):returnself._attr
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- python-best-practices # Rules to enforce Python best practices.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines