sera-2 1.14.5__py3-none-any.whl → 1.14.6__py3-none-any.whl

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.
sera/misc/_utils.py CHANGED
@@ -4,6 +4,44 @@ import re
4
4
  from typing import Any, Callable, Iterable, Optional, TypeVar
5
5
 
6
6
  T = TypeVar("T")
7
+ reserved_keywords = {
8
+ "and",
9
+ "or",
10
+ "not",
11
+ "is",
12
+ "in",
13
+ "if",
14
+ "else",
15
+ "elif",
16
+ "for",
17
+ "while",
18
+ "def",
19
+ "class",
20
+ "return",
21
+ "yield",
22
+ "import",
23
+ "from",
24
+ "as",
25
+ "with",
26
+ "try",
27
+ "except",
28
+ "finally",
29
+ "raise",
30
+ "assert",
31
+ "break",
32
+ "continue",
33
+ "pass",
34
+ "del",
35
+ "global",
36
+ "nonlocal",
37
+ "lambda",
38
+ "async",
39
+ "await",
40
+ "True",
41
+ "False",
42
+ "None",
43
+ "self",
44
+ }
7
45
 
8
46
 
9
47
  def to_snake_case(camelcase: str) -> str:
@@ -16,13 +54,21 @@ def to_snake_case(camelcase: str) -> str:
16
54
  def to_camel_case(snake: str) -> str:
17
55
  """Convert snake_case to camelCase."""
18
56
  components = snake.split("_")
19
- return components[0] + "".join(x.title() for x in components[1:])
57
+ out = components[0] + "".join(x.title() for x in components[1:])
58
+ # handle a corner case where the _ is added to the end of the string to avoid reserved keywords
59
+ if snake.endswith("_") and snake[:-1] in reserved_keywords:
60
+ out += "_"
61
+ return out
20
62
 
21
63
 
22
64
  def to_pascal_case(snake: str) -> str:
23
65
  """Convert snake_case to PascalCase."""
24
66
  components = snake.split("_")
25
- return "".join(x.title() for x in components)
67
+ out = "".join(x.title() for x in components)
68
+ # handle a corner case where the _ is added to the end of the string to avoid reserved keywords
69
+ if snake.endswith("_") and snake[:-1] in reserved_keywords:
70
+ out += "_"
71
+ return out
26
72
 
27
73
 
28
74
  def assert_isinstance(x: Any, cls: type[T]) -> T:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sera-2
3
- Version: 1.14.5
3
+ Version: 1.14.6
4
4
  Summary:
5
5
  Author: Binh Vu
6
6
  Author-email: bvu687@gmail.com
@@ -22,7 +22,7 @@ sera/make/make_python_services.py,sha256=0ZpWLwQ7Nwfn8BXAikAB4JRpNknpSJyJgY5b1cj
22
22
  sera/make/make_typescript_model.py,sha256=4yLCLIzP2jeXfmOeee6nNS_qd7_7iPinV2vQh1IfbLs,64000
23
23
  sera/misc/__init__.py,sha256=Dh4uDq0D4N53h3zhvmwfa5a0TPVRSUvLzb0hkFuPirk,411
24
24
  sera/misc/_formatter.py,sha256=aCGYL08l8f3aLODHxSocxBBwkRYEo3K1QzCDEn3suj0,1685
25
- sera/misc/_utils.py,sha256=V5g4oLGHOhUCR75Kkcn1w01pAvGvaepK-T8Z3pIgHjI,1450
25
+ sera/misc/_utils.py,sha256=vBfbEChf7IMdLDj3CbdOXTUAdWNQTLLpAWwBoUcF3u0,2315
26
26
  sera/models/__init__.py,sha256=vJC5Kzo_N7wd16ocNPy1VvAZDGNiWeiAhWJ4ihATKvA,780
27
27
  sera/models/_class.py,sha256=1J4Bd_LanzhhDWwZFHWGtFYD7lupe_alaB3D02ebNDI,2862
28
28
  sera/models/_collection.py,sha256=ZnQEriKC4X88Zz48Kn1AVZKH-1_l8OgWa-zf2kcQOOE,1414
@@ -36,6 +36,6 @@ sera/models/_parse.py,sha256=MaGZty29lsVUFumWqNanIjAwptBNOMbVZMXLZ2A9_2g,12317
36
36
  sera/models/_property.py,sha256=2rSLs9JjSesrxrEugE7krYaBQOivKU882I8mZN94FlI,7017
37
37
  sera/models/_schema.py,sha256=VxJEiqgVvbXgcSUK4UW6JnRcggk4nsooVSE6MyXmfNY,1636
38
38
  sera/typing.py,sha256=Fl4-UzLJu1GdLLk_g87fA7nT9wQGelNnGzag6dg_0gs,980
39
- sera_2-1.14.5.dist-info/METADATA,sha256=vwWtB6bjalDopfemBjaZj3CI2D4S9seb-diDw98smxY,852
40
- sera_2-1.14.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
41
- sera_2-1.14.5.dist-info/RECORD,,
39
+ sera_2-1.14.6.dist-info/METADATA,sha256=XuXxkDt84tayCblVI10S594d0t3e0eg5j66iUCB-PKQ,852
40
+ sera_2-1.14.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
41
+ sera_2-1.14.6.dist-info/RECORD,,