Git Product home page Git Product logo

Comments (3)

samueljsb avatar samueljsb commented on July 19, 2024

I've found another one that's causing us problems: decorators.

from dataclasses import dataclass


@dataclass()
class C:
    pass


# lint-fixme: ExplicitFrozenDataclass
@dataclass()
class C:
    pass


@dataclass()  # lint-fixme: ExplicitFrozenDataclass
class C:
    pass

We'd expect the first function to be reported, and the other two to be silenced.

t.py@4:0 ExplicitFrozenDataclass: When using dataclasses, explicitly specify a frozen keyword argument. Example: `@dataclass(frozen=True)` or `@dataclass(frozen=False)`. Docs: https://docs.python.org/3/library/dataclasses.html (has autofix)
t.py@10:0 ExplicitFrozenDataclass: When using dataclasses, explicitly specify a frozen keyword argument. Example: `@dataclass(frozen=True)` or `@dataclass(frozen=False)`. Docs: https://docs.python.org/3/library/dataclasses.html (has autofix)
🛠️  1 file checked, 1 file with errors, 2 auto-fixes available 🛠️

But we see the first two reported. The last one is correctly silenced.

from fixit.

samueljsb avatar samueljsb commented on July 19, 2024

I have written some failing tests to demonstrate these problems in #413. I haven't worked out how to demonstrate the function def problem yet, so I'd appreciate any advice you can offer there.

from fixit.

samueljsb avatar samueljsb commented on July 19, 2024

I have found another case. This looks superficially similar to the comprehensions case.

In the following file (t.py), we would expect the violation to be reported for the first function, but not for either of the other two.

def f(x):
    return (
        isinstance(x, int) or isinstance(x, float)
    )


def f(x):
    return (
        isinstance(x, int) or isinstance(x, float)  # lint-fixme: CollapseIsinstanceChecks
    )


def f(x):
    return (
        # lint-fixme: CollapseIsinstanceChecks
        isinstance(x, int) or isinstance(x, float)
    )

However, the violation is reported for all three:

$ fixit lint t.py
t.py@3:8 CollapseIsinstanceChecks: Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. (has autofix)
t.py@9:8 CollapseIsinstanceChecks: Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. (has autofix)
t.py@16:8 CollapseIsinstanceChecks: Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. (has autofix)
🛠️  1 file checked, 1 file with errors, 3 auto-fixes available 🛠️

from fixit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.