cuid2 1.3.0__tar.gz → 2.0.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.
- {cuid2-1.3.0 → cuid2-2.0.0}/PKG-INFO +21 -3
- {cuid2-1.3.0 → cuid2-2.0.0}/README.md +20 -2
- {cuid2-1.3.0 → cuid2-2.0.0}/pyproject.toml +8 -5
- cuid2-2.0.0/src/cuid2/__init__.py +4 -0
- cuid2-2.0.0/src/cuid2/cli.py +8 -0
- {cuid2-1.3.0 → cuid2-2.0.0}/src/cuid2/generator.py +14 -11
- cuid2-1.3.0/src/cuid2/__init__.py +0 -5
- {cuid2-1.3.0 → cuid2-2.0.0}/LICENSE +0 -0
- {cuid2-1.3.0 → cuid2-2.0.0}/src/cuid2/py.typed +0 -0
- {cuid2-1.3.0 → cuid2-2.0.0}/src/cuid2/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cuid2
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Next generation GUIDs. Collision-resistant ids optimized for horizontal scaling and performance.
|
|
5
5
|
Keywords: crypt security uuid guid cuid cryptography
|
|
6
6
|
Author-Email: Will Gordon <wgordon@redhat.com>
|
|
@@ -78,11 +78,29 @@ pip install cuid2
|
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
## Usage
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
You can generate CUIDs directly in the terminal with the following:
|
|
83
|
+
```bash
|
|
84
|
+
$ cuid2
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or you can rely on a CUID wrapper if you don't need any customizations:
|
|
88
|
+
```python
|
|
89
|
+
from typing import Callable
|
|
90
|
+
from cuid2 import cuid_wrapper
|
|
91
|
+
|
|
92
|
+
cuid_generator: Callable[[], str] = cuid_wrapper()
|
|
93
|
+
|
|
94
|
+
def main():
|
|
95
|
+
my_cuid: str = cuid_generator()
|
|
96
|
+
next_cuid: str = cuid_generator()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Finally, for more explicit control of the CUID generator, you can instantiate the class directly:
|
|
82
100
|
```python
|
|
83
101
|
from cuid2 import Cuid
|
|
84
102
|
|
|
85
|
-
CUID_GENERATOR: Cuid = Cuid()
|
|
103
|
+
CUID_GENERATOR: Cuid = Cuid(length=10)
|
|
86
104
|
|
|
87
105
|
def main():
|
|
88
106
|
my_cuid: str = CUID_GENERATOR.generate()
|
|
@@ -39,11 +39,29 @@ pip install cuid2
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## Usage
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
You can generate CUIDs directly in the terminal with the following:
|
|
44
|
+
```bash
|
|
45
|
+
$ cuid2
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or you can rely on a CUID wrapper if you don't need any customizations:
|
|
49
|
+
```python
|
|
50
|
+
from typing import Callable
|
|
51
|
+
from cuid2 import cuid_wrapper
|
|
52
|
+
|
|
53
|
+
cuid_generator: Callable[[], str] = cuid_wrapper()
|
|
54
|
+
|
|
55
|
+
def main():
|
|
56
|
+
my_cuid: str = cuid_generator()
|
|
57
|
+
next_cuid: str = cuid_generator()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Finally, for more explicit control of the CUID generator, you can instantiate the class directly:
|
|
43
61
|
```python
|
|
44
62
|
from cuid2 import Cuid
|
|
45
63
|
|
|
46
|
-
CUID_GENERATOR: Cuid = Cuid()
|
|
64
|
+
CUID_GENERATOR: Cuid = Cuid(length=10)
|
|
47
65
|
|
|
48
66
|
def main():
|
|
49
67
|
my_cuid: str = CUID_GENERATOR.generate()
|
|
@@ -31,7 +31,7 @@ keywords = [
|
|
|
31
31
|
"cuid",
|
|
32
32
|
"cryptography",
|
|
33
33
|
]
|
|
34
|
-
version = "
|
|
34
|
+
version = "2.0.0"
|
|
35
35
|
|
|
36
36
|
[project.license]
|
|
37
37
|
file = "LICENSE"
|
|
@@ -39,6 +39,9 @@ file = "LICENSE"
|
|
|
39
39
|
[project.urls]
|
|
40
40
|
repository = "https://github.com/gordon-code/cuid2/"
|
|
41
41
|
|
|
42
|
+
[project.scripts]
|
|
43
|
+
cuid2 = "cuid2.cli:main"
|
|
44
|
+
|
|
42
45
|
[tool.pdm.version]
|
|
43
46
|
source = "scm"
|
|
44
47
|
|
|
@@ -73,7 +76,7 @@ lint = [
|
|
|
73
76
|
"black~=23.3.0",
|
|
74
77
|
"codespell~=2.2.4",
|
|
75
78
|
"pylint~=2.17.4",
|
|
76
|
-
"ruff~=0.0.
|
|
79
|
+
"ruff~=0.0.269",
|
|
77
80
|
"safety==2.4.0b1",
|
|
78
81
|
]
|
|
79
82
|
test = [
|
|
@@ -81,13 +84,13 @@ test = [
|
|
|
81
84
|
"pytest-mock~=3.10.0",
|
|
82
85
|
"pytest-sugar~=0.9.7",
|
|
83
86
|
]
|
|
84
|
-
typing = [
|
|
85
|
-
"mypy~=1.3.0",
|
|
86
|
-
]
|
|
87
87
|
tox = [
|
|
88
88
|
"tox~=4.4.12",
|
|
89
89
|
"tox-pdm~=0.6.1",
|
|
90
90
|
]
|
|
91
|
+
typing = [
|
|
92
|
+
"mypy~=1.3.0",
|
|
93
|
+
]
|
|
91
94
|
|
|
92
95
|
[tool.tox]
|
|
93
96
|
legacy_tox_ini = " [tox]\n min_version = 4\n env_list = py3{8,9,10,11}, check\n work_dir = local/.tox\n isolated_build = True\n\n [testenv]\n description = run unit tests\n groups = test\n commands = testing\n\n [testenv:check]\n description = run linters and typing\n skip_install = true\n groups = lint, typing, test\n commands = lint-full\n"
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import time
|
|
2
|
-
import warnings
|
|
3
2
|
from math import floor
|
|
4
3
|
from secrets import SystemRandom
|
|
5
|
-
from typing import TYPE_CHECKING,
|
|
4
|
+
from typing import TYPE_CHECKING, Callable, Final, Optional, Protocol
|
|
6
5
|
|
|
7
6
|
from cuid2 import utils
|
|
8
7
|
|
|
@@ -99,13 +98,17 @@ class Cuid: # pylint: disable=too-few-public-methods
|
|
|
99
98
|
return first_letter + utils.create_hash(hash_input)[1 : length or self._length]
|
|
100
99
|
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"""Deprecated class CUID. Use Cuid instead."""
|
|
105
|
-
warnings.warn("CUID is deprecated, use Cuid instead", DeprecationWarning, stacklevel=1)
|
|
106
|
-
super().__init_subclass__(**kwargs)
|
|
101
|
+
def cuid_wrapper() -> Callable[[], str]:
|
|
102
|
+
"""Wrap a single Cuid class instance and return a callable that generates a CUID string.
|
|
107
103
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
Returns
|
|
105
|
+
-------
|
|
106
|
+
Callable[[], str]
|
|
107
|
+
A callable that generates a CUID string.
|
|
108
|
+
"""
|
|
109
|
+
cuid_generator: Cuid = Cuid()
|
|
110
|
+
|
|
111
|
+
def cuid() -> str:
|
|
112
|
+
return cuid_generator.generate()
|
|
113
|
+
|
|
114
|
+
return cuid
|
|
File without changes
|
|
File without changes
|
|
File without changes
|