I am trying autoflake
to remove unused global variable from source code. It is able to remove unused import but not the global variables:
example:
import autoflake
code = """
import os
import math
x = 1
#unused list
agg_level = [
"a",
(
"abc",
"def",
"xyz",
"pqr",
),
]
print(x)
"""
print(
autoflake.fix_code(
code,
remove_all_unused_imports=True,
remove_duplicate_keys=True,
remove_unused_variables=True
)
)
output
x = 1
unused list
agg_level = [
"a",
(
"abc",
"def",
"xyz",
"pqr",
),
]
print(x)