Skip to content

Drop __get__ and __set__ from unnecessary-dunder-call#9791

Merged
charliermarsh merged 4 commits intomainfrom
zb/fix-get-set-dunder
Feb 5, 2024
Merged

Drop __get__ and __set__ from unnecessary-dunder-call#9791
charliermarsh merged 4 commits intomainfrom
zb/fix-get-set-dunder

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Feb 2, 2024

These are for descriptors which affects the behavior of the object as a property; I do not think they should be called directly but there is no alternative when working with the object directly.

Closes #9789

These are for descriptors which affects the behavior of the object _as a property_; I do not think they should be called directly but there is no alternative when working with the object directly
@zanieb zanieb marked this pull request as draft February 2, 2024 17:13
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)

sphinx-doc/sphinx (error)

ruff failed
  Cause: Selection of unstable rules without the `--preview` flag is not allowed. Enable preview or remove selection of:
	- FURB113
	- FURB131
	- FURB132

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -7 violations, +0 -0 fixes in 2 projects; 41 projects unchanged)

apache/airflow (+0 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- airflow/serialization/serialized_objects.py:875:17: PLC2801 Unnecessary dunder call to `__get__`. Use `get` method.

bokeh/bokeh (+0 -6 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- src/bokeh/core/property/descriptors.py:394:16: PLC2801 Unnecessary dunder call to `__get__`. Use `get` method.
- src/bokeh/core/property/descriptors.py:444:21: PLC2801 Unnecessary dunder call to `__get__`. Use `get` method.
- src/bokeh/core/property/descriptors.py:652:17: PLC2801 Unnecessary dunder call to `__get__`. Use `get` method.
- src/bokeh/core/property/descriptors.py:944:17: PLC2801 Unnecessary dunder call to `__set__`. Use subscript assignment.
- tests/unit/bokeh/core/property/test_descriptors.py:105:13: PLC2801 Unnecessary dunder call to `__set__`. Use subscript assignment.
- tests/unit/bokeh/core/property/test_descriptors.py:98:13: PLC2801 Unnecessary dunder call to `__get__`. Use `get` method.

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLC2801 7 0 7 0 0

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Feb 2, 2024

Unclear if we should drop the violation entirely. I think we should though — will require a bit more work and some test coverage.

@charliermarsh
Copy link
Copy Markdown
Member

Yeah I say we drop it.

@AlexWaygood
Copy link
Copy Markdown
Member

The suggestion for __delete__ is similarly weird — calling .__delete__() on a descriptor instance is very different to using the del statement

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Feb 2, 2024

Ah good catch yeah that one is for descriptors too...

@charliermarsh charliermarsh marked this pull request as ready for review February 5, 2024 15:33
@charliermarsh charliermarsh added the bug Something isn't working label Feb 5, 2024
…dunder_call.py

Co-authored-by: Zanie Blue <contact@zanie.dev>
@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Feb 5, 2024

Can't approve but lgtm, thanks!

@charliermarsh charliermarsh merged commit 84aea7f into main Feb 5, 2024
@charliermarsh charliermarsh deleted the zb/fix-get-set-dunder branch February 5, 2024 15:54
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

Successfully merging this pull request may close these issues.

PLC2801 triggers for cases that are not necessarily errors

3 participants