base-typed-string 0.1.0__tar.gz → 0.1.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.
Files changed (21) hide show
  1. {base_typed_string-0.1.0/src/base_typed_string.egg-info → base_typed_string-0.1.1}/PKG-INFO +1 -1
  2. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/pyproject.toml +1 -1
  3. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string/_base_typed_string.py +9 -2
  4. {base_typed_string-0.1.0 → base_typed_string-0.1.1/src/base_typed_string.egg-info}/PKG-INFO +1 -1
  5. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/test_runtime_behavior.py +8 -0
  6. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/LICENSE +0 -0
  7. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/README.md +0 -0
  8. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/setup.cfg +0 -0
  9. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string/__init__.py +0 -0
  10. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string/_exceptions.py +0 -0
  11. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string/py.typed +0 -0
  12. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string.egg-info/SOURCES.txt +0 -0
  13. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string.egg-info/dependency_links.txt +0 -0
  14. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string.egg-info/requires.txt +0 -0
  15. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/src/base_typed_string.egg-info/top_level.txt +0 -0
  16. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/test_constructor.py +0 -0
  17. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/test_internal_invariants.py +0 -0
  18. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/test_pickle_support.py +0 -0
  19. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/test_pydantic_support.py +0 -0
  20. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/testing_assertions.py +0 -0
  21. {base_typed_string-0.1.0 → base_typed_string-0.1.1}/tests/testing_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: base-typed-string
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Strict typed string base class with exact runtime subtype preservation and optional Pydantic v2 support.
5
5
  Author-email: Eldeniz Guseinli <eldenizfamilyanskicode@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "base-typed-string"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "Strict typed string base class with exact runtime subtype preservation and optional Pydantic v2 support."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -39,7 +39,6 @@ class BaseTypedString(str):
39
39
 
40
40
  return str.__new__(cls, value)
41
41
 
42
-
43
42
  @classmethod
44
43
  def __get_pydantic_core_schema__(
45
44
  cls,
@@ -56,8 +55,13 @@ class BaseTypedString(str):
56
55
  Serialization:
57
56
  - serializes as plain str
58
57
  """
58
+ del source_type
59
+ del handler
60
+
59
61
  try:
60
- from pydantic_core import core_schema
62
+ from pydantic_core import ( # pyright: ignore[reportMissingImports]
63
+ core_schema,
64
+ )
61
65
  except ImportError as import_error:
62
66
  raise BaseTypedStringInvariantViolationError(
63
67
  "pydantic-core is required to build BaseTypedString schema."
@@ -82,3 +86,6 @@ class BaseTypedString(str):
82
86
  self,
83
87
  ) -> tuple[type[BaseTypedString], tuple[str]]:
84
88
  return (self.__class__, (str(self),))
89
+
90
+ def __repr__(self) -> str:
91
+ return f"{self.__class__.__name__}({str(self)!r})"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: base-typed-string
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Strict typed string base class with exact runtime subtype preservation and optional Pydantic v2 support.
5
5
  Author-email: Eldeniz Guseinli <eldenizfamilyanskicode@gmail.com>
6
6
  License-Expression: MIT
@@ -120,6 +120,13 @@ def test_typed_string_has_same_hash_and_equality_as_plain_string() -> None:
120
120
  assert hash(typed_value) == hash(plain_value)
121
121
 
122
122
 
123
+ def test_repr_uses_exact_runtime_subtype_name_and_plain_string_value() -> None:
124
+ typed_value: AdminUserName = AdminUserName("root")
125
+
126
+ rendered_value: str = repr(typed_value)
127
+
128
+ assert rendered_value == "AdminUserName('root')"
129
+
123
130
  def test_plain_class_attribute_preserves_exact_runtime_subtype() -> None:
124
131
  typed_value: UserName = UserName("alice")
125
132
 
@@ -133,3 +140,4 @@ def test_plain_class_attribute_preserves_exact_runtime_subtype() -> None:
133
140
  expected_plain_value="alice",
134
141
  expected_type=UserName,
135
142
  )
143
+