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

Allow del when working with c_exts #1408

Closed
webknjaz opened this issue May 19, 2020 · 3 comments
Closed

Allow del when working with c_exts #1408

webknjaz opened this issue May 19, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@webknjaz
Copy link
Contributor

Bug report

What's wrong / How is that should be

del smth raises WPS420. But sometimes I want to follow the principle saying that explicit is better than implicit to free that var and effectively allow Python to hit it with GC.

In particular, this is useful when working with objects implemented as C-extensions. I just want to inform Python that it's okay to deallocate them as soon as possible.

System information

N/A

@webknjaz webknjaz added the bug Something isn't working label May 19, 2020
@sobolevn
Copy link
Member

I can say that detecting that it is a C-extension is an overkill for disabling this rule for a single keyword.
Are there any other ways to detect things we can safely use del with?

In my opinion it is a good candidate for ignore=

P.S. Unrelated, but anyway: I am implementing a Future monad to work with async code: https://github.com/dry-python/returns#future-container I would appreciate your opinion on it!

@webknjaz
Copy link
Contributor Author

I can say that detecting that it is a C-extension is an overkill for disabling this rule for a single keyword.
Are there any other ways to detect things we can safely use del with?

Right, I just wanted to share a use-case here. But also, maybe this rule could be relaxed a bit if the target is just a variable name? As in, don't explode on del x but fail on del x[1].

In my opinion it is a good candidate for ignore=

Yeah, I'm thinking about it too.

P.S. Unrelated, but anyway: I am implementing a Future monad to work with async code: dry-python/returns#future-container I would appreciate your opinion on it!

Looks cool. Maybe I'll get to try it out when I'll finally have some time for the octomachinery refactoring...

@sobolevn
Copy link
Member

Thanks a lot for the report. Going to close as "a great example for 100% valid noqa or ignore=".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants