From 10a2374051568edf3d872988e730328d899a0fdd Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 3 Nov 2021 12:29:39 -0700 Subject: typing: first batch of python bulk type annotations While these changes are more delicate than simple lint changes, this specific batch of edits and annotations was *relatively* simple, and resulted in few code changes other than function signature additions. --- python/fatcat_tools/fcid.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'python/fatcat_tools/fcid.py') diff --git a/python/fatcat_tools/fcid.py b/python/fatcat_tools/fcid.py index 53891e5a..07463f62 100644 --- a/python/fatcat_tools/fcid.py +++ b/python/fatcat_tools/fcid.py @@ -2,17 +2,17 @@ import base64 import uuid -def fcid2uuid(s): +def fcid2uuid(fcid: str) -> str: """ Converts a fatcat identifier (base32 encoded string) to a uuid.UUID object """ - s = s.split("_")[-1].upper().encode("utf-8") - assert len(s) == 26 - raw = base64.b32decode(s + b"======") - return str(uuid.UUID(bytes=raw)).lower() + b = fcid.split("_")[-1].upper().encode("utf-8") + assert len(b) == 26 + raw_bytes = base64.b32decode(b + b"======") + return str(uuid.UUID(bytes=raw_bytes)).lower() -def uuid2fcid(s): +def uuid2fcid(s: str) -> str: """ Converts a uuid.UUID object to a fatcat identifier (base32 encoded string) """ @@ -20,6 +20,6 @@ def uuid2fcid(s): return base64.b32encode(raw)[:26].lower().decode("utf-8") -def test_fcid(): +def test_fcid() -> None: test_uuid = "00000000-0000-0000-3333-000000000001" assert test_uuid == fcid2uuid(uuid2fcid(test_uuid)) -- cgit v1.2.3