0

Is there a way to automatically remove (or give a warning) when a function is not being used in python?

def foo():  # warning unused
    print("foo")

def bar():
    print("bar")

if __name__ == "__main__":
    bar()
  • Delete it or comment it. If its not called anywhere its not being used. Can you maybe provide more details? If a function is outdated you either remove it or update it. – Josip Juros Feb 25 '22 at 06:56
  • I dont think theres any way to automatically remove code, but you might want to check this out - https://stackoverflow.com/questions/693070/how-can-you-find-unused-functions-in-python-code – Sneha Tunga Feb 25 '22 at 06:59
  • Someone told me about [vulture](https://pypi.org/project/vulture/) even though it's not automatically remove unused function, but it help me find them. – hidayat hamir Feb 25 '22 at 07:05

0 Answers0