xn-model 1.0.8__tar.gz → 1.0.10__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.2
2
2
  Name: xn-model
3
- Version: 1.0.8
3
+ Version: 1.0.10
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -28,13 +28,13 @@ class Model(TortModel):
28
28
  @classmethod
29
29
  def out_type(cls):
30
30
  if not cls._out_type:
31
- cls._out = pydantic_model_creator(cls, name=cls.__name__ + "Out")
31
+ cls._out_type = pydantic_model_creator(cls, name=cls.__name__ + "Out")
32
32
  return cls._out_type
33
33
 
34
34
  @classmethod
35
35
  def in_type(cls):
36
36
  if not cls._in_type:
37
- cls._inn = pydantic_model_creator(
37
+ cls._in_type = pydantic_model_creator(
38
38
  cls, name=cls.__name__ + "In", exclude_readonly=True, meta_override=cls.PydanticMetaIn
39
39
  )
40
40
  return cls._in_type
@@ -0,0 +1,17 @@
1
+ from typing import ClassVar
2
+ from msgspec import Struct
3
+ from msgspec.structs import asdict
4
+
5
+
6
+ class New(Struct):
7
+ _unq: ClassVar[tuple[str]] = ()
8
+
9
+ def df_unq(self, frozen_props: tuple[str] = ()) -> dict:
10
+ d = {k: v for k, v in asdict(self).items() if v is not None or k in frozen_props}
11
+ return {**{k: d.pop(k) for k in set(self._unq) & d.keys()}, "defaults": d}
12
+
13
+
14
+ class Upd(New):
15
+ _unq = ("id",)
16
+
17
+ id: int
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: xn-model
3
- Version: 1.0.8
3
+ Version: 1.0.10
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -1,15 +0,0 @@
1
- from pydantic import BaseModel
2
-
3
-
4
- class New(BaseModel):
5
- _unq: list[str] = []
6
-
7
- def df_unq(self) -> dict:
8
- d = self.model_dump(exclude_none=True)
9
- return {**{k: d.pop(k) for k in set(self._unq) & d.keys()}, "defaults": d}
10
-
11
-
12
- class Upd(New):
13
- _unq: list[str] = ["id"]
14
-
15
- id: int
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