Skip to content

Commit d20874c

Browse files
[core] chore: update types for support python 3.9
1 parent acb9cbb commit d20874c

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

libs/core/garf_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = '0.1.4'
15+
__version__ = '0.1.4.post1'

libs/core/garf_core/api_clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def from_csv(cls, file_location: str | os.PathLike[str]) -> FakeApiClient:
155155
{key: _field_converter(value) for key, value in row.items()}
156156
)
157157
return FakeApiClient(data)
158-
except FileNotFoundError as e:
158+
except (AttributeError, FileNotFoundError) as e:
159159
raise GarfApiError(f'Failed to open {file_location}') from e
160160

161161

libs/core/garf_core/query_editor.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,18 @@
2525
import jinja2
2626
import pydantic
2727
from dateutil import relativedelta
28-
from typing_extensions import Self
28+
from typing_extensions import Self, TypeAlias
2929

3030
from garf_core import exceptions
3131

32-
QueryParameters = dict[str, Union[str | float | int]]
32+
QueryParameters: TypeAlias = dict[str, Union[str, float, int]]
3333

3434

3535
class GarfQueryParameters(pydantic.BaseModel):
3636
"""Parameters for dynamically changing text of a query."""
3737

38-
macro: QueryParameters | None = None
39-
template: QueryParameters | None = None
40-
41-
def model_post_init(self, __context__) -> None:
42-
if self.macro is None:
43-
self.macro = {}
44-
if self.template is None:
45-
self.template = {}
38+
macro: QueryParameters = pydantic.Field(default_factory=dict)
39+
template: QueryParameters = pydantic.Field(default_factory=dict)
4640

4741

4842
class GarfQueryError(exceptions.GarfError):

libs/core/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ dependencies = [
1111
"requests",
1212
"pyyaml",
1313
"pydantic",
14+
"eval_type_backport",
1415
]
1516
authors = [
1617
{name = "Google Inc. (gTech gPS CSE team)", email = "no-reply@google.com"},
1718
{name = "Andrei Markin", email = "andrey.markin.ppc@gmail.com"},
1819
]
19-
requires-python = ">=3.8"
20+
requires-python = ">=3.9"
2021
description = "Abstracts fetching data from API based on provided SQL-like query."
2122
readme = "README.md"
2223
license = {text = "Apache 2.0"}
2324
classifiers = [
2425
"Programming Language :: Python :: 3 :: Only",
25-
"Programming Language :: Python :: 3.8",
2626
"Programming Language :: Python :: 3.9",
2727
"Programming Language :: Python :: 3.10",
2828
"Programming Language :: Python :: 3.11",

0 commit comments

Comments
 (0)