tracktolib 0.56.0__tar.gz → 0.57.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tracktolib
3
- Version: 0.56.0
3
+ Version: 0.57.0
4
4
  Summary: Utility library for python
5
5
  License: MIT
6
6
  Keywords: utility
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tracktolib"
3
- version = "0.56.0"
3
+ version = "0.57.0"
4
4
  description = "Utility library for python"
5
5
  authors = ["Julien Brayere <julien.brayere@tracktor.fr>"]
6
6
  license = "MIT"
@@ -83,7 +83,7 @@ pythonPlatform = "Linux"
83
83
 
84
84
  [tool.commitizen]
85
85
  name = "cz_conventional_commits"
86
- version = "0.56.0"
86
+ version = "0.57.0"
87
87
  tag_format = "$version"
88
88
  version_files = [
89
89
  "pyproject.toml:version"
@@ -1,5 +1,5 @@
1
1
  from pathlib import Path
2
- from typing import Iterable, Any, overload, Literal, cast, Optional
2
+ from typing import Iterable, Any, overload, Literal, cast, Optional, Mapping, Sequence
3
3
 
4
4
  from typing_extensions import LiteralString
5
5
 
@@ -67,20 +67,22 @@ def fetch_one(engine: Connection, query: Query, *args, required: bool = False) -
67
67
  return _data
68
68
 
69
69
 
70
- def _parse_value(v):
70
+ def _parse_value(v: Any) -> Any:
71
71
  if isinstance(v, dict):
72
72
  return Json(v)
73
73
  return v
74
74
 
75
75
 
76
- def get_insert_data(table: LiteralString, data: list[dict]) -> tuple[LiteralString, list[tuple[Any, ...]]]:
76
+ def get_insert_data(
77
+ table: LiteralString, data: Sequence[Mapping[str, Any]]
78
+ ) -> tuple[LiteralString, list[tuple[Any, ...]]]:
77
79
  keys = data[0].keys()
78
80
  _values = ",".join("%s" for _ in range(0, len(keys)))
79
- query = f"INSERT INTO {table} as t ({','.join(keys)}) VALUES ({_values})"
81
+ query = cast(LiteralString, f"INSERT INTO {table} as t ({','.join(keys)}) VALUES ({_values})")
80
82
  return query, [tuple(_parse_value(_x) for _x in x.values()) for x in data]
81
83
 
82
84
 
83
- def insert_many(engine: Connection | Cursor, table: LiteralString, data: list[dict]):
85
+ def insert_many(engine: Connection | Cursor, table: LiteralString, data: Sequence[Mapping[str, Any]]):
84
86
  query, _data = get_insert_data(table, data)
85
87
  if isinstance(engine, Connection):
86
88
  with engine.cursor() as cur:
@@ -92,15 +94,17 @@ def insert_many(engine: Connection | Cursor, table: LiteralString, data: list[di
92
94
 
93
95
 
94
96
  @overload
95
- def insert_one(engine: Connection, table: LiteralString, data: dict, returning: None = None) -> None: ...
97
+ def insert_one(engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: None = None) -> None: ...
96
98
 
97
99
 
98
100
  @overload
99
- def insert_one(engine: Connection, table: LiteralString, data: dict, returning: list[LiteralString]) -> dict: ...
101
+ def insert_one(
102
+ engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString]
103
+ ) -> dict: ...
100
104
 
101
105
 
102
106
  def insert_one(
103
- engine: Connection, table: LiteralString, data: dict, returning: list[LiteralString] | None = None
107
+ engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString] | None = None
104
108
  ) -> dict | None:
105
109
  query, _data = get_insert_data(table, [data])
106
110
  _is_returning = False
File without changes
File without changes