astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
28.75k stars 933 forks source link

PyCharm inspections #3040

Open matthewlloyd opened 1 year ago

matthewlloyd commented 1 year ago

(Opening a new issue to continue the discussion from #2972 which will be closed by https://github.com/charliermarsh/ruff/pull/3022)

I went through all the PyCharm inspections, filtered those I deemed implementable in a non-type-aware linter, and categorized them by whether they have Ruff or PyLint counterparts, mostly by running Ruff and PyLint directly on the examples provided in the PyCharm Settings panel.

There were five left over, which might merit consideration for inclusion as RUF rules.

PyCharm inspections not currently covered by Ruff or PyLint

Covered by Ruff or PyLint

charliermarsh commented 1 year ago

Thank you for this, super thorough and much appreciated!

pkulev commented 5 months ago

I'm looking forward to see those checks in ruff! I'll expand here some moments regarding F811 and similar check in pycharm.

In the following example all redeclarations were highlighted by pycharm, but ruff alerts only on imports and function/class definitions. Variable redeclaration without usage passes the check.

import os
import sys
import os  # ruff alerts F811

def foo():
    pass

def foo():  # ruff alerts F811
    pass

class Foo:
    pass

class Foo:  # ruff alerts F811
    pass

class Bar:
    x = 10
    x = 20  # No alert

BAR = "bar"
BAR = "baz"  # No alert

It would be great to enable checking for variables too.