python-ulid 2.4.0__tar.gz → 2.5.0__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 (27) hide show
  1. {python_ulid-2.4.0 → python_ulid-2.5.0}/CHANGELOG.rst +9 -0
  2. {python_ulid-2.4.0 → python_ulid-2.5.0}/PKG-INFO +5 -2
  3. {python_ulid-2.4.0 → python_ulid-2.5.0}/pyproject.toml +4 -1
  4. {python_ulid-2.4.0 → python_ulid-2.5.0}/tests/test_ulid.py +22 -1
  5. {python_ulid-2.4.0 → python_ulid-2.5.0}/ulid/__init__.py +2 -0
  6. {python_ulid-2.4.0 → python_ulid-2.5.0}/.github/workflows/lint-and-test.yml +0 -0
  7. {python_ulid-2.4.0 → python_ulid-2.5.0}/.github/workflows/publish.yml +0 -0
  8. {python_ulid-2.4.0 → python_ulid-2.5.0}/.gitignore +0 -0
  9. {python_ulid-2.4.0 → python_ulid-2.5.0}/.pre-commit-config.yaml +0 -0
  10. {python_ulid-2.4.0 → python_ulid-2.5.0}/.readthedocs.yml +0 -0
  11. {python_ulid-2.4.0 → python_ulid-2.5.0}/LICENSE +0 -0
  12. {python_ulid-2.4.0 → python_ulid-2.5.0}/README.rst +0 -0
  13. {python_ulid-2.4.0 → python_ulid-2.5.0}/docs/Makefile +0 -0
  14. {python_ulid-2.4.0 → python_ulid-2.5.0}/docs/requirements.txt +0 -0
  15. {python_ulid-2.4.0 → python_ulid-2.5.0}/docs/source/api.rst +0 -0
  16. {python_ulid-2.4.0 → python_ulid-2.5.0}/docs/source/changelog.rst +0 -0
  17. {python_ulid-2.4.0 → python_ulid-2.5.0}/docs/source/conf.py +0 -0
  18. {python_ulid-2.4.0 → python_ulid-2.5.0}/docs/source/index.rst +0 -0
  19. {python_ulid-2.4.0 → python_ulid-2.5.0}/hatch.toml +0 -0
  20. {python_ulid-2.4.0 → python_ulid-2.5.0}/logo.png +0 -0
  21. {python_ulid-2.4.0 → python_ulid-2.5.0}/tests/__init__.py +0 -0
  22. {python_ulid-2.4.0 → python_ulid-2.5.0}/tests/test_base32.py +0 -0
  23. {python_ulid-2.4.0 → python_ulid-2.5.0}/tests/test_cli.py +0 -0
  24. {python_ulid-2.4.0 → python_ulid-2.5.0}/ulid/__main__.py +0 -0
  25. {python_ulid-2.4.0 → python_ulid-2.5.0}/ulid/base32.py +0 -0
  26. {python_ulid-2.4.0 → python_ulid-2.5.0}/ulid/constants.py +0 -0
  27. {python_ulid-2.4.0 → python_ulid-2.5.0}/ulid/py.typed +0 -0
@@ -5,6 +5,14 @@ Changelog
5
5
 
6
6
  Versions follow `Semantic Versioning <http://www.semver.org>`_
7
7
 
8
+ `2.5.0`_ - 2024-04-26
9
+ ---------------------
10
+
11
+ Changed
12
+ ~~~~~~~
13
+ * Generate a more accurate JSON schema with Pydantic's ``BaseModel.model_json_schema()``. This
14
+ includes a specification for string and byte representations.
15
+
8
16
  `2.4.0`_ - 2024-04-02
9
17
  ---------------------
10
18
 
@@ -151,6 +159,7 @@ Changed
151
159
  * The package now has no external dependencies.
152
160
  * The test-coverage has been raised to 100%.
153
161
 
162
+ .. _2.5.0: https://github.com/mdomke/python-ulid/compare/2.4.0...2.5.0
154
163
  .. _2.4.0: https://github.com/mdomke/python-ulid/compare/2.3.0...2.4.0
