Franck Nijhof
3e85a29b86
Move overlapping pylint rules to ruff, disable mypy overlap ( #94359 )
2023-06-27 17:42:46 +02:00
Jesse Moody
c4ee35570d
Update django github references to main instead of master branch. ( #89951 )
2023-03-20 10:27:55 +01:00
J. Nick Koston
ea356ad260
Optimize fetching weekly/monthly/yearly statistics ( #87747 )
...
* Optimize fetching statistics
* speed up
* avoid double groupby
* avoid another loop
* tweak flow
* fixes
* tweak
* avoid a new dt object in the cache for week/month
* avoid a new dt object in the cache for week/month
2023-02-09 21:22:32 -05:00
Franck Nijhof
7adb8d5ddc
Code styling tweaks to core utils & YAML loader ( #85433 )
...
Code styling tweaks to core utils
2023-01-08 22:01:55 -08:00
J. Nick Koston
d81febd3f4
Small speed up to frequently called datetime functions ( #85399 )
2023-01-08 09:42:29 -10:00
J. Nick Koston
1589c06203
Significantly reduce clock_gettime syscalls on platforms with broken vdso ( #81257 )
2022-10-31 09:35:08 -04:00
Kevin Stillhammer
90e5d69184
Add template as_timedelta ( #71801 )
2022-05-23 19:32:22 +02:00
J. Nick Koston
4e9bc9eaff
Small cleanups to find_next_time_expression and addition of tests ( #71845 )
2022-05-14 12:13:32 -07:00
J. Nick Koston
ebce5660e3
Sync event timed_fired and the context ulid time ( #71854 )
2022-05-14 12:12:08 -07:00
Marc Mueller
d8f167bbac
Remove `backports.zoneinfo` dependency ( #65069 )
2022-01-27 09:59:27 -08:00
Marvin Wichmann
707fe67c00
Move StrEnum to homeassistant.backports and move Platform to homeassistant.const ( #60880 )
...
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-12-03 09:31:17 +01:00
Franck Nijhof
c8b0a3b667
Revert "Move Platform StrEnum to const" ( #60875 )
2021-12-02 14:19:08 -08:00
Franck Nijhof
6e220d5d17
Move Platform StrEnum to const ( #60857 )
2021-12-02 22:30:52 +01:00
J. Nick Koston
1cd9be7538
Fix recursive limit in find_next_time_expression_time ( #58914 )
...
* Fix recursive limit in find_next_time_expression_time
* Add test case
* Update test_event.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-02 00:11:17 +01:00
Otto Winter
a9c0f89c09
Fix find_next_time_expression_time ( #58894 )
...
* Better tests
* Fix find_next_time_expression_time
* Add tests for Nov 7th 2021, Chicago transtion
* Update event tests
* Update test_event.py
* small performance improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-01 17:45:13 +01:00
Marc Mueller
7af67d34cf
Use assignment expressions 01 ( #56394 )
2021-09-18 13:31:35 -10:00
Daniel Hjelseth Høyer
fbad453c89
Pylint 2.9.3 ( #52972 )
...
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-07-14 21:44:57 -07:00
Erik Montnemery
15e2c6d7dc
Fix typing for dt_util as_timestamp ( #50886 )
...
* Fix typing for dt_util::as_timestamp
* Apply suggestions from code review
2021-05-22 09:34:49 +02:00
Ruslan Sayfutdinov
de5472403b
Use mypy-friendly conditional import for zoneinfo ( #50444 )
2021-05-13 22:36:49 -07:00
Paul Ganssle
efa5c59559
Replace hand-rolled binary search with bisect_left ( #50410 )
...
The `bisect` module exposes a `bisect_left` function which does
basically what the bulk of `_lower_bound` does. From my tests, it is
slightly faster (~5%) in the probably common ideal case where `arr` is short.
In the worst case scenario, `bisect.bisect_left` is *much* faster.
```
>>> arr = list(range(60))
>>> cmp = 59
>>> %timeit _lower_bound(arr, cmp)
736 ns ± 6.24 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
>>> %timeit bisect_lower_bound(arr, cmp)
290 ns ± 7.77 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
```
I doubt this is a huge bottleneck or anything, but I think it's a bit
more readable, and it's more efficient, so it seems like it's mostly a
win.
This commit *will* add a new unconditional import for `bisect` when
importing `util.dt`, and `bisect` is not currently imported for any of
the standard library modules. It is possible to make this conditional by
placing `import bisect` in the _lower_bound function, or in the function
it's nested in.
2021-05-11 08:18:20 -07:00
Paulus Schoutsen
f8584c3ded
Use zoneinfo instead of dateutil ( #50387 )
...
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-05-10 08:32:29 -07:00
J. Nick Koston
bf2d40adfe
Migrate from pytz to python-dateutil ( #49643 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-07 22:46:26 -07:00
Franck Nijhof
6932cf9534
Use contextlib.suppress where possible ( #48189 )
2021-03-23 14:36:43 +01:00
Franck Nijhof
8a56dbf587
Add flake8 comprehensions checks to pre-commit & CI ( #48111 )
2021-03-19 13:41:09 +01:00
Marc Mueller
fabd73f08b
Update typing 03 ( #48015 )
2021-03-17 21:46:07 +01:00
Paulus Schoutsen
edf70e9f06
Make input_datetime better handle timezones ( #43396 )
...
* Make input_datetime better handle timezones
* Improve test coverage
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Revert change to time format
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-11-26 20:20:10 +01:00
J. Nick Koston
a9de9c62f1
Use native utc timezone for utcnow() ( #41727 )
...
This allows timezone operations to happen in C code instead
of the pure-python code of pytz
2020-10-12 17:43:21 -05:00
Dmitry
b106149588
Fix string parameter processing in parse_time_expression ( #41468 ) ( #41469 )
2020-10-09 11:48:49 +02:00
J. Nick Koston
42227c1c53
Improve the performance of dt_util.utcnow() ( #39145 )
2020-08-23 09:57:58 +02:00
Jelle Raaijmakers
ef254a1c3d
Round time values in get_age() to better approximate the actual age ( #37125 )
2020-07-09 11:19:38 -07:00
Ville Skyttä
b4404b071f
Pylint cleanups ( #35409 )
...
* Avoid some outer name redefinitions
* Remove unneeded directives
* Narrow directive scope
* Don't disable redefined-variable-type
2020-05-09 14:08:40 +03:00
Franck Nijhof
71a47fc80c
Enable pylint global-statement ( #33641 )
2020-04-04 20:10:55 +02:00
Ruslan Sayfutdinov
15b4975681
Use ciso8601 library to parse datetime faster ( #32128 )
2020-02-24 08:33:10 -08:00
Ville Skyttä
fa4fa30461
Various string cleanups ( #30435 )
...
* Remove some unnecessary string concatenations
* Replace some simple str.formats with f-strings
* Replace some string concatenations with f-strings
2020-01-03 14:47:06 +01:00
Ville Skyttä
e6388e186c
Remove unnecessary string literal concatenations ( #30360 )
2020-01-02 21:17:10 +02:00
Bas Nijholt
67c56c860d
Sort imports according to PEP8 for 'homeassistant' folder ( #29789 )
...
Components are already done
2019-12-09 16:42:10 +01:00
Ville Skyttä
761d7f21e9
Upgrade pylint ( #27279 )
...
* Upgrade pylint to 2.4.2 and astroid to 2.3.1
https://pylint.readthedocs.io/en/latest/whatsnew/2.4.html
https://pylint.readthedocs.io/en/latest/whatsnew/changelog.html#what-s-new-in-pylint-2-4-1
https://pylint.readthedocs.io/en/latest/whatsnew/changelog.html#what-s-new-in-pylint-2-4-2
* unnecessary-comprehension fixes
* invalid-name fixes
* self-assigning-variable fixes
* Re-enable not-an-iterable
* used-before-assignment fix
* invalid-overridden-method fixes
* undefined-variable __class__ workarounds
https://github.com/PyCQA/pylint/issues/3090
* no-member false positive disabling
* Remove some no longer needed disables
* using-constant-test fix
* Disable import-outside-toplevel for now
* Disable some apparent no-value-for-parameter false positives
* invalid-overridden-method false positive disables
https://github.com/PyCQA/pylint/issues/3150
* Fix unintentional Entity.force_update override in AfterShipSensor
2019-10-07 08:17:39 -07:00
Franck Nijhof
2f0eb07624
Migrate legacy typehints in core to PEP-526 ( #26403 )
...
* Migrate legacy typehints in core to PEP-526
* Fix one type
2019-09-03 20:36:04 -07:00
Franck Nijhof
decf13b948
Use literal string interpolation in core (f-strings) ( #26166 )
2019-08-23 09:53:33 -07:00
Paulus Schoutsen
620cb74050
Type
2019-07-31 13:08:31 -07:00
Paulus Schoutsen
4de97abc3a
Black
2019-07-31 12:25:30 -07:00
Anders Melchiorsen
a439e087e1
Fix time expression parsing ( #24696 )
2019-06-22 13:39:33 +02:00
Otto Winter
26cf5acd5b
Make async_track_time_change smarter ( #17199 )
...
* Make async_track_time_change smarter
* Move to util/dt
* Remove unnecessary check
* Lint
* Remove tzinfo check
* Remove check
* Add comment about async_track_point_in_utc_time
* Fix typing check
* Lint
2018-10-09 10:14:18 +02:00
Ville Skyttä
ee696643cd
Isort preparations ( #16555 )
...
* Don't treat typing as an "in-between" module for import order
That was a < 3.5 era thing.
* Tighten scope of some pylint unused-import disables
To avoid isort moving a top level one around, undesirably broadening its
scope.
2018-09-11 11:21:48 +02:00
Ville Skyttä
3800f00564
Disable assuming Optional type for values with None default ( #16029 )
...
https://www.python.org/dev/peps/pep-0484/#union-types
"Type checkers should move towards requiring the optional type to be
made explicit."
2018-08-17 20:22:49 +02:00
Ville Skyttä
eee9b50b70
Upgrade pylint to 2.0.1 ( #15683 )
...
* Upgrade pylint to 2.0.1
* Pylint 2 bad-whitespace fix
* Pylint 2 possibly-unused-variable fixes
* Pylint 2 try-except-raise fixes
* Disable pylint fixme for todoist for now
https://github.com/PyCQA/pylint/pull/2320
* Disable pylint 2 useless-return for now
https://github.com/PyCQA/pylint/issues/2300
* Disable pylint 2 invalid-name for type variables for now
https://github.com/PyCQA/pylint/issues/1290
* Disable pylint 2 not-an-iterable for now
https://github.com/PyCQA/pylint/issues/2311
* Pylint 2 unsubscriptable-object workarounds
* Disable intentional pylint 2 assignment-from-nones
* Disable pylint 2 unsupported-membership-test apparent false positives
* Disable pylint 2 assignment-from-no-return apparent false positives
* Disable pylint 2 comparison-with-callable false positives
https://github.com/PyCQA/pylint/issues/2306
2018-07-26 08:55:42 +02:00
Andrey
140a874917
Add typing to homeassistant/*.py and homeassistant/util/ ( #15569 )
...
* Add typing to homeassistant/*.py and homeassistant/util/
* Fix wrong merge
* Restore iterable in OrderedSet
* Fix tests
2018-07-23 10:24:39 +02:00
Ville Skyttä
b7c336a687
Pylint cleanups ( #15626 )
...
* Pylint 2 no-else-return fixes
* Remove unneeded abstract-class-not-used pylint disable
2018-07-23 10:16:05 +02:00
Andrey
c2fe0d0120
Make typing checks more strict ( #14429 )
...
## Description:
Make typing checks more strict: add `--strict-optional` flag that forbids implicit None return type. This flag will become default in the next version of mypy (0.600)
Add `homeassistant/util/` to checked dirs.
## Checklist:
- [x] The code change is tested and works locally.
- [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
2018-07-13 13:24:51 +03:00
Ville Skyttä
b92350fb55
Lint cleanup ( #15103 )
...
* Remove unneeded inline pylint disables
* Remove unneeded noqa's
* Use symbol names instead of message ids in inline pylint disables
2018-06-25 13:05:07 -04:00