import ast


def count_number_of_functions(filepath):
    """Count number of functions inside a .py file."""
    # Taken from: https://stackoverflow.com/a/37514895/1274908
    with open(filepath, "r+") as f:
        tree = ast.parse(f.read())
        return sum(isinstance(exp, ast.FunctionDef) for exp in tree.body)