From d0a99846fbc1ccd93e3e436396173637556c621a Mon Sep 17 00:00:00 2001 From: "zongsi.zhang" Date: Wed, 17 Apr 2024 10:03:37 +0800 Subject: [PATCH] Solve some backward compatible issue with python 3.9 --- poetry.lock | 30 ++++++++++++++++++++++++------ pyproject.toml | 1 + wherobots/db/constants.py | 3 ++- wherobots/db/cursor.py | 12 ++++++------ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9a233d5..3530f55 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "black" @@ -505,6 +505,7 @@ optional = false python-versions = ">=3.9" files = [ {file = "pandas-2.2.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:90c6fca2acf139569e74e8781709dccb6fe25940488755716d1d354d6bc58bce"}, + {file = "pandas-2.2.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c7adfc142dac335d8c1e0dcbd37eb8617eac386596eb9e1a1b77791cf2498238"}, {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4abfe0be0d7221be4f12552995e58723c7422c80a659da13ca382697de830c08"}, {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8635c16bf3d99040fdf3ca3db669a7250ddf49c55dc4aa8fe0ae0fa8d6dcc1f0"}, {file = "pandas-2.2.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:40ae1dffb3967a52203105a077415a86044a2bea011b5f321c6aa64b379a3f51"}, @@ -525,6 +526,7 @@ files = [ {file = "pandas-2.2.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:43498c0bdb43d55cb162cdc8c06fac328ccb5d2eabe3cadeb3529ae6f0517c32"}, {file = "pandas-2.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:d187d355ecec3629624fccb01d104da7d7f391db0311145817525281e2804d23"}, {file = "pandas-2.2.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0ca6377b8fca51815f382bd0b697a0814c8bda55115678cbc94c30aacbb6eff2"}, + {file = "pandas-2.2.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9057e6aa78a584bc93a13f0a9bf7e753a5e9770a30b4d758b8d5f2a62a9433cd"}, {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:001910ad31abc7bf06f49dcc903755d2f7f3a9186c0c040b827e522e9cef0863"}, {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66b479b0bd07204e37583c191535505410daa8df638fd8e75ae1b383851fe921"}, {file = "pandas-2.2.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a77e9d1c386196879aa5eb712e77461aaee433e54c68cf253053a73b7e49c33a"}, @@ -863,6 +865,22 @@ files = [ {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] +[[package]] +name = "strenum" +version = "0.4.15" +description = "An Enum that inherits from str." +optional = false +python-versions = "*" +files = [ + {file = "StrEnum-0.4.15-py3-none-any.whl", hash = "sha256:a30cda4af7cc6b5bf52c8055bc4bf4b2b6b14a93b574626da33df53cf7740659"}, + {file = "StrEnum-0.4.15.tar.gz", hash = "sha256:878fb5ab705442070e4dd1929bb5e2249511c0bcf2b0eeacf3bcd80875c82eff"}, +] + +[package.extras] +docs = ["myst-parser[linkify]", "sphinx", "sphinx-rtd-theme"] +release = ["twine"] +test = ["pylint", "pytest", "pytest-black", "pytest-cov", "pytest-pylint"] + [[package]] name = "tenacity" version = "8.2.3" @@ -929,13 +947,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.25.1" +version = "20.25.2" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, - {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, + {file = "virtualenv-20.25.2-py3-none-any.whl", hash = "sha256:6e1281a57849c8a54da89ba82e5eb7c8937b9d057ff01aaf5bc9afaa3552e90f"}, + {file = "virtualenv-20.25.2.tar.gz", hash = "sha256:fa7edb8428620518010928242ec17aa7132ae435319c29c1651d1cf4c4173aad"}, ] [package.dependencies] @@ -944,7 +962,7 @@ filelock = ">=3.12.2,<4" platformdirs = ">=3.9.1,<5" [package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] [[package]] @@ -1031,4 +1049,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "59a5c5f32cf98a8d05abf7ed659b93ad92be038237278aec2dc39320ee5dc97e" +content-hash = "13b61de257c4d99758eb4ef886b63d1e38a44d69480a5c7d949301751d9dc6a6" diff --git a/pyproject.toml b/pyproject.toml index a915635..3106ee8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ tenacity = "^8.2.3" pyarrow = "^15.0.2" cbor2 = "^5.6.3" pandas = "^2.2.2" +StrEnum = "^0.4.15" [tool.poetry.group.dev.dependencies] mypy = "^1.8.0" diff --git a/wherobots/db/constants.py b/wherobots/db/constants.py index 6e07aa7..04123fb 100644 --- a/wherobots/db/constants.py +++ b/wherobots/db/constants.py @@ -1,4 +1,5 @@ -from enum import StrEnum, auto +from enum import auto +from strenum import StrEnum from .region import Region from .runtime import Runtime diff --git a/wherobots/db/cursor.py b/wherobots/db/cursor.py index 266da35..10490f4 100644 --- a/wherobots/db/cursor.py +++ b/wherobots/db/cursor.py @@ -1,5 +1,5 @@ import queue -from typing import Any +from typing import Any, Optional from .errors import ProgrammingError, DatabaseError @@ -11,20 +11,20 @@ def __init__(self, exec_fn, cancel_fn): self.__cancel_fn = cancel_fn self.__queue: queue.Queue = queue.Queue() - self.__results: list[Any] | None = None - self.__current_execution_id: str | None = None + self.__results: Optional[list[Any]] = None + self.__current_execution_id: Optional[str] = None self.__current_row: int = 0 # Description and row count are set by the last executed operation. # Their default values are defined by PEP-0249. - self.__description: str | None = None + self.__description: Optional[str] = None self.__rowcount: int = -1 # Array-size is also defined by PEP-0249 and is expected to be read/writable. self.arraysize: int = 1 @property - def description(self) -> str | None: + def description(self) -> Optional[str]: return self.__description @property @@ -34,7 +34,7 @@ def rowcount(self) -> int: def __on_execution_result(self, result) -> None: self.__queue.put(result) - def __get_results(self) -> list[Any] | None: + def __get_results(self) -> Optional[list[Any]]: if not self.__current_execution_id: raise ProgrammingError("No query has been executed yet") if self.__results is not None: