Skip to content

Commit

Permalink
tests/utils.py: annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
juha-aiven committed May 12, 2021
1 parent b31f95f commit deb77bb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass
from kafka.errors import TopicAlreadyExistsError
from karapace.utils import Client
from typing import List
from typing import Callable, List
from urllib.parse import quote

import asyncio
Expand Down Expand Up @@ -212,22 +212,22 @@ def new_random_name(prefix: str) -> str:
return f"{prefix}{suffix}"


def create_subject_name_factory(prefix: str) -> str:
def create_subject_name_factory(prefix: str) -> Callable[[], str]:
return create_id_factory(f"subject-{prefix}")


def create_field_name_factory(prefix: str) -> str:
def create_field_name_factory(prefix: str) -> Callable[[], str]:
return create_id_factory(f"field-{prefix}")


def create_id_factory(prefix: str) -> str:
def create_id_factory(prefix: str) -> Callable[[], str]:
"""
Creates unique ids prefixed with prefix..
The resulting ids are safe to embed in URLs.
"""
index = 1

def create_name():
def create_name() -> str:
nonlocal index
random_name = str(uuid.uuid4())[:8]
name = f"{quote(prefix).replace('/', '_')}_{index}_{random_name}"
Expand Down

0 comments on commit deb77bb

Please sign in to comment.