Use clearer number notation for very small and very large literals#164521
Use clearer number notation for very small and very large literals#164521Pierre-Sassoulas wants to merge 2 commits intohome-assistant:devfrom
Conversation
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).
There was a problem hiding this comment.
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!
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Hey there @cgtobi, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
Hey there @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
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.00000001with1e-8in Bitcoin sensor satoshi conversion math (×6 occurrences) - Replace
1000000.0with1_000_000.0in 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 |
|
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. |
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
Additional information
Checklist
ruff format 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.To help with the load of incoming pull requests: