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

Bump ruff to 0.0.254 #89273

Merged
merged 5 commits into from
Mar 7, 2023
Merged

Bump ruff to 0.0.254 #89273

merged 5 commits into from
Mar 7, 2023

Conversation

epenet
Copy link
Contributor

@epenet epenet commented Mar 7, 2023

Proposed change

Follow-up to #89211 and #89240

https://github.com/charliermarsh/ruff/releases/tag/v0.0.254

In particular:

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@@ -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
Copy link
Contributor Author

@epenet epenet Mar 7, 2023

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):
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

LGTM.

@epenet epenet added smash Indicator this PR is close to finish for merging or closing second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. and removed smash Indicator this PR is close to finish for merging or closing labels Mar 7, 2023
@frenck frenck merged commit ff2a88b into home-assistant:dev Mar 7, 2023
@epenet epenet deleted the ruff-254 branch March 7, 2023 12:26
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed core dependency second-opinion-wanted Add this label when a reviewer needs a second opinion from another member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants