Commit graph

367 commits

Author SHA1 Message Date
Franck Nijhof
95ed6fbc08
Small improvements to middleware filter ()
Small improvements middleware filter
2023-02-28 12:07:17 -05:00
epenet
ba23816a0c
Inverse json import logic ()
* Fix helpers and util

* Adjust components

* Move back errors

* Add report

* mypy

* mypy

* Assert deprecation messages

* Move test_json_loads_object

* Adjust tests

* Fix rebase

* Adjust pylint plugin

* Fix plugin

* Adjust references

* Adjust backup tests
2023-02-16 11:37:57 +01:00
Erik Montnemery
899adef590
Sort manifests 4 () 2023-02-08 20:27:05 +01:00
Franck Nijhof
ca1a12898c
Enable Ruff D212 () 2023-02-03 23:08:48 +01:00
Paulus Schoutsen
9c0856787d
Improve JSON errors from HTTP view () 2023-01-31 20:37:26 +01:00
Franck Nijhof
d4955a3d87
Replace assert False by raising an error () 2023-01-26 16:51:43 +01:00
Marc Mueller
8abce25948
Update Union typing (4) [Py310] () 2023-01-23 09:04:40 +01:00
Marc Mueller
45b4b0e990
Import ParamSpec from typing [Py310] ()
* Import ParamSpec from typing [Py310]

* Update additional imports
2023-01-23 07:28:43 +01:00
Franck Nijhof
79b52a2b41
Stricter pylint message control () 2023-01-20 13:47:55 +01:00
Mike Degatano
87aacf9fbe
Increase max line size for ingress addons () 2023-01-13 13:30:28 +01:00
Franck Nijhof
cb13418bab
String formatting and max line length - Part 2 () 2022-12-22 11:38:59 +01:00
Joakim Plate
8bd4125390
Test corrections noticed during pytest upgrade ()
* Withing trigger a call to coordinator after init

* Stop discovery task on STOP event

* Stop dsmr connection task on STOP

* Use autospec in modem_serial tests

close on AioSerial is non async, and should not be mocked as a coroutine

* Make sure responder is specced correctly

tests/components/emulated_hue/test_init.py::test_setup_works
  /Users/joakim/src/hass/home-assistant/homeassistant/components/emulated_hue/__init__.py:119: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    protocol.close()

* Don't assume Pymodbus is the only thing logging

* Use gather instead of wait

```
homeassistant/components/homeassistant/__init__.py:208: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
```

* Increase wait time for automation tests

Assuming exit within 1 seconds is unreasonable on a potentially loaded
test machine.

* Avoid changing app state after startup
2022-11-23 20:53:28 +01:00
Franck Nijhof
2b27cfdabb
Set system & entity integration types () 2022-10-04 10:36:42 -04:00
epenet
454bdcc00d
Expose http constants in root () 2022-09-12 18:41:18 +02:00
Franck Nijhof
91180923ae
Fix HTTP 404 being logged as a stack trace () 2022-07-28 16:43:32 +02:00
Marc Mueller
af7df260a0
Fix small type issues [core] () 2022-07-26 16:28:22 +02:00
Marc Mueller
b1ed1543c8
Improve http decorator typing () 2022-07-21 13:07:42 +02:00
Franck Nijhof
9a4a7e2f4d
Extend failed login message with the request URL () 2022-07-14 21:43:14 +02:00
epenet
16900dcef1
Make Store a generic class () 2022-07-09 22:32:57 +02:00
J. Nick Koston
0c29b68cf8
Switch linear search to a dict lookup for ip bans () 2022-07-07 10:57:44 +02:00
J. Nick Koston
332cf3cd2d
Resolve and caches paths for CachingStaticResource in the executor () 2022-07-06 13:49:48 -05:00
J. Nick Koston
8dfb0cb4e7
Fix SIGN_QUERY_PARAM in check in auth_middleware () 2022-07-05 21:09:33 -07:00
J. Nick Koston
8b067e83f7
Initial orjson support take 3 ()
* Initial orjson support take 2

Still need to work out problem building wheels

--

Redux of  /  Now possible since the following is solved:
 (comment)

This implements orjson where we use our default encoder.  This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently.  If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).

Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)

Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups).  I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes

If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass) and it
will fallback to `as_dict`

Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png">

* use for views as well

* handle UnicodeEncodeError

* tweak

* DRY

* DRY

* not needed

* fix tests

* Update tests/components/http/test_view.py

* Update tests/components/http/test_view.py

* black

* templates
2022-06-22 21:59:51 +02:00
Christopher Bailey
0461ec1566
Fix auth_sign_path with query params (take 2) () 2022-06-22 10:09:21 -05:00
J. Nick Koston
1e0a3246f4
Revert "Fix auth_sign_path with query params ()" () 2022-06-21 22:45:16 -05:00
Christopher Bailey
67618311fa
Fix auth_sign_path with query params ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-21 14:21:47 -05:00
Franck Nijhof
5f44d0f8f9
Clean up accessing storage.Store helper via hass () 2022-05-17 18:45:57 +02:00
Marc Mueller
93cbb331e5
Update Mypy to 0.950 ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-04-27 20:49:54 -05:00
Marc Mueller
53245c6523
Update pylint to 2.13.0 () 2022-03-25 15:14:48 -07:00
Franck Nijhof
3afadf8adb
Revert "Block peer certs on supervisor" () 2022-02-23 12:32:07 +01:00
Paulus Schoutsen
938b64081b
Block peer certs on supervisor ()
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
2022-02-22 13:59:40 -08:00
J. Nick Koston
3bf2be1765
Startup with an emergency self signed cert if the ssl certificate cannot be loaded () 2022-02-18 16:08:26 -08:00
Marc Mueller
370832f527
Fix http typing () 2022-02-14 13:40:31 +01:00
Franck Nijhof
fa09cf663e
Update black to 22.1.0 () 2022-02-05 14:19:37 +01:00
Paulus Schoutsen
63f8e437ed
Add Home Assistant Content user () 2022-01-21 10:06:39 -08:00
epenet
6f631c542c
Import hassio ()
* Import hassio

* Fix HassioAPIError

* Use relative import

* Adjust import

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-20 19:03:26 +01:00
Erik Montnemery
2eab3c8de1
Import persistent notification (part 3) () 2022-01-11 09:51:16 -08:00
epenet
40e77e2af0
Fix type hint in http register_view ()
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-04 21:25:16 -08:00
Tobias Sauerwein
2c904c0974
Bump mypy to 0.930 ()
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-12-27 17:55:17 +01:00
Paulus Schoutsen
914f7f85ec
Add local only users () 2021-11-29 14:01:03 -08:00
Simone Chemelli
5fc51130ea
Replace util.get_local_ip in favor of components.network.async_get_source_ip() - part 4 ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-11-15 09:18:57 -08:00
Paulus Schoutsen
6ef64f6b1c
Fix CORS error in emulated_hue () 2021-11-11 22:11:41 -08:00
Bram Kragten
28c07f5c43
Fix CORS ()
* Fix CORS

* rename

* Update view.py
2021-11-09 18:30:51 +01:00
Marc Mueller
4c68662612
Use assignment expressions 34 () 2021-10-31 19:01:16 +01:00
Ville Skyttä
b52c5c82b1
Use http.HTTPStatus in components/[gh]* () 2021-10-23 20:34:53 +02:00
Marc Mueller
aa7dc78a1e
Use assignment expressions 11 () 2021-10-17 20:15:48 +02:00
Ville Skyttä
cc97502a0c
Use HTTPStatus instead of HTTP_* consts in aiohttp web response statuses () 2021-10-01 09:27:44 -07:00
Marc Mueller
565a9fea6b
Import Callable from collections.abc (2) () 2021-09-29 14:06:51 +02:00
Ville Skyttä
d8d34fdd3b
Prefer HTTPStatus over int in HA view JSON functions ()
* Prefer HTTPStatus over int in HA view JSON functions

* Update zwave tests to not expect a fixed typo
2021-09-22 21:59:52 +03:00
Ruslan Sayfutdinov
7195b8222b
Bump PyJWT to 2.1.0 () 2021-09-07 20:59:02 -07:00