155
164
  .. _2.3.0: https://github.com/mdomke/python-ulid/compare/2.2.0...2.3.0
156
165
  .. _2.2.0: https://github.com/mdomke/python-ulid/compare/2.1.0...2.2.0
@@ -1,10 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-ulid
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: Universally unique lexicographically sortable identifier
5
5
  Project-URL: Homepage, https://github.com/mdomke/python-ulid
6
+ Project-URL: Documentation, https://python-ulid.readthedocs.io
7
+ Project-URL: Changelog, https://python-ulid.readthedocs.io/en/latest/changelog.html
8
+ Project-URL: Issues, https://github.com/mdomke/python-ulid/issues
9
+ Project-URL: CI, https://github.com/mdomke/python-ulid/actions
6
10
  Project-URL: Repository, https://github.com/mdomke/python-ulid
7
- Project-URL: Documentation, https://python-ulid.readthedocs.io/
8
11
  Author-email: Martin Domke <mail@martindomke.net>
9
12
  License-Expression: MIT
10
13
  License-File: LICENSE
@@ -28,8 +28,11 @@ classifiers = [
28
28
 
29
29
  [project.urls]
30
30
  Homepage = "https://github.com/mdomke/python-ulid"
31
+ Documentation = "https://python-ulid.readthedocs.io"
32
+ Changelog = "https://python-ulid.readthedocs.io/en/latest/changelog.html"
33
+ Issues = "https://github.com/mdomke/python-ulid/issues"
34
+ CI = "https://github.com/mdomke/python-ulid/actions"
31
35
  Repository = "https://github.com/mdomke/python-ulid"
32
- Documentation = "https://python-ulid.readthedocs.io/"
33
36
 
34
37
  [project.optional-dependencies]
35
38
  pydantic = [
@@ -5,6 +5,7 @@ from collections.abc import Callable
5
5
  from datetime import datetime
6
6
  from datetime import timedelta
7
7
  from datetime import timezone
8
+ from typing import Optional
8
9
  from typing import Union
9
10
 
10
11
  import pytest
@@ -168,7 +169,7 @@ def test_pydantic_protocol() -> None:
168
169
  ulid = ULID()
169
170
 
170
171
  class Model(BaseModel):
171
- ulid: ULID
172
+ ulid: Optional[ULID] = None
172
173
 
173
174
  for value in [ulid, str(ulid), int(ulid), bytes(ulid)]:
174
175
  model = Model(ulid=value)
@@ -188,3 +189,23 @@ def test_pydantic_protocol() -> None:
188
189
  model_json = model.model_dump_json()
189
190
  assert isinstance(json.loads(model_json)["ulid"], str)
190
191
  assert Model.model_validate_json(model_json) == model
192
+
193
+ model_json_schema = model.model_json_schema()
194
+ assert "properties" in model_json_schema
195
+ assert "ulid" in model_json_schema["properties"]
196
+ assert "anyOf" in model_json_schema["properties"]["ulid"]
197
+ assert {
198
+ "maxLength": 26,
199
+ "minLength": 26,
200
+ "pattern": "[A-Z0-9]{26}",
201
+ "type": "string",
202
+ } in model_json_schema["properties"]["ulid"]["anyOf"]
203
+ assert {
204
+ "maxLength": 16,
205
+ "minLength": 16,
206
+ "type": "string",
207
+ "format": "binary",
208
+ } in model_json_schema["properties"]["ulid"]["anyOf"]
209
+ assert {
210
+ "type": "null",
211
+ } in model_json_schema["properties"]["ulid"]["anyOf"]
@@ -259,6 +259,8 @@ class ULID:
259
259
  [
260
260
  core_schema.is_instance_schema(ULID),
261
261
  core_schema.no_info_plain_validator_function(ULID),
262
+ core_schema.str_schema(pattern=r"[A-Z0-9]{26}", min_length=26, max_length=26),
263
+ core_schema.bytes_schema(min_length=16, max_length=16),
262
264
  ]
263
265
  ),
264
266
  serialization=core_schema.to_string_ser_schema(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes