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

False positive instance-method-first-arg-name when using zope.interface #380

Open
2 tasks done
miketheman opened this issue Aug 21, 2023 · 1 comment
Open
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@miketheman
Copy link

Checklist

  • I have searched the Sourcery documentation for the issue, and found nothing
  • I have checked there are no open bugs referencing the same bug or problem

Description

When declaring a class that inherits from zope.interface.Interface, the suggested refactor is incompatible with the library's behavior.

From zope.interface documentation:

Note that bar doesn’t take a self argument. Interfaces document how an object is used. When calling instance methods, you don’t pass a self argument, so a self argument isn’t included in the interface signature. The self argument in instance methods is really an implementation detail of Python instances.

Code snippet that reproduces issue

from zope.interface import Interface

class IRandomNameService(Interface):
    def foo(name): ...

I expect Sourcery to not alert me about this refactoring when examining the Interface declaration - but for any implementer class, it should continue to recommend adding self, like so:

from zope.interface import implementer

@implementer(IRandomNameService)
class RealRandomNameService:
    def foo(self, name): ...

Debug Information

IDE Version: PyCharm 2023.2 (Professional Edition)

Build #PY-232.8660.197, built on July 26, 2023

Sourcery Version: sourcery.pycharm-plugin (1.7.0)

Operating system and Version: macOS Ventura 13.5 (22G74)

@miketheman miketheman added the bug Something isn't working label Aug 21, 2023
@bm424 bm424 self-assigned this Aug 23, 2023
@miketheman
Copy link
Author

miketheman commented Jan 3, 2024

Is there anything I can do to help correct this? The source for sourcery isn't open, is it?

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