Skip to content

Use clearer number notation for very small and very large literals#164521

Open
Pierre-Sassoulas wants to merge 2 commits intohome-assistant:devfrom
Pierre-Sassoulas:dev
Open

Use clearer number notation for very small and very large literals#164521
Pierre-Sassoulas wants to merge 2 commits intohome-assistant:devfrom
Pierre-Sassoulas:dev

Conversation

@Pierre-Sassoulas
Copy link

@Pierre-Sassoulas Pierre-Sassoulas commented Mar 1, 2026

Proposed change

Use scientific notation (1e-8, 1e-7, 1e-11) and underscore grouping (1_000_000.0) for numeric literals that are hard to read in plain decimal form, as identified by pylint's yet unreleased number-notation checker (pylint-dev/pylint#10425).

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:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • 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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Use scientific notation (1e-8, 1e-7, 1e-11) and underscore grouping
(1_000_000.0) for numeric literals that are hard to read in plain
decimal form, as identified by pylint's yet unreleased number-notation
checker (pylint-dev/pylint#10425).
Copilot AI review requested due to automatic review settings March 1, 2026 14:27
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @Pierre-Sassoulas

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

home-assistant bot commented Mar 1, 2026

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

home-assistant bot commented Mar 1, 2026

Hey there @cgtobi, mind taking a look at this pull request as it has been labeled with an integration (netatmo) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of netatmo can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign netatmo Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.
@home-assistant
Copy link

home-assistant bot commented Mar 1, 2026

Hey there @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of esphome can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign esphome Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.
@Pierre-Sassoulas Pierre-Sassoulas marked this pull request as ready for review March 1, 2026 14:29
@home-assistant home-assistant bot dismissed their stale review March 1, 2026 14:29

Stale

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the readability of numeric literals that are hard to read in plain decimal form, as flagged by an upcoming pylint number-notation checker. It replaces hard-to-read small decimal literals (like 0.00000001) with scientific notation (1e-8) and groups large integer-like floats with underscores (1_000_000.0).

Changes:

  • Replace 0.00000001 with 1e-8 in Bitcoin sensor satoshi conversion math (×6 occurrences)
  • Replace 1000000.0 with 1_000_000.0 in ESPHome light and mass/volume concentration unit conversion
  • Replace tiny decimal literals (0.00000000001, 0.0000001) with scientific notation in color utility and Netatmo config flow

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
homeassistant/components/bitcoin/sensor.py Six 0.00000001 satoshi-conversion literals replaced with 1e-8
homeassistant/components/esphome/light.py 1000000.0 mired conversion literal replaced with 1_000_000.0
homeassistant/components/netatmo/config_flow.py 0.0000001 coordinate padding literal replaced with 1e-7
homeassistant/util/color.py Near-zero guard value 0.00000000001 replaced with 1e-11
homeassistant/util/unit_conversion.py 1000000.0 unit ratio replaced with 1_000_000.0
@MartinHjelmare
Copy link
Member

Please restore the PR template in the PR description. Fill out the PR template and don't remove the things you don't fill out.

@MartinHjelmare MartinHjelmare marked this pull request as draft March 1, 2026 18:38
@Pierre-Sassoulas Pierre-Sassoulas marked this pull request as ready for review March 1, 2026 20:38
Copilot AI review requested due to automatic review settings March 1, 2026 20:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment