Commit Graph

809 Commits (a5f70dec967428d26e0be3ce2495588b7542a7b5)

Author SHA1 Message Date
J. Nick Koston 04ab74589a
Fix missing f-string in loop util (#120800) 2024-06-29 07:01:18 +02:00
J. Nick Koston f7e194b32c
Adjust blocking I/O messages to provide developer help (#120113) 2024-06-21 12:55:22 -05:00
dontinelli 0dd5391cd7
Add Siemes and Millisiemens as additional units of conductivity and enable conversion between conductivity units (#118728) 2024-06-21 11:10:15 +02:00
Marc Mueller dbb27755a4
Update mypy-dev to 1.11.0a5 (#118519) 2024-06-02 15:28:24 +02:00
J. Nick Koston 8f94205014
Include a traceback for non-strict event loop blocking detection (#118620) 2024-06-02 06:36:25 -04:00
Paulus Schoutsen 9dc580e5de
Add (deep)copy support to read only dict (#118204) 2024-05-26 23:05:45 -04:00
J. Nick Koston c368ffffd5
Add async_get_hass_or_none (#118164) 2024-05-26 13:38:46 +02:00
Jan Bouwhuis c616fc036e
Move recorder chunk utils to shared collection utils (#118065) 2024-05-24 12:49:39 -10:00
Marc Mueller 5c9c71ba2c
Fix performance regression with SignalType (#117920) 2024-05-22 13:58:37 +02:00
Marc Mueller d44f949b19
Use PEP 695 misc (2) (#117814) 2024-05-21 09:45:57 +02:00
J. Nick Koston 5a609c34bb
Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
Marc Mueller f76842d7db
Use PEP 695 for hass_dict annotations (#117779) 2024-05-20 10:46:50 +02:00
Marc Mueller 8f0fb4db3e
Use PEP 695 for class annotations (4) (#117778) 2024-05-20 10:44:52 +02:00
Marc Mueller 4cf0a3f154
Use PEP 695 for function annotations (3) (#117660) 2024-05-18 11:43:32 +02:00
Marc Mueller 25d1ca747b
Use PEP 695 for decorator typing (3) (#117640) 2024-05-17 16:27:32 +02:00
Marc Mueller 87bb7ced79
Use PEP 695 for simple type aliases (#117633) 2024-05-17 14:42:21 +02:00
J. Nick Koston 6d7345ea1c
Speed up loading YAML (#117388)
Co-authored-by: Dave T <17680170+davet2001@users.noreply.github.com>
2024-05-14 13:56:42 +02:00
J. Nick Koston d06932bbc2
Refactor asyncio loop protection to improve performance (#117295) 2024-05-13 07:01:55 +09:00
Sid 2cc916db6d
Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
Marc Mueller 3d700e2b71
Add HassDict implementation (#103844) 2024-05-07 10:53:13 +02:00
Sid b456d97e65
Replace pylint protected-access with Ruff SLF001 (#115735) 2024-05-06 20:33:26 +02:00
Sid e662e3b65c
Bump ruff to 0.4.2 (#116201)
* Bump ruff to 0.4.2

* review comments
2024-04-26 08:48:32 +02:00
rlippmann 1120246194
Deprecate relative_time() in favor of time_since() and time_until() (#111177)
* add time_since/time_until.  add deprecation of relative_time

* fix merge conflicts

* Apply suggestions from code review

* Update homeassistant/helpers/template.py

* Update homeassistant/helpers/template.py

* Update homeassistant/helpers/template.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-04-24 11:13:07 +02:00
J. Nick Koston 53a179088f
Add debug mode to catch unsafe thread operations using core helpers (#115390)
* adjust

* adjust

* fixes

* one more

* test

* debug

* move to config

* cover

* Update homeassistant/core.py

* set debug from RuntimeConfig

* reduce

* fix message

* raise

* Update homeassistant/core.py

* Update homeassistant/core.py

* no flood check for raise

* cover
2024-04-24 03:36:05 +02:00
J. Nick Koston 8f1761343e
Only work out job type once when setting up dispatcher (#116030) 2024-04-23 22:24:36 +02:00
Sid 3799d20d43
Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
Sid d61db732da
Enable Ruff SLOT rules (#115043) 2024-04-09 18:57:27 -10:00
J. Nick Koston f527fd0947
Improve error reporting when an integration tries to create a task in a thread (#115307) 2024-04-09 11:11:22 -10:00
Sid cbbadf6256
Enable Ruff PYI036 (#115228) 2024-04-08 08:47:03 -10:00
Sid 025c6f5e2e
Add `__slots__` to NodeClass classes (#115079)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-04-08 08:44:18 -10:00
Marc Mueller a0e6fd6ec5
Add improved typing for event fire and listen methods (#114906)
* Add EventType implementation

* Update integrations for EventType

* Change state_changed to EventType

* Fix tests

* Remove runtime impact

* Add tests

* Move to stub file

* Apply pre-commit to stub files

* Fix ruff PYI checks

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-04-07 13:28:24 -10:00
Sid 8e98ba7312
Add first batch of Ruff PYI rules (#115100)
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-04-07 11:30:50 -10:00
J. Nick Koston 164d29d4d9
Remove prepare override in HomeAssistantQueueHandler (#115064) 2024-04-06 13:53:36 -10:00
Sid 0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
Marc Mueller 816ce116bf
Remove unnecessary functools.cached_property backport (#114239) 2024-04-04 11:24:26 +02:00
J. Nick Koston 5038a035bd
Detect blocking module imports in the event loop (#114488) 2024-03-30 19:51:31 -10:00
Marc Mueller 443bfee16d
Replace partial annotations (#114177) 2024-03-28 18:33:39 +01:00
Marc Mueller 3929273b41
Allow float for int argument type [pylint plugin] (#114105) 2024-03-27 11:51:27 +01:00
Marc Mueller 1d2c2d2055
Move SignalTypes to util (#114236) 2024-03-27 08:41:44 +01:00
Franck Nijhof 2388e2dda9
Drop Python 3.11 support (#114220) 2024-03-26 12:51:14 +01:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Sid 82a60fe8ad
Enable Ruff RSE (#113695) 2024-03-18 00:40:38 +01:00
Sid 6ee273a548
Clean up unneeded ruff noqa directives (#113616) 2024-03-16 09:48:37 -10:00
Joost Lekkerkerker 05172d8e4d
Improve loops and lists (#113269)
* Enable PERF

* Enable PERF rule

* Enable PERF rule

* Don't enable flag yet
2024-03-14 10:22:20 +01:00
Marc Mueller aa16a9d707
Add empty line after module docstring (3) (#112750) 2024-03-08 20:38:34 +01:00
Marc Mueller a6b842f818
Add empty line after module docstring (2) [other] (#112738) 2024-03-08 19:16:38 +01:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
J. Nick Koston 1fb9cfe37e
Speed up the frame helper (#112562) 2024-03-06 20:54:09 -10:00
fwestenberg 385b29bdf5
Add Beaufort to wind_speed (#105795)
* Add Beaufort to wind_speed

* Add Bft to UnitOfSpeed

* Update tests with Bft

* Remove check for unit

* Fix test_deprecated_constants

* Test depricated constant Beaufort

* Fix test_unit_system.py for Beaufort

* Remove _DEPRECATED_SPEED_FEET_BEAUFORT

* Remove maxsize from lru_cache

* Update test_deprecated_constants

* Update comment

* Add missing docstring

* Apply suggestions from code review

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-03-05 14:55:59 +01:00
Marc Mueller 16b162cd07
Fix util create_eager_task typing (#111976) 2024-03-01 21:04:45 +01:00
J. Nick Koston f59268b2ee
Include filename in exception when loading a json file fails (#111802)
* Include filename in exception when loading a json file fails

* fix
2024-02-29 10:30:29 -05:00
J. Nick Koston cfe478245f
Migrate gather_with_limited_concurrency to use create_eager_task (#111565) 2024-02-26 16:31:52 -10:00
J. Nick Koston 67e356904b
Add support for eager tasks (#111425)
* Add support for eager tasks

python 3.12 supports eager tasks

reading:
https://docs.python.org/3/library/asyncio-task.html#eager-task-factory
https://github.com/python/cpython/issues/97696

There are lots of places were we are unlikely to suspend, but we might
suspend so creating a task makes sense

* reduce

* revert entity

* revert

* coverage

* coverage

* coverage

* coverage

* fix test
2024-02-26 11:36:46 -05:00
J. Nick Koston 5d421e249f
YAML loader performance improvements (#111199)
* YAML loader performance improvements

- Cache the name of the loader since we call it multiple
  times for every line

- Add a fast path for scalar tags since they are the
  most common

* Update homeassistant/util/yaml/loader.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* remove unreachable code

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-02-23 13:37:09 -05:00
Erik Montnemery 49a99559c7
Remove lru cache size limit of TemperatureConverter (#109726) 2024-02-05 20:21:04 +01:00
Marc Mueller cd0ee98dba
Use builtin TimeoutError [core + helpers] (#109684) 2024-02-05 12:09:54 +01:00
J. Nick Koston 582d6968b2
Avoid de/recode of bytes to string to bytes when writing json files (#109348) 2024-02-02 09:02:26 +01:00
J. Nick Koston 155499fafe
Load json file as binary instead of decoding to string (#109351) 2024-02-02 09:00:46 +01:00
J. Nick Koston 8afcd53af6
Restore support for packages being installed from urls with fragments (#109267) 2024-02-01 08:56:57 +01:00
Robert Resch b409933d19
Add DurationConverter (#108865)
* Add DurationConverter

* Update withings snapshots

* Add sensor test

* Fix tests

* Update snapshots after #108902 was merged
2024-01-30 23:08:12 +01:00
Joakim Plate cece117c93
Flow rate unit conversions and device class (#106077)
* Add volume flow rate conversions

* Add missing translations

* Adjust liter unit and add gallons per minute

* Adjust to min instead of m for minutes

* Add matching class for number

* Add some tests for number and sensor platform

* Add deprecated constants

* Add explicit list of flow rate for check

This reverts commit 105171af31.
2024-01-30 15:01:08 +01:00
Erik Montnemery 1cb5bbf865
Fix empty files included by !include_dir_named (#108489)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-01-20 15:12:32 +01:00
Marc Mueller afcb7a26cd
Enable strict typing for config (#108023) 2024-01-18 09:20:19 +01:00
J. Nick Koston 52e90b32df
Avoid many replace calls in find_next_time_expression_time (#108273) 2024-01-18 08:44:40 +01:00
Pedro Lamas 6cab4486f7
Fix loading empty yaml files with include_dir_named (#107853) 2024-01-16 10:23:04 +01:00
Marc Mueller a9420bf05a
Enable strict typing for ios (#107382) 2024-01-12 14:43:17 +01:00
J. Nick Koston 1e4d10efe1
Add caching to the distance calculation utility (#107626) 2024-01-08 21:51:56 -10:00
J. Nick Koston 69307374f4
Signficantly reduce executor contention during bootstrap (#107312)
* Signficantly reduce executor contention during bootstrap

At startup we have a thundering herd wanting to use the executor
to load manifiest.json. Since we know which integrations we are
about to load in each resolver step, group the manifest loads
into single executor jobs by calling async_get_integrations on
the deps of the integrations after they are resolved.

In practice this reduced the number of executor jobs
by 80% during bootstrap

* merge

* naming

* tweak

* tweak

* not enough contention to be worth it there

* refactor to avoid waiting

* refactor to avoid waiting

* tweaks

* tweaks

* tweak

* background is fine

* comment
2024-01-07 22:55:40 -05:00
J. Nick Koston 75d591593d
Remove calls to distribution and legacy zip support from package util (#107427) 2024-01-07 07:39:48 -10:00
Marc Mueller 43fa51b696
Enable strict typing for blueprint (#106887) 2024-01-02 20:48:51 +01:00
Erik Montnemery 8f9bd75a36
Enable strict typing of date_time (#106868)
* Enable strict typing of date_time

* Fix parse_datetime

* Add test

* Add comments

* Update tests/util/test_dt.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

---------

Co-authored-by: G Johansson <goran.johansson@shiftit.se>
2024-01-02 13:57:25 +01:00
J. Nick Koston a4f0c84457
Reduce duplicate code in json_loads (#106859) 2024-01-01 20:25:23 -10:00
Ville Skyttä 24b1e01d71
Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
2023-12-20 23:55:09 +01:00
Erik Montnemery 0c2485bc03
Freeze integration entity descriptions (#105984)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-18 16:28:13 -10:00
Marc Mueller b671de8942
Improve logging util typing (#105968) 2023-12-18 14:54:12 +01:00
Marc Mueller aac02d7b84
Add first TypeVarTuple annotations (#105379) 2023-12-18 00:38:07 +01:00
J. Nick Koston 47f8e08261
Reduce overhead to connect dispatcher (#105715)
Reduce overhead connect dispatcher

- We tend to have 1000s (or 10000s) of connected dispatchers which
  makes these prime targets to reduce overhead/memory

- Instead of creating new functions to wrap log exceptions each time
  use partials which reuses the function body and only create new
  arguments

Previous optimizations #103307 #93602
2023-12-16 10:16:58 +01:00
Erik Montnemery 22c3847c0e
Allow inheriting `FrozenOrThawed` with custom init (#105624) 2023-12-13 10:13:34 +01:00
Erik Montnemery 5bd0833f49
Improve FrozenOrThawed (#105541) 2023-12-12 21:19:41 +01:00
Erik Montnemery d4cf049016
Remove unneeded class _EntityDescriptionBase (#105518) 2023-12-11 23:10:11 +01:00
Erik Montnemery dd338799d4
Make it possible to inherit EntityDescription in frozen and mutable dataclasses (#105211) 2023-12-11 20:00:55 +01:00
vexofp 885410bcfc
Prevent duplicate default SSLContext instances (#105348)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-09 11:30:12 -10:00
Erik Montnemery af715a4b9a
Add workaround for orjson not handling subclasses of str (#105314)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-12-08 18:13:34 +01:00
Erik Montnemery 5b55c7da5f
Remove logic converting empty or falsy YAML to empty dict (#103912)
* Correct logic converting empty YAML to empty dict

* Modify according to github comments

* Add load_yaml_dict helper

* Update check_config script

* Update tests
2023-12-05 18:08:11 +01:00
Erik Montnemery 5b59e043fa
Don't use deprecated_class decorator on deprecated YAML classes (#105063) 2023-12-05 11:36:26 +01:00
Erik Montnemery ae002e2f38
Remove breaks_in_ha_version from deprecated YAML classes (#105062) 2023-12-05 10:48:31 +01:00
Jan Bouwhuis e8475b9b33
Add scaling utils for brightness and fanspeed (#104753)
Co-authored-by: Robert Resch <robert@resch.dev>
2023-12-04 12:10:58 +01:00
Erik Montnemery db51a8e1f7
Allow passing breaks_in_ha_version to deprecation helper decorators (#104985) 2023-12-04 11:52:10 +01:00
J. Nick Koston 67039e0f26
Remove monotonic_time_coarse datetime helper (#104892) 2023-12-04 09:10:13 +01:00
Niccolò Maggioni 0232c8dcb0
Add temperature to the light color mode parameter fallbacks (#86026)
* Add color temperature to the color mode fallbacks

* Manually add ATTR_COLOR_TEMP since ATTR_COLOR_TEMP_KELVIN is pre-parsed

* Include the legacy ATTR_COLOR_TEMP attribute in the tests

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Add citation for McCamy's approximation formula

If still existing, also see page 3 of https://www.st.com/resource/en/application_note/an5638-how-correlated-color-temperature-is-calculated-by-vd6283-stmicroelectronics.pdf

* Update homeassistant/util/color.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-12-01 08:26:07 +01:00
Erik Montnemery 00e57ab9a4
Use deprecated_class decorator in deprecated YAML loader classes (#104835) 2023-11-30 22:43:34 +01:00
Erik Montnemery abc05451a2
Restore renamed yaml loader classes and warn when used (#104818) 2023-11-30 18:14:48 +01:00
Erik Montnemery 12902b8a68
Add NodeStrClass.__voluptuous_compile__ (#104808) 2023-11-30 17:45:27 +01:00
Aarni Koskela 706add4a57
Switch formatting from black to ruff-format (#102893)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
Erik Montnemery 88698d8dfe
Fix docstring in yaml util (#104240) 2023-11-20 11:34:14 +01:00
J. Nick Koston cc31d77205
Use ulid_now instead of ulid_at_timestamp if no timestamp is passed (#104226)
* Use ulid_now instead of ulid_at_timestamp if no timestamp is passed

ulid_now is slightly faster than ulid_at_timestamp

* tweak usage
2023-11-19 22:27:24 -05:00
Erik Montnemery f89194784d
Fix including yaml files with scalar values (#103914) 2023-11-13 15:23:50 +01:00
Erik Montnemery e49f6b41ee
Rename YAML loader classes (#103609) 2023-11-08 00:26:54 +01:00
Erik Montnemery c29b0cd05b
Correct line numbers in yaml node annotations (#103605) 2023-11-07 23:22:23 +01:00
Erik Montnemery 05deae09fc
Add file and line annotation to strings when loading yaml (#103586) 2023-11-07 17:10:15 +01:00