From ac9e0fec988052eecbac6a6461f740666d87927b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:49:36 +0200 Subject: [PATCH 1/5] Update pydantic requirement from <1.10.0,>=1.8.2 to >=1.8.2,<1.11.0 (#251) Updates the requirements on [pydantic](https://github.com/pydantic/pydantic) to permit the latest version. - [Release notes](https://github.com/pydantic/pydantic/releases) - [Changelog](https://github.com/pydantic/pydantic/blob/main/HISTORY.md) - [Commits](https://github.com/pydantic/pydantic/compare/v1.8.2...v1.10.0) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 253dda9..f67fbed 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ "pytz>=2021.1,<2023.0", "tzlocal>=2.1,<5.0", "deprecation~=2.1.0", - "pydantic>=1.8.2,<1.10.0", + "pydantic>=1.8.2,<1.11.0", ], classifiers=[ "Programming Language :: Python :: 3", From 7bcba832c950cf16e87410654449556844ac5911 Mon Sep 17 00:00:00 2001 From: Marcel Vriend <92307684+marcelvriend@users.noreply.github.com> Date: Mon, 19 Sep 2022 18:56:48 +0200 Subject: [PATCH 2/5] Fix tzlocal dependency causing an exception (#250) --- pygrocy/utils.py | 12 ++---------- setup.py | 4 +--- test/test_utils.py | 45 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/pygrocy/utils.py b/pygrocy/utils.py index 4e85a91..e139f5f 100644 --- a/pygrocy/utils.py +++ b/pygrocy/utils.py @@ -1,14 +1,10 @@ from datetime import datetime -import iso8601 -import pytz -from tzlocal import get_localzone - def parse_date(input_value): if input_value == "" or input_value is None: return None - return iso8601.parse_date(input_value) + return datetime.fromisoformat(input_value) def parse_int(input_value, default_value=None): @@ -40,8 +36,4 @@ def parse_bool_int(input_value): def localize_datetime(timestamp: datetime) -> datetime: - if timestamp.tzinfo is not None: - return timestamp - - local_tz = get_localzone() - return local_tz.localize(timestamp).astimezone(pytz.utc) + return timestamp.astimezone() diff --git a/setup.py b/setup.py index f67fbed..0a77d3c 100644 --- a/setup.py +++ b/setup.py @@ -16,9 +16,7 @@ packages=setuptools.find_packages(), install_requires=[ "requests", - "iso8601>=0.1.16,<1.1.0", - "pytz>=2021.1,<2023.0", - "tzlocal>=2.1,<5.0", + "backports.zoneinfo", # backports can be removed when python 3.8 support is dropped "deprecation~=2.1.0", "pydantic>=1.8.2,<1.11.0", ], diff --git a/test/test_utils.py b/test/test_utils.py index 171bf0c..06fb838 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,12 +1,17 @@ from datetime import datetime -from unittest import TestCase + +try: + import zoneinfo +except ImportError: + # backports can be removed when python 3.8 support is dropped + from backports import zoneinfo import pygrocy.utils as utils -class TestUtils(TestCase): +class TestUtils: def test_parse_date_valid(self): - date_str = "2019-05-04T11:31:04.563Z" + date_str = "2022-07-10 21:10:53" date_obj = utils.parse_date(date_str) assert isinstance(date_obj, datetime) @@ -58,3 +63,37 @@ def test_parse_float_error(self): float_number = utils.parse_float(float_str, -1) assert float_number == -1 + + def test_localize_datetime_input_timezone_unaware(self): + date = datetime(2022, 7, 10, 21, 17, 34, 633809, tzinfo=None) + + localized_datetime = utils.localize_datetime(date) + + assert localized_datetime == datetime( + 2022, 7, 10, 21, 17, 34, 633809, tzinfo=zoneinfo.ZoneInfo("localtime") + ) + + def test_localize_datetime_input_timezone_aware(self): + date = datetime( + 2022, + 7, + 10, + 13, + 17, + 34, + 633809, + tzinfo=zoneinfo.ZoneInfo("America/Los_Angeles"), + ) + + localized_datetime = utils.localize_datetime(date) + + assert localized_datetime == datetime( + 2022, + 7, + 10, + 13, + 17, + 34, + 633809, + tzinfo=zoneinfo.ZoneInfo("America/Los_Angeles"), + ) From dae4107527085aa6370f3d5f089f21b40b2ee4ff Mon Sep 17 00:00:00 2001 From: Sebastian Rutofski Date: Mon, 19 Sep 2022 19:25:03 +0200 Subject: [PATCH 3/5] constrain backports.zoneinfo to py < 3.9 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0a77d3c..a30e8e4 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ packages=setuptools.find_packages(), install_requires=[ "requests", - "backports.zoneinfo", # backports can be removed when python 3.8 support is dropped + "backports.zoneinfo;python_version<'3.9'", # backports can be removed when python 3.8 support is dropped "deprecation~=2.1.0", "pydantic>=1.8.2,<1.11.0", ], From a0d621cedce17e5f8a72ebba585e847a305e57a5 Mon Sep 17 00:00:00 2001 From: Sebastian Rutofski Date: Mon, 19 Sep 2022 19:25:19 +0200 Subject: [PATCH 4/5] add stackaid.json --- stackaid.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 stackaid.json diff --git a/stackaid.json b/stackaid.json new file mode 100644 index 0000000..f31bc28 --- /dev/null +++ b/stackaid.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "dependencies": [ + { + "source": "https://github.com/psf/requests" + }, + { + "source": "https://github.com/pydantic/pydantic" + }, + { + "source": "https://github.com/tox-dev/tox" + } + ] +} \ No newline at end of file From c3c2d594b0520c3d1268055ef6a4dac7801d4dd2 Mon Sep 17 00:00:00 2001 From: Sebastian Rutofski Date: Mon, 19 Sep 2022 19:26:29 +0200 Subject: [PATCH 5/5] 1.5.0 prep --- CHANGELOG.md | 14 ++++++++++++-- setup.py | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f65f083..2c11ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,23 @@ # Changelog -## [v1.4.1](https://github.com/SebRut/pygrocy/tree/v1.4.1) (2022-07-28) +## [v1.5.0](https://github.com/SebRut/pygrocy/tree/v1.5.0) (2022-09-19) -[Full Changelog](https://github.com/SebRut/pygrocy/compare/v1.4.0...v1.4.1) +[Full Changelog](https://github.com/SebRut/pygrocy/compare/v1.4.1...v1.5.0) + +**Closed issues:** + +- Update pydantic requirements from 1.10.0 to 1.10.2 [\#252](https://github.com/SebRut/pygrocy/issues/252) **Merged pull requests:** +- Update pydantic requirement from \<1.10.0,\>=1.8.2 to \>=1.8.2,\<1.11.0 [\#251](https://github.com/SebRut/pygrocy/pull/251) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Fix tzlocal dependency causing an exception [\#250](https://github.com/SebRut/pygrocy/pull/250) ([marcelvriend](https://github.com/marcelvriend)) - Fix enabled features lookup [\#248](https://github.com/SebRut/pygrocy/pull/248) ([marcelvriend](https://github.com/marcelvriend)) +## [v1.4.1](https://github.com/SebRut/pygrocy/tree/v1.4.1) (2022-07-28) + +[Full Changelog](https://github.com/SebRut/pygrocy/compare/v1.4.0...v1.4.1) + ## [v1.4.0](https://github.com/SebRut/pygrocy/tree/v1.4.0) (2022-07-24) [Full Changelog](https://github.com/SebRut/pygrocy/compare/v1.3.0...v1.4.0) diff --git a/setup.py b/setup.py index a30e8e4..e2012f8 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pygrocy", - version="1.4.1", + version="1.5.0", author="Sebastian Rutofski", author_email="kontakt@sebastian-rutofski.de", description="",