-
-
Notifications
You must be signed in to change notification settings - Fork 28.7k
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
Bump ruff to 0.0.254 #89273
Bump ruff to 0.0.254 #89273
Conversation
@@ -526,6 +526,7 @@ async def read_gatt_char( | |||
The characteristic to read from, specified by either integer | |||
handle, UUID or directly by the BleakGATTCharacteristic | |||
object representing it. | |||
**kwargs: Unused |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file resolves D417 Missing argument description in the docstring
All others refer to UP038 [*] Use 'X | Y' in 'isinstance' call instead of '(X, Y)'
@@ -203,6 +203,6 @@ def native_value(self) -> float | int | str | None: | |||
"""Return current state.""" | |||
descr = self.entity_description | |||
state: float | int | str | None = self.coordinator.data.get(descr.key) | |||
if state is not None and descr.factor and isinstance(state, (float, int)): | |||
if state is not None and descr.factor and isinstance(state, float | int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: The union syntax is 100 - 50 % slower on Python 3.10 and Python 3.11 than the tuple syntax, according to the issue for this feature in ruff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, this is the issue mentionned above: astral-sh/ruff#2923
See also PEP 604
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: The union syntax is 100 - 50 % slower on Python 3.10 and Python 3.11 than the tuple syntax, according to the issue for this feature in ruff.
Does it make sense then to replace it if it's slower? The way I understand PEP 604, it's a new option to use the Union syntax. However the old way won't go anywhere anytime soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add UP038
to ignore list, and I can revert commit 65a884a if that is what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all in favor of modern syntaxes, but we don't have to pay the performance price right now, which affects 95% of the userbase. I think we can reconsider once we run Python 3.11 on our main distribution.
For now, I rather have this one on the ignore list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This reverts commit 65a884a.
Proposed change
Follow-up to #89211 and #89240
https://github.com/charliermarsh/ruff/releases/tag/v0.0.254
In particular:
: Replace tuples with type union in isinstance or issubclass calls astral-sh/ruff#3280UP038 [*] Use 'X | Y' in 'isinstance' call instead of '(X, Y)'
D417 Missing argument description in the docstring
: Use presence of convention-specific sections during docstring inference astral-sh/ruff#3325Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: