Commit Graph

362 Commits (65a5244d5a642f993cb6da11dea92eb68b13cce3)

Author SHA1 Message Date
Ville Skyttä ca936d0b38
Replace bandit with ruff (#93200) 2023-06-08 22:46:04 +02:00
leranp 4a3f341444
Language codes for Hebrew (#93681)
* Language codes for Hebrew

There is 2 optional code for Hebrew:
he-IL is the new code
iw-IL is the old code , the google cloud STT for example is using the old code (iw)

* Update language.py

* Update test_language.py

* Update test_language.py

* Update test_language.py

* Simplify duplicate language check

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-05-30 22:27:32 -04:00
J. Nick Koston 2f1f32f0bb
Make unit converter use a factory to avoid looking up the ratios each conversion (#93706) 2023-05-29 20:50:40 +02:00
Erik Montnemery 9a70f47049
Teach UnitlessRatioConverter about ppm and ppb (#92989) 2023-05-12 16:46:37 +02:00
Michael Hansen 5d6ccd6a32
Allow "no" to match "nb" in language util (#92862)
* Allow "no" to match "nb"

* Adjust comparison for speed
2023-05-09 13:46:57 -05:00
Michael Hansen b4bd3b97f8
Use order in preferred regions list (#91959)
* Use order in preferred regions list

* Use float for score (inf = exact match)
2023-04-24 14:12:38 -04:00
Michael Hansen 5075281add
Fix zh Hant/Hans (#91390)
* Fix zh Hant/Hans

* Fix comments
2023-04-24 16:55:08 +02:00
Michael Hansen 9fdc794b36
Prefer country over language family + MATCH_ALL (#91753)
* Prefer country over language family

* More test fixes
2023-04-20 13:55:26 -04:00
Michael 67c4de90f3
Add option to select list of accepted ssl ciphers in httpx client (#91389) 2023-04-15 09:32:30 -10:00
Michael Hansen f0c625b2ad
Add language util (#91290)
* Add language util

* Add no match tests

* Update tests/util/test_language.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-04-12 20:27:09 -05:00
Erik Montnemery ead88cc3f8
Add preferred wind speed unit to unit systems (#90504)
* Add preferred wind speed unit to unit systems

* Tweak

* Update tests
2023-03-30 12:54:12 +02:00
epenet ab4a726e6c
Add tmpdir to known fixtures in pylint (#89844) 2023-03-17 10:22:02 +01:00
epenet a0f725dfcb
Add type hints to tests (#89497) 2023-03-10 12:06:50 +01:00
epenet ed3cdd8fb9
Fix lingering task in timeout test (#88953) 2023-03-01 09:42:55 +01:00
epenet aa20c902db
Add typed helpers and improve type hints in util/json (#88534)
* Add type hints to load_json

* Adjust ios

* Adjust nest

* Add use of load_json_array

* Add tests

* Adjust test patch

* Add test_load_json_os_error
2023-02-22 10:09:28 +01:00
J. Nick Koston 5bc0636905
Replace fire_coroutine_threadsafe with asyncio.run_coroutine_threadsafe (#88572)
fire_coroutine_threadsafe did not hold a reference to the asyncio
task which meant the task had the risk of being prematurely
garbage collected
2023-02-21 21:16:18 -05:00
epenet a51cc75f03
Add type hints to core tests (part 2) (#88492) 2023-02-21 09:27:13 +01:00
Jan Bouwhuis 4f6a25b470
Allow parameterizing YAML config in tests (#87981)
* Add fixture to parameterize yaml config

* Apply to more tests

* Re-add @fixture label

* Add fixtures to patch yaml content and targets

* Typo

* Improve docstr

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

* Update references to mock_yaml_configuration

* Apply new fixtures

* Apply to check_config tests

* Follow up comments

* Rename fixtures, update docstr

* Split paths

* Patch load_yaml_config_file instead

* sort

* Fix tests

* improve docst

* Rename fixtures

* sorting

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

* Improve docstr

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

* Improve docstr

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

* Improve docstr

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

* Improve docstr

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

* Improve docstr

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

* Improve docstr

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

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-02-20 16:57:12 +01:00
epenet 5f25b71df7
Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00
Franck Nijhof 1e05697080
Enable Ruff B007 (#88356)
* Enable Ruff B007

* Adjust existing cases
2023-02-17 21:08:18 -05:00
epenet 3873484849
Refactor json tests to align with new code (#88247)
* Refactor json tests to align with new code

* Use tmp_path
2023-02-16 21:34:19 +01:00
epenet 8c821c8969
Add JSON support to load_fixture (#88076)
* Add JSON support to load_fixture

* More tests

* Remove lru_cache on load_json
2023-02-16 19:40:47 +01:00
J. Nick Koston c79157208b
Add python 3.11 to the CI (#88038)
* Remove profiler.memory service

guppy3 is not python3.11 compat
https://github.com/zhuyifei1999/guppy3/issues/41

This service will return if and when guppy3 becomes
python3.11 compat

* squash

* temp remove

* temp dump tests

* temp dump tests

* drop a few more to get a run

* drop a few more to get a run

* Account for changed python3.11 enum.IntFlag behavior in zha

There may be additional changes needed, but I could only
see what needed to be updated based on the tests

* merge

* restore

* restore

* legacy value

* tweak a bit for the python 3.11 timings

* block cchardet

* conditional

* adjust est

* test

* not yet

* tweak

* give a little leeway for timing

* Fix otbr tests

* Increase database test timeout

It looks like we need a little more time to run
with the addiitonal tests in #87019

* Increase database test timeout

It looks like we need a little more time to run
with the addiitonal tests in #87019

* Fix aprs tests with python 3.11

* merge fix

* hints

* Update homeassistant/package_constraints.txt

* Update script/gen_requirements_all.py

* Constrain uamqp for Python 3.10 only

* Bump vulcan-api to 2.3.0

see https://github.com/kapi2289/vulcan-api/pull/126
see https://github.com/home-assistant/core/pull/88038
see https://github.com/home-assistant/docker/pull/260

* add ban

* Bump python-matter-server to 2.1.1

* revert

* Update tests/asyncio_legacy.py

---------

Co-authored-by: Erik <erik@montnemery.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
2023-02-16 12:38:32 -05:00
epenet ba23816a0c
Inverse json import logic (#88099)
* 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
Franck Nijhof f67ebcade1
Enable Ruff SIM201 (#88171) 2023-02-15 14:43:02 +01:00
Franck Nijhof ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
J. Nick Koston 0c35c6a313
Fix enum try_parse test for python3.11 (#88131) 2023-02-14 15:29:44 -06:00
J. Nick Koston 03eea7bd3f
Avoid subprocess memory copy when c library supports posix_spawn (#87958)
* use posix spawn on alpine

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy all the memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided and subprocess creation does not
get discernibly slow the larger the Home Assistant
python process grows.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* missed some

* adjust more tests

* coverage
2023-02-13 09:02:51 -05:00
Erik Montnemery 45ac8c515e
Update unit system unit conversions (#87632)
* Update unit system unit conversions

* Tweak tests
2023-02-08 10:52:54 +01:00
epenet c98b4e3204
Add typing to tests with single hass argument (2) (#87675)
* Add typing to tests with single hass argument (2)

* a few more
2023-02-08 08:51:43 +01:00
epenet 4142f0d15d
Add return type to tests without arguments (#87613)
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
epenet aa00114c2f
Add return type to async tests without arguments (#87612) 2023-02-07 10:26:56 +01:00
Franck Nijhof ca1a12898c
Enable Ruff D212 (#87347) 2023-02-03 23:08:48 +01:00
epenet 810367b757
Fix `can not` typo (#87254) 2023-02-03 11:37:16 +01:00
epenet 1225c5e97d
Add enum util (#87082)
* Add enum helper

* docstring

* Move to util

* Add use case
2023-02-01 15:00:27 +01:00
Franck Nijhof c56832bb2c
Enable Ruff SIM300 (#86793) 2023-01-30 11:03:23 +01:00
Franck Nijhof 89c0b27b42
Migrates tests to use UnitOfPressure enum (#86785) 2023-01-27 12:13:27 +01:00
epenet 561fc2d771
Remove deprecated unit system properties (#86643)
* Remove deprecated unit system properties

* Fix tests
2023-01-27 12:09:26 +01:00
Franck Nijhof 49148421cb
Migrates tests to use UnitOfSpeed enum (#86777) 2023-01-27 10:58:55 +01:00
Franck Nijhof e50a531cd9
Code styling tweaks to the tests - Part 2 (#86662)
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +01:00
SgtBatten 0ccab19d2c
Add Mega Joule as valid unit of energy (#86055)
* Add Mega joule

* Reorder valid energy types

Alphabetical

* Add Mega Joule

* Add Mega Joule as valid energy unit

* Add Mega Joule

* Add Mega Joule as a Unit of Measurement to Energy

* Update tests

* Update tests

* Update number docstring

Co-authored-by: Roving Ronin <108674933+Roving-Ronin@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-01-25 14:13:42 +01:00
epenet 64535175b1
Add missing conversion tests in unit conversion (#86434) 2023-01-23 10:11:11 +01:00
epenet 30bf0634fe
Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
epenet e1fc494b54
Add missing ratio test cases in unit conversion (#86340)
* Add missing ratio test cases in unit conversion

* Improve ratio test to check inverse
2023-01-22 16:39:45 +01:00
epenet e8d19e7c62
Ensure all unit converters are tested (#86271)
* Ensure all unit converters are tested

* Adjust

* Simplify

* Simplify

* docstring
2023-01-21 13:11:13 +01:00
Erik Montnemery f93bbd55ba
Improve logging shutdown (#85812)
* Improve logging shutdown

* Update test
2023-01-17 20:06:25 +01:00
SukramJ 005bc8994d
Add mA to SensorDeviceClass.CURRENT units (#84492)
fixes undefined
2022-12-30 13:55:14 +01:00
epenet f68a7636c5
Cleanup pytest.approx in unit conversion tests (#84810) 2022-12-30 10:16:20 +01:00
epenet 6261994fcf
Enable unit conversion for DATA_SIZE (#84699) 2022-12-29 09:58:15 +01:00
epenet 46e02ebaff
Enable unit conversion for DATA_RATE (#84698) 2022-12-28 21:49:00 +01:00