"Class-Private" methods that are never executed inside their enclosing class are dead code: unnecessary, inoperative code that should be removed. Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.

Python has no real private methods. Every method is accessible. There are however two conventions indicating that a method is not meant to be "public":

This rule raises an issue when a class-private method (two leading underscores, max one underscore at the end) is never called inside the class. Class methods, static methods and instance methods will all raise an issue.

Noncompliant Code Example

class Noncompliant:

    @classmethod
    def __mangled_class_method(cls):  # Noncompliant
        print("__mangled_class_method")

    @staticmethod
    def __mangled_static_method():  # Noncompliant
        print("__mangled_static_method")

    def __mangled_instance_method(self):  # Noncompliant
        print("__mangled_instance_method")

Compliant Solution

class Compliant:

    def __init__(self):
        Compliant.__mangled_class_method()
        Compliant.__mangled_static_method()
        self.__mangled_instance_method()

    @classmethod
    def __mangled_class_method(cls):
        print("__mangled_class_method")

    @staticmethod
    def __mangled_static_method():
        print("__mangled_static_method")

    def __mangled_instance_method(self):
        print("__mangled_instance_method")

See