Live data from Hacker News

Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

astral.sh

231–240 of 247 posts

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#231
post #83
post #53

Earlier quoted context omitted.

Waiting patiently for the other person to produce a post hoc rationalization about why everybody’s code looking different is in fact a good thing

My argument is more to the tune of "everybody’s code looking slightly different is not a problem in practice as long as I can read and understand it." However since you've asked so nicely here you go: everybody’s code looking different is because all humans are different. It's what makes us human. I am very serious about my craftsmanship, and I bring my "humanity" to it: sometimes I include a cultural reference (as i…

It depends wildly on how one defines "slightly". If it overflows in the editor, then that's a problem IMO. But some people would say no. In PHP we often see this type of thing:

  $someArr = [
    'config' => [
      'system' => 'linux',
      ...
     ],
  ];
Versus:

  $someArr =
    [
      'config' =>
        [
          'system' => 'linux',
          ...
        ],
    ];

Well... option 2 uses both significantly more vertical space, and horizontal space. But it's technically PSR compliant. However, we really need standard formatting on this, because it's annoying.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#232
post #20

Earlier quoted context omitted.

In my previous place, discussions on coding style were forbidden in PRs. It worked just fine. Edit: one could also use single or double quotes in strings, and it didn't anger the grammar nazi bots as there were none.

Using a consistent string delimiter has value: if you search for ['foo'] you will find all instances of the string foo. With inconsistent delimiters, you better have a single canonical 'foo' in your project or you're going to run into problems.

The inverse is also true (speaking from PHP, I'm not 100% familiar with Python semantics). If we use '' where appropriate, then we know absolutely no escaping and no interpolation is done. That has value. If we use "" for everything, then we have to examine the string for interpolation or for escaping.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#233
post #230
post #224

Earlier quoted context omitted.

I find it hard to look at ruff as at "other dependencies." First, my other dependencies usually deliver something of value to the customer (and so I deliver my other dependencies to the end-user installation.) Second, when I need to change code to accommodate other dependencies, it is usually limited to a couple of files, sometimes to a couple of modules; this change will touch much, much more than that. Third, my ot…

I also do not like if project stays on 0 version to break compatibility with every minor version. This is the problem with many rust tools and libraries. I think it is unfair to do that years after first release and with healthy community. But it is a tradeoff and not using ruff is in my opinion worse. To your other issues, just do not upgrade. There is no need to upgrade everything a few days after release. I always…

I find it kinda amusing that we seem to have an endless and useless discussion on "what version of ruff to use" now when you kinda implied that you have some sort of a solution to these endless, useless discussions -- in a form of "just use ruff."

> upgrade whenever it is convenient

In my codebase, and with my environment, the best answer is never. We'll have to pick a second-best answer though.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#234

Earlier quoted context omitted.

The point of the "grammar nazi" bots is to focus on the actual problems: if a bot is deciding about linting, you don't have to waste brain power to discuss it in PRs. It is what it is, everyone gets the same, shut up and work on what matters. I'm surprised you consider it a lot of energy spent, I tend not to spend any on this, it just runs automatically on my code and I drop out of pretty much every discussions about…

I've never had discussions about code formatting in PRs, this seems like a made up problem or something that predates my career.

I've made comments if the formatting is egregious enough. This is a "bigger problem" in not-python, languages without significant whitespace. You can truly write some horrifying code that will compile just fine.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#235
post #221

Earlier quoted context omitted.

(am not the GP) I personally like double quotes, because in so many other languages they are for strings, while single quotes are often for other things. But somehow many people have a single quotes obsession in Python. I am guessing, that it is because of ease of typing them on a US keyboard layout.

> many people have a single quotes obsession Not my problem. My problem is that I want to use them both , as I've been able to for many years. I'll always use double to surround "can't" and single to surround '8.5" x 14"'. I'll use a context-appropriate pair when adding to existing code. But for all the other cases, I don't want to expend any energy on this. It's a complete non-issue. > ease of typing them on a US ke…

At least on German keyboard layout double quotes are not a single key press, but a shift + something combination. Shift + 2, I believe. It's been a while since I used German layout. But I am aware, that other EU countries have other layouts, so there it could be a single key press, and I wouldn't know.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#237
post #206

Earlier quoted context omitted.

I think that tabs vs spaces is a rather extreme example because it has unexpected parser semantics - that is, it's not a style choice. So I don't think it's actually relevant to a conversation about conventions/ style.

It definitely is relevant to a discussion about linters. And as I said on my comment - it's just an example, I mentioned other types of discussions as well.

I don't think it is because spaces vs tabs impacts semantics.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#238
post #206

Earlier quoted context omitted.

It definitely is relevant to a discussion about linters. And as I said on my comment - it's just an example, I mentioned other types of discussions as well.

I don't think it is because spaces vs tabs impacts semantics.

Since this is a long-standing, real-world problem that linters solved, how could it not be relevant to a discussion about the usefulness of linters?

And the choice of whether to use tabs or spaces does not affect semantics. It is purely a matter of style. Indentation using tabs and indentation using spaces work in exactly the same way.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#239

Earlier quoted context omitted.

You know how many bugs I've met working on large Python codebases over 20 years, caused by unsorted imports or `except Exception`? Yeah, you've guessed it: exactly 0 bugs. It's really annoying how many people think that if you enforce stupidly strict rules about formatting, more strict that those of Fortran in 70s, you'll automatically get good code. I've seen companies that enable 100% of ruff rules, use several oth…

I don't think people expect import sorting to fix bugs. It's just good (and free!) practice. Anyway I have definitely had linters like Ruff catch bugs. Probably the most common is the mutable default argument gotcha.

I'm not saying that it's not catching bugs. Sometimes it does. But most of the rules are nonsense and the number of rules that makes no sense is growing.

Also, mutable default argument is not a bug. It is a bug only if mutable default argument is mutated inside the body of a function/method. Which is almost never the case.

Re: Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

#240

I really wish Ruff would introduce something similar to Nix’s stateVersion, which is used to determine the set of defaults that will be applied. Updating Ruff at a scale beyond a single repo is a bit of a crapshoot currently, with every version introducing a bunch of new default rules which you then have to deal with immediately (either by turning them off or fixing them). I’m aware we could have an allowlist in plac…

If you want to be protected from changes in the default set, you can choose the ones you want with `select`.
Post reply on HN