Package: alphabetize
AlphabetizeAlphabetize finds grouped lines of variables  within your files and orders them alphabetically. This is useful for cleaning up codebases.The organisation priority is:independent variablesdependent variablesThe variable 'a' is ordered last as it depends on the other variables.b = 10
c = 20
d = 40
a = b + c + dUPPERCASE and lowercase variables are separated when ordered.A = 10
B = 20
C = 30
a = 10
b = 20
c = 30Installationpip install alphabetizeUsagealphabetize myfile.py
alphabetize path/to/myfile.pyThe provided argument can either be the relative path or absolute path to a Python file.ExamplesExample 1 - single useConsider the following Python script (unordered_code.py)import datetime
from time import time

# First Variable Block
c_variable = 60
A_variable = 10
a_variable = 40
B_variable = 20
b_variable = 50
C_variable = 30


class TestClass:
    def __init__(self):
        self.c_variable = 30
        self.a_variable = 10
        self.b_variable = 20


def test_function():
    c_variable = time()
    a_variable = 10
    b_variable = datetime
    a_list = [a_variable, b_variable, c_variable]
    bb_variable = 20
    aa_variable = 10
    cc_variable = aa_variable + bb_variable

    return a_list, cc_variableCalling:alphabetize unordered_code.pyResults in the following output:import datetime
from time import time

# First Variable Block
A_variable = 10
B_variable = 20
C_variable = 30
a_variable = 40
b_variable = 50
c_variable = 60


class TestClass:
    def __init__(self):
        self.a_variable = 10
        self.b_variable = 20
        self.c_variable = 30


def test_function():
    a_variable = 10
    b_variable = datetime
    c_variable = time()
    a_list = [a_variable, b_variable, c_variable]
    aa_variable = 10
    bb_variable = 20
    cc_variable = aa_variable + bb_variable

    return a_list, cc_variableExample 2 - multiple usesDepending on the variable names found within grouped lines,alphabetizecan be called multiple times to further reorder the grouped lines of variables.This particularly comes into play when independent and dependent variables are mixed within the same grouped lines block.Consider the following Python script (unordered_code_multi.py)def test_function():
    c_variable = 30
    a_variable = 10
    b_variable = 20
    list = [a_variable, b_variable, c_variable]
    bb_variable = 20
    aa_variable = 10
    cc_variable = aa_variable + bb_variable

    return list, cc_variableCallingalphabetize unordered_code_multi.pyfor the first time produces:def test_function():
    a_variable = 10
    b_variable = 20
    c_variable = 30
    aa_variable = 10
    bb_variable = 20
    list = [a_variable, b_variable, c_variable]
    cc_variable = aa_variable + bb_variable

    return list, cc_variableThen callingalphabetize unordered_code_multi.pya second time produces a further ordered file:def test_function():
    a_variable = 10
    aa_variable = 10
    b_variable = 20
    bb_variable = 20
    c_variable = 30
    cc_variable = aa_variable + bb_variable
    list = [a_variable, b_variable, c_variable]

    return list, cc_variableRecommended RunningWhen usingalphabetizeit is recommended that you lint and format your files in the following order:flake8is a wrapper around the tools:PyflakespycodestyleNed Batchelder's McCabe scriptvulturefinds unused code in Python programs.alphabetizefinds and orders variables within filesIt is recommended to runalphabetizea second time to catch any caught dependent variables. Then a furtherflake8to ensure your file is formatted and adheres to PEP8 correctly.