Commit Graph

29 Commits (36a0c1b5146fe094c33d8a769a251b2ade4c3042)

Author SHA1 Message Date
Erik Montnemery 8759a6a14d
Make optional arguments to frame.report kwarg only (#125062)
* Make optional arguments to frame.report kwarg only

* Update homeassistant/helpers/frame.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-09-03 17:03:36 +02:00
J. Nick Koston 475c20d529
Always do thread safety check when writing state (#118886)
* Always do thread safety check when writing state

Refactor the 3 most common places where the thread safety check
for the event loop to be inline to make the check fast enough
that we can keep it long term. While code review catches most
of the thread safety issues in core, some of them still make
it through, and new ones keep getting added. Its not possible
to catch them all with manual code review, so its worth the
tiny overhead to check each time.

Previously the check was limited to custom components
because they were the most common source of thread
safety issues.

* Always do thread safety check when writing state

Refactor the 3 most common places where the thread safety check
for the event loop to be inline to make the check fast enough
that we can keep it long term. While code review catches most
of the thread safety issues in core, some of them still make
it through, and new ones keep getting added. Its not possible
to catch them all with manual code review, so its worth the
tiny overhead to check each time.

Previously the check was limited to custom components
because they were the most common source of thread
safety issues.

* async_fire is more common than expected with ccs

* fix mock

* fix hass mocking
2024-06-05 23:41:55 -04:00
J. Nick Koston 8f94205014
Include a traceback for non-strict event loop blocking detection (#118620) 2024-06-02 06:36:25 -04:00
J. Nick Koston c368ffffd5
Add async_get_hass_or_none (#118164) 2024-05-26 13:38:46 +02:00
Marc Mueller 900b6211ef
Use PEP 695 for function annotations (2) (#117659) 2024-05-18 11:44:39 +02:00
Sid b456d97e65
Replace pylint protected-access with Ruff SLF001 (#115735) 2024-05-06 20:33:26 +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
Marc Mueller 816ce116bf
Remove unnecessary functools.cached_property backport (#114239) 2024-04-04 11:24:26 +02: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
J. Nick Koston 6421a08ba8
Avoid expensive inspect calls in config validators (#112085)
* Avoid expensive inspect calls in config validators

inspect has a performance problem https://github.com/python/cpython/issues/92041

We now avoid calling inspect unless we are going to log

* remove unused

* reduce

* get_integration_logger
2024-03-02 21:50:35 -05:00
Jan-Philipp Benecke bc6b4d01c8
Deprecate `hass.components` and log warning if used inside custom component (#111508)
* Deprecate @bind_hass and log error if used inside custom component

* Log also when accessing `hass.components`

* Log warning only when `hass.components` is used

* Change version

* Process code review
2024-02-29 12:25:46 +01:00
Erik Montnemery dce5099d92
Use loader.async_suggest_report_issue in frame helper (#101461) 2023-10-05 19:52:26 +02:00
Erik Montnemery 7e39acda37
Minor improvement of frame helper (#101387)
* Minor improvement of frame helper

* Add new custom integration for testing

* Make IntegrationFrame kw_only
2023-10-04 21:43:00 +02:00
Erik Montnemery ab2de18f8f
Refactor frame.get_integration_frame (#101322) 2023-10-03 19:21:27 +02:00
Franck Nijhof d4f69a3652
String formatting and max line length - Part 7 (#84532)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 11:18:56 +01:00
Franck Nijhof 7adb0f0ef5
Custom component -> Custom integration (#75404) 2022-07-18 22:10:22 +02:00
Marc Mueller 97af164858
Prepare for upcoming mypy update (#70800) 2022-04-26 07:41:52 -07:00
Marc Mueller eae0c75620
Make TypeVars private (2) (#68206) 2022-03-17 19:09:55 +01:00
epenet b8b4855b8e
Prevent log flooding in frame helper (#61085)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-06 15:26:31 -08:00
epenet 560546f65e
Use dataclass for DhcpServiceInfo (#60136)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-23 13:35:53 +01:00
Ville Skyttä f305d99af9
Add integration filtering and error if core options to helpers.frame.report (#60009)
Reduces some existing and upcoming boilerplate.
2021-11-20 12:53:04 +02:00
Marc Mueller 77ee72cbb9
Import Callable from collections.abc (1) (#56775) 2021-09-29 16:32:11 +02:00
Marc Mueller 6fb2e63e49
Update typing 02 (#48014) 2021-03-17 18:34:19 +01:00
tkdrob c2302784c2
Use core constants for helpers (#46240) 2021-02-08 22:53:17 +01:00
Ville Skyttä b4bac0f7a0
Exception chaining and wrapping improvements (#39320)
* Remove unnecessary exception re-wraps

* Preserve exception chains on re-raise

We slap "from cause" to almost all possible cases here. In some cases it
could conceivably be better to do "from None" if we really want to hide
the cause. However those should be in the minority, and "from cause"
should be an improvement over the corresponding raise without a "from"
in all cases anyway.

The only case where we raise from None here is in plex, where the
exception for an original invalid SSL cert is not the root cause for
failure to validate a newly fetched one.

Follow local convention on exception variable names if there is a
consistent one, otherwise `err` to match with majority of codebase.

* Fix mistaken re-wrap in homematicip_cloud/hap.py

Missed the difference between HmipConnectionError and
HmipcConnectionError.

* Do not hide original error on plex new cert validation error

Original is not the cause for the new one, but showing old in the
traceback is useful nevertheless.
2020-08-28 13:50:32 +02:00
J. Nick Koston 444df4a7d2
Use the shared zeroconf instance when attempting to create another Zeroconf instance (#38744) 2020-08-12 16:08:33 +02:00
Paulus Schoutsen f49ce5d1b4
Protect loop set default executor (#37438)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-07-06 15:58:53 -07:00
Martin Hjelmare 2a120d9045
Patch aiohttp client session close (#34769)
* Patch aiohttp client session close

* Add test

* Restore close regardless of auto_cleanup

* Close session instead of detaching and do not restore

* Delint test

* Add frame helper

* Use frame helper

* Test warning log when closing session

* Clean up

* Correct docstring

* Do not change shutdown

* Fix tests
2020-05-13 09:58:33 +02:00