aboutsummaryrefslogtreecommitdiff
path: root/examples/static-analysis/none_comparisons.tbsp
blob: 2d654265a67bdcba682c41b8f1f8c279af128c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
BEGIN {
    bool in_equal_compare = false;
    string comparison_text = "";
}

enter comparison_operator {
    if (text(node.operators) == "==") {
        in_equal_compare = true;
        comparison_text = text(node);
    };
}

leave comparison_operator {
    in_equal_compare = false;
}

enter none {
    if (in_equal_compare) {
        print("using `==` to compare with None, use `is None` instead:\n\t");
        print(comparison_text);
        print("\n");
    } else {
    };
}