this post was submitted on 26 Feb 2025
24 points (100.0% liked)

Python

6723 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
 
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()

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

you are viewing a single comment's thread
view the rest of the comments
[–] FizzyOrange 2 points 5 days ago (5 children)

Yeah Pylint catches this. If you aren't using Pylint you are writing bad Python.

[–] [email protected] 6 points 5 days ago (4 children)

That's a funny way to spell Ruff

[–] FizzyOrange 3 points 4 days ago (3 children)

Yeah I tried Ruff about a year ago and it only had really trivial lints so it wasn't a good replacement for Pylint. Is it on par yet?

[–] NostraDavid 2 points 4 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).

load more comments (2 replies)
load more comments (2 replies)
load more comments (2 replies)