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

[pylint] Do not report property-like wrappers (PLE0302) #15582

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #15572.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Contributor

github-actions bot commented Jan 19, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser
Copy link
Member

MichaReiser commented Jan 19, 2025

Would you mind extending your summary with an explanation why you think we should allow property wrapped context managers. It seems you already did some research and writing it down would save me the work to do the same.

@InSyncWithFoo
Copy link
Contributor Author

InSyncWithFoo commented Jan 19, 2025

@MichaReiser This is not specific to any dunder methods. The issue's example is a bit too complex, so here's a simplification:

class C:
	# This is the normal signature and one expected by PLE0302
	def __getitem__(self, other): ...


def some_function(other): ...

class D:
	@property
	def __getitem__(self):
		return some_function

d = D()
d[1]  # Calls `d.__getitem__(1)`.
      # `d.__getitem__` returns `some_function`,
      # so the eventual result is that of `some_function(1)`.

@dylwil3 dylwil3 added the rule Implementing or modifying a lint rule label Jan 19, 2025
@charliermarsh charliermarsh self-assigned this Jan 19, 2025
@charliermarsh
Copy link
Member

I'll fix the docs and merge.

@charliermarsh
Copy link
Member

I asked one question in the linked issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive PLE0302 with special methods as properties.
4 participants