Why this matters
Python’s __init__ method should always return None. Returning anything else will raise a TypeError and break object instantiation.
__init__ Does Not Return a ValueVerify that __init__ methods always return None. Returning any other value causes a TypeError and prevents correct object instantiation.
Python’s __init__ method should always return None. Returning anything else will raise a TypeError and break object instantiation.
Side-by-side examples engineers can pattern-match during review.
class MyClass(object):
def __init__(self):
self.message = 'Hello'
return self # Noncompliant: a TypeError will be raisedclass MyClass(object):
def __init__(self):
self.message = 'Hello'From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.