Files
concrete/hdk/utils/misc.py
Arthur Meyre 36d93a60d9 chore(tools): add mypy as dev tool but don't check in CI for now
- we'll see if the benefits of static typing are worth it or not
2021-07-19 16:25:24 +02:00

19 lines
442 B
Python

"""Misc. utils for hdk"""
from typing import Iterator
def get_unique_id() -> int:
"""Function to get a unique ID"""
if not hasattr(get_unique_id, "generator"):
def generator() -> Iterator[int]:
current_id = 0
while True:
yield current_id
current_id += 1
setattr(get_unique_id, "generator", generator())
return next(getattr(get_unique_id, "generator"))