class Node:
    def __init__(self, edges = set()):
        self.edges = edges


def main():
    foo = Node()
    bar = Node()
    quz = Node()

    foo.edges.add(bar)
    bar.edges.add(foo)

    assert(foo is not bar) # assertion succeeds
    assert(foo is not quz) # assertion succeeds
    assert(bar is not quz) # assertion succeeds
    assert(len(quz.edges) == 0) # assertion fails??


main()
spoiler

Mutable default values are shared across objects. The set in this case.

  • NostraDavid
    link
    fedilink
    arrow-up
    2
    ·
    5 days ago

    It has implemented about half - I would check which the important ones are, and check if it’s been implemented (which is being tracked in issue 970):

    https://github.com/astral-sh/ruff/issues/970

    Astral claims Ruff has more rules total (about 800), but implemented about half of Pylint (which has 400 rules, so 200 implemented).