oocana 0.16.4__tar.gz → 0.16.5__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,10 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oocana
3
- Version: 0.16.4
3
+ Version: 0.16.5
4
4
  Summary: python implement of oocana to give a context for oocana block
5
5
  License: MIT
6
6
  Requires-Python: >=3.9
7
7
  Requires-Dist: paho-mqtt>=2
8
8
  Requires-Dist: simplejson>=3.19.2
9
- Requires-Dist: typing-extensions>=4.12.2; python_version < "3.11"
10
9
 
@@ -29,17 +29,10 @@ class JobDict(TypedDict):
29
29
  job_id: str
30
30
 
31
31
  class BlockDict(TypedDict):
32
-
33
- try:
34
- # NotRequired, Required was added in version 3.11
35
- from typing import NotRequired, Required, TypedDict # type: ignore
36
- except ImportError:
37
- from typing_extensions import NotRequired, Required, TypedDict
38
-
39
32
  session_id: str
40
33
  job_id: str
41
34
  stacks: list
42
- block_path: NotRequired[str]
35
+ block_path: str | None # better to use NotRequired here, but it is not supported in python 3.10 and type_extensions requires high version, For compatibility, use None instead of NotRequired.
43
36
 
44
37
  # dataclass 默认字段必须一一匹配
45
38
  # 如果多一个或者少一个字段,就会报错。
@@ -84,7 +77,7 @@ class BlockInfo:
84
77
  "session_id": self.session_id,
85
78
  "job_id": self.job_id,
86
79
  "stacks": self.stacks,
87
- }
80
+ } # type: ignore[return-value]
88
81
 
89
82
  return {
90
83
  "session_id": self.session_id,
@@ -1,11 +1,10 @@
1
1
  [project]
2
2
  name = "oocana"
3
- version = "0.16.4"
3
+ version = "0.16.5"
4
4
  description = "python implement of oocana to give a context for oocana block"
5
5
  dependencies = [
6
6
  "paho-mqtt>=2",
7
7
  "simplejson>=3.19.2",
8
- "typing-extensions>=4.12.2; python_version < '3.11'",
9
8
  ]
10
9
  requires-python = ">=3.9"
11
10
 
@@ -71,5 +71,21 @@ class TestData(unittest.TestCase):
71
71
  key_serialize_block_info = data.dumps({"key": block_info})
72
72
  self.assertEqual(key_serialize_block_info, '{"key": {"session_id": "session_id_one", "job_id": "job_id_one", "stacks": ["stack1", "stack2"], "block_path": "block_path_one"}}')
73
73
 
74
+ with self.assertRaises(TypeError):
75
+ json_dumps(block_info)
76
+
77
+ def test_dataclass_dumps_with_none(self):
78
+ block_info_dict = {
79
+ "session_id": "session_id_one",
80
+ "job_id": "job_id_one",
81
+ "stacks": ["stack1", "stack2"],
82
+ "block_path": None,
83
+ "extra": "extra"
84
+ }
85
+
86
+ block_info = data.BlockInfo(**block_info_dict)
87
+ serialize_block_info = data.dumps(block_info.block_dict())
88
+ self.assertEqual(serialize_block_info, '{"session_id": "session_id_one", "job_id": "job_id_one", "stacks": ["stack1", "stack2"]}')
89
+
74
90
  with self.assertRaises(TypeError):
75
91
  json_dumps(block_info)
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