TypeDAL 3.7.0__tar.gz → 3.7.1__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.

Potentially problematic release.


This version of TypeDAL might be problematic. Click here for more details.

Files changed (58) hide show
  1. {typedal-3.7.0 → typedal-3.7.1}/CHANGELOG.md +11 -0
  2. {typedal-3.7.0 → typedal-3.7.1}/PKG-INFO +6 -2
  3. {typedal-3.7.0 → typedal-3.7.1}/README.md +2 -0
  4. {typedal-3.7.0 → typedal-3.7.1}/pyproject.toml +3 -1
  5. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/__about__.py +1 -1
  6. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/core.py +24 -7
  7. {typedal-3.7.0 → typedal-3.7.1}/.github/workflows/su6.yml +0 -0
  8. {typedal-3.7.0 → typedal-3.7.1}/.gitignore +0 -0
  9. {typedal-3.7.0 → typedal-3.7.1}/.readthedocs.yml +0 -0
  10. {typedal-3.7.0 → typedal-3.7.1}/coverage.svg +0 -0
  11. {typedal-3.7.0 → typedal-3.7.1}/docs/1_getting_started.md +0 -0
  12. {typedal-3.7.0 → typedal-3.7.1}/docs/2_defining_tables.md +0 -0
  13. {typedal-3.7.0 → typedal-3.7.1}/docs/3_building_queries.md +0 -0
  14. {typedal-3.7.0 → typedal-3.7.1}/docs/4_relationships.md +0 -0
  15. {typedal-3.7.0 → typedal-3.7.1}/docs/5_py4web.md +0 -0
  16. {typedal-3.7.0 → typedal-3.7.1}/docs/6_migrations.md +0 -0
  17. {typedal-3.7.0 → typedal-3.7.1}/docs/7_mixins.md +0 -0
  18. {typedal-3.7.0 → typedal-3.7.1}/docs/css/code_blocks.css +0 -0
  19. {typedal-3.7.0 → typedal-3.7.1}/docs/index.md +0 -0
  20. {typedal-3.7.0 → typedal-3.7.1}/docs/requirements.txt +0 -0
  21. {typedal-3.7.0 → typedal-3.7.1}/example_new.py +0 -0
  22. {typedal-3.7.0 → typedal-3.7.1}/example_old.py +0 -0
  23. {typedal-3.7.0 → typedal-3.7.1}/mkdocs.yml +0 -0
  24. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/__init__.py +0 -0
  25. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/caching.py +0 -0
  26. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/cli.py +0 -0
  27. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/config.py +0 -0
  28. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/fields.py +0 -0
  29. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/for_py4web.py +0 -0
  30. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/for_web2py.py +0 -0
  31. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/helpers.py +0 -0
  32. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/mixins.py +0 -0
  33. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/py.typed +0 -0
  34. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/serializers/as_json.py +0 -0
  35. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/types.py +0 -0
  36. {typedal-3.7.0 → typedal-3.7.1}/src/typedal/web2py_py4web_shared.py +0 -0
  37. {typedal-3.7.0 → typedal-3.7.1}/tests/__init__.py +0 -0
  38. {typedal-3.7.0 → typedal-3.7.1}/tests/configs/simple.toml +0 -0
  39. {typedal-3.7.0 → typedal-3.7.1}/tests/configs/valid.env +0 -0
  40. {typedal-3.7.0 → typedal-3.7.1}/tests/configs/valid.toml +0 -0
  41. {typedal-3.7.0 → typedal-3.7.1}/tests/test_cli.py +0 -0
  42. {typedal-3.7.0 → typedal-3.7.1}/tests/test_config.py +0 -0
  43. {typedal-3.7.0 → typedal-3.7.1}/tests/test_docs_examples.py +0 -0
  44. {typedal-3.7.0 → typedal-3.7.1}/tests/test_helpers.py +0 -0
  45. {typedal-3.7.0 → typedal-3.7.1}/tests/test_json.py +0 -0
  46. {typedal-3.7.0 → typedal-3.7.1}/tests/test_main.py +0 -0
  47. {typedal-3.7.0 → typedal-3.7.1}/tests/test_mixins.py +0 -0
  48. {typedal-3.7.0 → typedal-3.7.1}/tests/test_mypy.py +0 -0
  49. {typedal-3.7.0 → typedal-3.7.1}/tests/test_orm.py +0 -0
  50. {typedal-3.7.0 → typedal-3.7.1}/tests/test_py4web.py +0 -0
  51. {typedal-3.7.0 → typedal-3.7.1}/tests/test_query_builder.py +0 -0
  52. {typedal-3.7.0 → typedal-3.7.1}/tests/test_relationships.py +0 -0
  53. {typedal-3.7.0 → typedal-3.7.1}/tests/test_row.py +0 -0
  54. {typedal-3.7.0 → typedal-3.7.1}/tests/test_stats.py +0 -0
  55. {typedal-3.7.0 → typedal-3.7.1}/tests/test_table.py +0 -0
  56. {typedal-3.7.0 → typedal-3.7.1}/tests/test_web2py.py +0 -0
  57. {typedal-3.7.0 → typedal-3.7.1}/tests/test_xx_others.py +0 -0
  58. {typedal-3.7.0 → typedal-3.7.1}/tests/timings.py +0 -0
