bantam 2.4.44__tar.gz → 2.4.45__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.
Files changed (29) hide show
  1. {bantam-2.4.44 → bantam-2.4.45}/PKG-INFO +2 -2
  2. {bantam-2.4.44 → bantam-2.4.45}/setup.py +1 -1
  3. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/conversions.py +6 -2
  4. {bantam-2.4.44 → bantam-2.4.45}/src/bantam.egg-info/PKG-INFO +2 -2
  5. {bantam-2.4.44 → bantam-2.4.45}/test/test_conversions.py +6 -4
  6. {bantam-2.4.44 → bantam-2.4.45}/README +0 -0
  7. {bantam-2.4.44 → bantam-2.4.45}/requirements.txt +0 -0
  8. {bantam-2.4.44 → bantam-2.4.45}/setup.cfg +0 -0
  9. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/__init__.py +0 -0
  10. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/api.py +0 -0
  11. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/autogen/__init__.py +0 -0
  12. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/autogen/main.py +0 -0
  13. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/client.py +0 -0
  14. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/decorators.py +0 -0
  15. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/http.py +0 -0
  16. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/js.py +0 -0
  17. {bantam-2.4.44 → bantam-2.4.45}/src/bantam/js_async.py +0 -0
  18. {bantam-2.4.44 → bantam-2.4.45}/src/bantam.egg-info/SOURCES.txt +0 -0
  19. {bantam-2.4.44 → bantam-2.4.45}/src/bantam.egg-info/dependency_links.txt +0 -0
  20. {bantam-2.4.44 → bantam-2.4.45}/src/bantam.egg-info/entry_points.txt +0 -0
  21. {bantam-2.4.44 → bantam-2.4.45}/src/bantam.egg-info/requires.txt +0 -0
  22. {bantam-2.4.44 → bantam-2.4.45}/src/bantam.egg-info/top_level.txt +0 -0
  23. {bantam-2.4.44 → bantam-2.4.45}/test/test_client_get.py +0 -0
  24. {bantam-2.4.44 → bantam-2.4.45}/test/test_client_post.py +0 -0
  25. {bantam-2.4.44 → bantam-2.4.45}/test/test_client_post_inherited_apis.py +0 -0
  26. {bantam-2.4.44 → bantam-2.4.45}/test/test_decorators.py +0 -0
  27. {bantam-2.4.44 → bantam-2.4.45}/test/test_http.py +0 -0
  28. {bantam-2.4.44 → bantam-2.4.45}/test/test_js.py +0 -0
  29. {bantam-2.4.44 → bantam-2.4.45}/test/test_js_async.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bantam
3
- Version: 2.4.44
3
+ Version: 2.4.45
4
4
  Summary: small utils to automate web interface in Python
5
5
  Home-page: https://github.com/nak/bantam
6
- Download-URL: https://github.com/bantam/dist/2.4.44
6
+ Download-URL: https://github.com/bantam/dist/2.4.45
7
7
  Author: John Rusnak
8
8
  Author-email: john.j.rusnak@att.net
9
9
  License: BSD 2-CLAUSE
@@ -2,7 +2,7 @@ import os
2
2
 
3
3
  import setuptools
4
4
 
5
- VERSION = "2.4.44"
5
+ VERSION = "2.4.45"
6
6
 
7
7
  setuptools.setup(
8
8
  name='bantam',
@@ -54,6 +54,8 @@ def normalize_to_json_compat(val: Any) -> Any:
54
54
  json_data = []
55
55
  for value in val:
56
56
  json_data.append(normalize_to_json_compat(value))
57
+ elif hasattr(val, '__getstate__'):
58
+ json_data = val.__getstate__()
57
59
  else:
58
60
  try:
59
61
  return normalize_to_json_compat([int(b) for b in pickle.dumps(val)])
@@ -87,6 +89,8 @@ def full_type(annotation: Any) -> tuple[Any, tuple[Type, ...]]:
87
89
  return base, annotation.__args__
88
90
  elif hasattr(annotation, '__dataclass_fields__'):
89
91
  return annotation, tuple()
92
+ elif hasattr(base, '__getstate__'):
93
+ return base, tuple()
90
94
  else:
91
95
  raise TypeError(f"Unsupported type for web api: '{annotation}'. "
92
96
  "Parameterizable types must include type specifics")
@@ -176,8 +180,8 @@ def normalize_from_json(json_data, typ: Any) -> Any:
176
180
  name: normalize_from_json(json_data[name], field.type)
177
181
  for name, field in typ.__dataclass_fields__.items()
178
182
  })
179
- elif hasattr(typ, '__setstate__'):
180
- result = typ.__new__(typ)
183
+ elif hasattr(true_type, '__setstate__'):
184
+ result = true_type.__new__(true_type)
181
185
  result.__setstate__(json_data)
182
186
  return result
183
187
  else:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bantam
3
- Version: 2.4.44
3
+ Version: 2.4.45
4
4
  Summary: small utils to automate web interface in Python
5
5
  Home-page: https://github.com/nak/bantam
6
- Download-URL: https://github.com/bantam/dist/2.4.44
6
+ Download-URL: https://github.com/bantam/dist/2.4.45
7
7
  Author: John Rusnak
8
8
  Author-email: john.j.rusnak@att.net
9
9
  License: BSD 2-CLAUSE
@@ -6,15 +6,17 @@ import uuid
6
6
  from collections import OrderedDict
7
7
  from dataclasses import dataclass
8
8
  from pathlib import Path, PosixPath
9
- from typing import Dict, List, Union, Tuple, Set, Optional
9
+ from typing import Dict, List, Union, Tuple, Set, Optional, Generic, TypeVar
10
10
 
11
11
  import pytest
12
12
  from frozenlist import FrozenList
13
13
  from frozendict import frozendict
14
14
 
15
15
  from bantam.conversions import to_str, from_str, normalize_from_json
16
+ T = TypeVar('T')
16
17
 
17
- class Pickleable:
18
+
19
+ class Pickleable(Generic[T]):
18
20
 
19
21
  def __init__(self, host: str = None, port: int = None, semaphore = None):
20
22
  self.host = host or "localhost"
@@ -102,10 +104,10 @@ class Test:
102
104
  })
103
105
 
104
106
  def test_pickleable_from_str(self):
105
- item = Pickleable()
107
+ item: Pickleable[int] = Pickleable()
106
108
  text = to_str(item)
107
109
  assert json.loads(text) == {'host': 'localhost', 'port': 12345}
108
- item2 = normalize_from_json(json.loads(text), Pickleable)
110
+ item2 = normalize_from_json(json.loads(text), Pickleable[int])
109
111
  assert item2.host == "localhost"
110
112
  assert item2.port == 12345
111
113
  assert isinstance(item.semaphore, threading.Semaphore)
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