DeepSource has joined Harness. Learn more
Python logoPython/
PTC-W0065

Unused nested function or class detectedPTC-W0065

Major severityMajor
Anti-pattern categoryAnti-pattern

This issue concerns that one or more nested classes/functions have been declared but are nowhere used in the function.

A class or function defined inside a function is only accessible inside its parent function scope. It is recommended either to remove the unused classes and functions as it is a dead code or refactor it to use them.

Note: DeepSource will remove all the unused nested definitions during Autofix.

Bad practice

def run():
    def total_time():
        return Something

    class Runner:
        def __init__(time):
            pass

Preferred

def run():
    def total_time():
        return Something

    class Runner:
        def __init__(time):
            ...

    t = total_time()
    bill = Runner(t)
    ...