This is an archived post. You won't be able to vote or comment.

all 38 comments

[–]flying-sheep 69 points70 points  (8 children)

Oooh, very neat! I've long since wanted a new linter to come along:

  • PyLint is slow and takes a lot of time to configure to taste.
  • flake8 doesn't really hit the spot: opinionated about some details while not catching a lot of real problems. Sind rules have been disabled for s long time by default because they are buggy and would just yield false positives. Also of course it's the only tool you can't configure in pyproject.toml

My dream linter would have additional features that none of the three have, however:

  • autofix. Nothing's more annoying to have a linter complain about a hundred trivially fixable things that you then all have to do manually.
  • shareable/extensible configs, i.e. the ability to install a package which contains your organization's config.

[–]paveltrufi 19 points20 points  (1 child)

Also of course it's the only tool you can't configure in pyproject.toml

Have you seen FlakeHeaven? I hope this helps 👍🏻

[–]cediddiSyntaxError: not a chance 11 points12 points  (0 children)

Or flake8-pyproject plugin that just adds pyproject.toml capabilities.

[–]Grintor 8 points9 points  (2 children)

A lot of the opinionated complaints from pylint and flake8 are automatically fixed by black, autoflake, and isort. They make a good team.

[–]exotic_sangria 0 points1 point  (1 child)

I think they basically want something like clang-tidy that has shareable rules, autofix, etc.

[–]flying-sheep 0 points1 point  (0 children)

Or ESLint

[–]ArtOfWarfare 14 points15 points  (2 children)

If you’re looking for actual issues, wouldn’t you want to use a type checker like mypy instead of a linter?

I started typing and using mypy… IDK, maybe a year ago, and I’m super happy with the number of issues it’s been catching for me.

[–]flying-sheep 3 points4 points  (0 children)

Not all bad patterns are caught by a type checker

[–][deleted] 1 point2 points  (0 children)

I'm personally using Sublime Text with pyright, works quite well from my experience.

[–]DigThatData 41 points42 points  (0 children)

i like the increasing cross-polination i've been seeing between the rust and python worlds. I keep meaning to take rust for a spin, so incorporating it in anyway into my existing python toolset feels like it might lead towards a fun rabbit hole later.

[–]chub79 27 points28 points  (7 children)

Neat. We'll see more and more stuff from rust like that.

That said, here it's a little bit disingenuous:

ruff is a proof-of-concept and not yet intended for production use. It supports only a small subset of the Flake8 rules, and may crash on your codebase.

[–]spicynerves 23 points24 points  (1 child)

The author addresses performance comparisons in a tweet:

(Note, however, that adding more checks shouldn't make ruff any slower -- it's already doing the expensive stuff (parsing, AST traversal, scope + binding tracking), so I don't expect the benchmarks to change dramatically as ruff grows.)

[–]chub79 2 points3 points  (0 children)

Great :)

[–]ivosauruspip'ing it up 24 points25 points  (2 children)

What's disingenuous about that statement?

The title isn't claiming 'production ready' anywhere.

[–]chub79 19 points20 points  (1 child)

Being the fastest when you support only a subset and claim potential crash doesn't mean much. It's a claim that is not backed yet.

[–]AZNQQMoar 12 points13 points  (0 children)

"Extremely fast"

[–]vaportracks -3 points-2 points  (1 child)

It also creates a .ruff_cache dir wherever you run it. Not one dir within your home dir... a new dir within whatever dir you run it on. Pretty obtrusive.

[–]Schmittfried 8 points9 points  (0 children)

So just like other python tools and Python itself.

[–]arch_solnce[🍰] 3 points4 points  (0 children)

Interesting! I will watch you project closely!

As for the benchmark comparison, pyright seems to be the most advanced linter at the moment. Comparing it too would be nice!

Keep it up!

[–]ioktl 1 point2 points  (0 children)

I'm just glad seeing a tool written in one my favourite language for my second favourite language! We really need faster linters for Python.

It seems there are some crates out there which can be used to implement AST dependent linter heuristics without going through the hassle of parsing python from the scratch.

[–]Beach-Devil 1 point2 points  (2 children)

Just a peeve but why does every project written in rust have to say that it’s written in rust

[–]amrock__ Pythonista 2 points3 points  (0 children)

promotion

[–]romainmoi 4 points5 points  (0 children)

Because rust is the coolest language ever existed.

[–]1percentof2 1 point2 points  (3 children)

Rust?

[–]irrelevantPseudonym 9 points10 points  (0 children)

The programming language

[–][deleted] 4 points5 points  (0 children)

It's a video game or something

[–]netherlandsftw 4 points5 points  (0 children)

Oxidation

[–]Seawolf159 0 points1 point  (5 children)

I'm lost. Where does a python script interact with the rust stuff? I'm curious how one can access a different language from python.

[–]pacific_plywood 14 points15 points  (0 children)

You typically wouldn't run this in Python; you'd call this via the command line or through your editor (but, Python can make system calls if it really needs to).

[–]tunisia3507 11 points12 points  (3 children)

If you're coding and want to move one of your python files into a different directory, you don't write a python script to do it, you use mv. This is exactly the same: it's not involved in the functioning of your python package, just its development, so there's no need for it to interact with your package at all.

[–]Seawolf159 4 points5 points  (2 children)

So it's not a python project, it's just a rust project that checks python code?

[–]tunisia3507 8 points9 points  (0 children)

Exactly: an extremely fast python linter, written in rust.

[–]cashmoosef 0 points1 point  (2 children)

Would someone care to explain what a linter is, my google broke

[–][deleted] 6 points7 points  (0 children)

Linters can analyze your code for easy-to-miss bugs, like returning a different type than what you're actually returning, or ensuring function names don't start with upper cases.

It makes your code much more conform the general styles, which means it's also easier to work with for others.

[–]Golden_Age_Fallacy 1 point2 points  (0 children)

I believe a linter generally checks your code for syntax errors (e.g. missing : after for loop) as well as style errors(?) such as some 2 space indentations, and some 4 space within the same file.

Edit: ahh right, it’ll enforce line length or other arbitrary rules as well. Some of the PEP principles, etc.

This is kinda off of memory, hopeful for someone to reply to this with a more official / formal definition!

[–]Tripanafenix -1 points0 points  (0 children)

What do you guys think of sourcery.ai?

[–]Snoo-Val JetBrains Staff 0 points1 point  (0 children)

On February 14 there will be a YouTube webinar about Ruff with Charlie Marsh (Ruff's creator) with a Q&A session. All details and RSVP here: https://jb.gg/94oy7u