Skip to content

Commit 0b2235a

Browse files
committed
update docs
1 parent 4356906 commit 0b2235a

1 file changed

Lines changed: 39 additions & 18 deletions

File tree

Lib/test/support/hashlib_helper.py

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010

1111

1212
def _parse_fullname(fullname, *, strict=False):
13-
"""Parse a fully-qualified name <module_name>.<member_name>.
13+
"""Parse a fully-qualified name ``<module_name>.<member_name>``.
1414
1515
The ``module_name`` component contains one or more dots.
1616
The ``member_name`` component does not contain any dot.
17+
18+
If *strict* is true, *fullname* must be a string. Otherwise,
19+
it can be None, and, ``module_name`` and ``member_name`` will
20+
also be None.
1721
"""
1822
if fullname is None:
1923
assert not strict
@@ -119,7 +123,6 @@ class _HashInfoItem:
119123
The object is entirely described by its fully-qualified *fullname*.
120124
121125
*fullname* must be None or a string "<module_name>.<member_name>".
122-
If *strict* is true, *fullname* cannot be None.
123126
"""
124127

125128
def __init__(self, fullname=None, *, strict=False):
@@ -160,6 +163,7 @@ class _HashInfoBase:
160163
"""
161164

162165
def __init__(self, canonical_name):
166+
assert isinstance(canonical_name, _HashId), canonical_name
163167
self.canonical_name = canonical_name
164168

165169
def __getitem__(self, implementation):
@@ -185,6 +189,8 @@ def invalid_implementation_error(self, implementation):
185189
class _HashTypeInfo(_HashInfoBase):
186190
"""Dataclass containing information for hash functions types.
187191
192+
- *canonical_name* must be a _HashId.
193+
188194
- *builtin* is the fully-qualified name for the builtin HACL* type,
189195
e.g., "_md5.MD5Type".
190196
@@ -243,6 +249,8 @@ def import_object_type(self, implementation, *, allow_skip=False):
243249
class _HashFuncInfo(_HashInfoBase):
244250
"""Dataclass containing information for hash functions constructors.
245251
252+
- *canonical_name* must be a _HashId.
253+
246254
- *builtin* is the fully-qualified name of the HACL*
247255
hash constructor function, e.g., "_md5.md5".
248256
@@ -289,22 +297,14 @@ def method_name(self, implementation):
289297
class _HashInfo:
290298
"""Dataclass containing information for supported hash functions.
291299
292-
- *builtin_object_type_fullname* is the fully-qualified name
293-
for the builtin HACL* type, e.g., "_md5.MD5Type".
294-
295-
- *openssl_object_type_fullname* is the fully-qualified name
296-
for the OpenSSL wrapper type, i.e. "_hashlib.HASH" or "_hashlib.HASHXOF".
297-
298-
- *builtin_method_fullname* is the fully-qualified name
299-
of the HACL* hash constructor function, e.g., "_md5.md5".
300-
301-
- *openssl_method_fullname* is the fully-qualified name
302-
of the "_hashlib" module method for the explicit OpenSSL
303-
hash constructor function, e.g., "_hashlib.openssl_md5".
304-
305-
- *hashlib_method_fullname* is the fully-qualified name
306-
of the "hashlib" module method for the explicit hash
307-
constructor function, e.g., "hashlib.md5".
300+
Attributes
301+
----------
302+
canonical_name : _HashId
303+
The hash function canonical name.
304+
type : _HashTypeInfo
305+
The hash object types information.
306+
func : _HashTypeInfo
307+
The hash object constructors information.
308308
"""
309309

310310
def __init__(
@@ -316,6 +316,27 @@ def __init__(
316316
openssl_method_fullname=None,
317317
hashlib_method_fullname=None,
318318
):
319+
"""
320+
- *canonical_name* must be a _HashId.
321+
322+
- *builtin_object_type_fullname* is the fully-qualified name
323+
for the builtin HACL* type, e.g., "_md5.MD5Type".
324+
325+
- *openssl_object_type_fullname* is the fully-qualified name
326+
for the OpenSSL wrapper type, e.g., "_hashlib.HASH".
327+
328+
- *builtin_method_fullname* is the fully-qualified name
329+
of the HACL* hash constructor function, e.g., "_md5.md5".
330+
331+
- *openssl_method_fullname* is the fully-qualified name
332+
of the "_hashlib" module method for the explicit OpenSSL
333+
hash constructor function, e.g., "_hashlib.openssl_md5".
334+
335+
- *hashlib_method_fullname* is the fully-qualified name
336+
of the "hashlib" module method for the explicit hash
337+
constructor function, e.g., "hashlib.md5".
338+
"""
339+
assert isinstance(canonical_name, _HashId), canonical_name
319340
self.canonical_name = canonical_name
320341
self.type = _HashTypeInfo(
321342
canonical_name,

0 commit comments

Comments
 (0)