Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A002: shadowing python builtin bug. #3053

Closed
jonathan-s opened this issue Feb 20, 2023 · 2 comments
Closed

A002: shadowing python builtin bug. #3053

jonathan-s opened this issue Feb 20, 2023 · 2 comments
Labels
question Asking for support or clarification

Comments

@jonathan-s
Copy link

jonathan-s commented Feb 20, 2023

Ruff version: 0.0.247

class BaseMessage(dict):
    pass

    @property
    def type(self):
        return self["type"]

When using flake8-builtins linting, it complains that Argument type is shadowing a python builtin. However in this instance it is not an argument, but an attribute.

This collides with A003, right now A002 takes precedence over A003.

Somewhat interesting discussion around A003 -> gforcada/flake8-builtins#75 though I would say, leave it up to the user. Personally I don't see much point in A003.

@jonathan-s jonathan-s changed the title flake8-builtin: shadowing python builtin bug. A002: flake8-builtin: shadowing python builtin bug. Feb 20, 2023
@jonathan-s jonathan-s changed the title A002: flake8-builtin: shadowing python builtin bug. A002: shadowing python builtin bug. Feb 20, 2023
@charliermarsh charliermarsh self-assigned this Feb 20, 2023
@charliermarsh charliermarsh added the bug Something isn't working label Feb 20, 2023
@charliermarsh charliermarsh removed their assignment Feb 20, 2023
@charliermarsh
Copy link
Member

When I run this, I get A003 Class attribute type is shadowing a python builtin, which seems correct. Am I misinterpreting the issue?

@charliermarsh charliermarsh added question Asking for support or clarification and removed bug Something isn't working labels Feb 21, 2023
@allisonkarlitskaya
Copy link
Contributor

I think the issue is that it doesn't really make sense to worry about this problem because it's almost never possible to refer to class attributes in a way that would conflict with a builtin.

An interesting approach might be to allow the definition to go through but to flag any potentially-confusing use.

It's also easy enough to just explicitly exclude A003 (or don't select A in the first place). It might make sense to remove A003 from being automatically enabled by A, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

3 participants