@@ -2,6 +2,17 @@
2
2
 
3
3
  <!--next-version-placeholder-->
4
4
 
5
+ ## v3.7.1 (2024-10-09)
6
+
7
+ ### Fix
8
+
9
+ * Prepare for python 3.13 (-> cgi dependency, changes in forward reference evaluation); except psycopg2 ([`bbcca8f`](https://github.com/trialandsuccess/TypeDAL/commit/bbcca8f7a5d2f8a6ddc8caf3a1b05fde3ed2fdd2))
10
+ * Require legacy-cgi for python 3.13+ ([`7ba9489`](https://github.com/trialandsuccess/TypeDAL/commit/7ba94898cde600008a350e718783a4d0dbc05e45))
11
+
12
+ ### Documentation
13
+
14
+ * **readme:** Include `from typedal.helpers import get_db` in example ([`8853052`](https://github.com/trialandsuccess/TypeDAL/commit/8853052575b4576945901eb87da94bf709e99526))
15
+
5
16
  ## v3.7.0 (2024-08-17)
6
17
 
7
18
  ### Feature
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: TypeDAL
3
- Version: 3.7.0
3
+ Version: 3.7.1
4
4
  Summary: Typing support for PyDAL
5
5
  Project-URL: Documentation, https://typedal.readthedocs.io/
6
6
  Project-URL: Issues, https://github.com/trialandsuccess/TypeDAL/issues
@@ -12,16 +12,18 @@ Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
15
16
  Classifier: Programming Language :: Python :: Implementation :: CPython
16
17
  Classifier: Programming Language :: Python :: Implementation :: PyPy
17
18
  Requires-Python: >=3.10
18
19
  Requires-Dist: configurable-json
19
20
  Requires-Dist: configuraptor>=1.26.2
20
21
  Requires-Dist: dill
22
+ Requires-Dist: legacy-cgi; python_version >= '3.13'
21
23
  Requires-Dist: pydal
22
24
  Requires-Dist: python-slugify
23
25
  Provides-Extra: all
24
- Requires-Dist: edwh-migrate>=0.8.0; extra == 'all'
26
+ Requires-Dist: edwh-migrate[full]>=0.8.0; extra == 'all'
25
27
  Requires-Dist: py4web; extra == 'all'
26
28
  Requires-Dist: pydal2sql[all]>=1.2.0; extra == 'all'
27
29
  Requires-Dist: questionary; extra == 'all'
@@ -318,6 +320,8 @@ These helpers are useful for scenarios where direct access to the PyDAL objects
318
320
  An example of this is when you need to do a `db.commit()` but you can't import `db` directly:
319
321
 
320
322
  ```python
323
+ from typedal.helpers import get_db #, get_table, get_field
324
+
321
325
  MyTable.insert(...)
322
326
  db = get_db(MyTable)
323
327
  db.commit() # this is usually done automatically but sometimes you want to manually commit.
@@ -264,6 +264,8 @@ These helpers are useful for scenarios where direct access to the PyDAL objects
264
264
  An example of this is when you need to do a `db.commit()` but you can't import `db` directly:
265
265
 
266
266
  ```python
267
+ from typedal.helpers import get_db #, get_table, get_field
268
+
267
269
  MyTable.insert(...)
268
270
  db = get_db(MyTable)
269
271
  db.commit() # this is usually done automatically but sometimes you want to manually commit.
@@ -19,6 +19,7 @@ classifiers = [
19
19
  "Programming Language :: Python :: 3.10",
20
20
  "Programming Language :: Python :: 3.11",
21
21
  "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
22
23
  "Programming Language :: Python :: Implementation :: CPython",
23
24
  "Programming Language :: Python :: Implementation :: PyPy",
24
25
  ]
@@ -28,6 +29,7 @@ dependencies = [
28
29
  "configuraptor >= 1.26.2", # config
29
30
  "Configurable-JSON", # json dumping
30
31
  "python-slugify",
32
+ "legacy-cgi; python_version >= '3.13'"
31
33
  ]
32
34
 
33
35
  [project.optional-dependencies]
@@ -49,7 +51,7 @@ all = [
49
51
  "typer",
50
52
  "tabulate",
51
53
  "pydal2sql[all]>=1.2.0",
52
- "edwh-migrate>=0.8.0",
54
+ "edwh-migrate[full]>=0.8.0",
53
55
  "questionary",
54
56
  "tomlkit",
55
57
  ]
@@ -5,4 +5,4 @@ This file contains the Version info for this package.
5
5
  # SPDX-FileCopyrightText: 2023-present Robin van der Noord <robinvandernoord@gmail.com>
6
6
  #
7
7
  # SPDX-License-Identifier: MIT
8
- __version__ = "3.7.0"
8
+ __version__ = "3.7.1"
@@ -8,6 +8,7 @@ import datetime as dt
8
8
  import inspect
9
9
  import json
10
10
  import math
11
+ import sys
11
12
  import types
12
13
  import typing
13
14
  import warnings
@@ -339,6 +340,22 @@ def to_relationship(
339
340
  return Relationship(typing.cast(type[TypedTable], field), condition, typing.cast(JOIN_OPTIONS, join))
340
341
 
341
342
 
343
+ def evaluate_forward_reference(fw_ref: typing.ForwardRef) -> type:
344
+ """
345
+ Extract the original type from a forward reference string.
346
+ """
347
+ kwargs = dict(
348
+ localns=locals(),
349
+ globalns=globals(),
350
+ recursive_guard=frozenset(),
351
+ )
352
+ if sys.version_info >= (3, 13):
353
+ # required since 3.13 and not supported before
354
+ kwargs["type_params"] = ()
355
+
356
+ return fw_ref._evaluate(**kwargs) # type: ignore
357
+
358
+
342
359
  class TypeDAL(pydal.DAL): # type: ignore
343
360
  """
344
361
  Drop-in replacement for pyDAL with layer to convert class-based table definitions to classical pydal define_tables.
@@ -465,6 +482,7 @@ class TypeDAL(pydal.DAL): # type: ignore
465
482
  # when __future__.annotations is implemented, cls.__annotations__ will not work anymore as below.
466
483
  # proper way to handle this would be (but gives error right now due to Table implementing magic methods):
467
484
  # typing.get_type_hints(cls, globalns=None, localns=None)
485
+ # -> ERR e.g. `pytest -svxk cli` -> name 'BestFriend' is not defined
468
486
 
469
487
  # dirty way (with evil eval):
470
488
  # [eval(v) for k, v in cls.__annotations__.items()]
@@ -674,9 +692,8 @@ class TypeDAL(pydal.DAL): # type: ignore
674
692
 
675
693
  if isinstance(ftype, str):
676
694
  # extract type from string
677
- ftype = typing.get_args(Type[ftype])[0]._evaluate(
678
- localns=locals(), globalns=globals(), recursive_guard=frozenset()
679
- )
695
+ fw_ref: typing.ForwardRef = typing.get_args(Type[ftype])[0]
696
+ ftype = evaluate_forward_reference(fw_ref)
680
697
 
681
698
  if mapping := BASIC_MAPPINGS.get(ftype):
682
699
  # basi types
@@ -1144,7 +1161,7 @@ class TableMeta(type):
1144
1161
  """
1145
1162
  Add a before insert hook.
1146
1163
  """
1147
- cls._before_insert.append(fn) # type: ignore
1164
+ cls._before_insert.append(fn)
1148
1165
  return cls
1149
1166
 
1150
1167
  def after_insert(
@@ -1157,7 +1174,7 @@ class TableMeta(type):
1157
1174
  """
1158
1175
  Add an after insert hook.
1159
1176
  """
1160
- cls._after_insert.append(fn) # type: ignore
1177
+ cls._after_insert.append(fn)
1161
1178
  return cls
1162
1179
 
1163
1180
  def before_update(
@@ -1167,7 +1184,7 @@ class TableMeta(type):
1167
1184
  """
1168
1185
  Add a before update hook.
1169
1186
  """
1170
- cls._before_update.append(fn) # type: ignore
1187
+ cls._before_update.append(fn)
1171
1188
  return cls
1172
1189
 
1173
1190
  def after_update(
@@ -1177,7 +1194,7 @@ class TableMeta(type):
1177
1194
  """
1178
1195
  Add an after update hook.
1179
1196
  """
1180
- cls._after_update.append(fn) # type: ignore
1197
+ cls._after_update.append(fn)
1181
1198
  return cls
1182
1199
 
1183
1200
  def before_delete(cls: Type[T_MetaInstance], fn: typing.Callable[[Set], Optional[bool]]) -> Type[T_MetaInstance]:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes