diff --git a/markup.py b/markup.py index f6dbbbb..7c30d77 100755 --- a/markup.py +++ b/markup.py @@ -18,7 +18,7 @@ import functools import random import re import string -from typing import Protocol +from typing import Optional, Protocol NAME_CHARS = string.ascii_letters + string.digits @@ -196,7 +196,7 @@ class MarkupParser: ################################################################################ -def render(text: str, ctx: MarkupContext | None = None) -> str: +def render(text: str, ctx: Optional[MarkupContext] = None) -> str: if not ctx: ctx = default_context() assert ctx @@ -210,7 +210,7 @@ def render(text: str, ctx: MarkupContext | None = None) -> str: def macro_random( - ctx: MarkupContext, first: str | None = None, second: str | None = None, *tail: str + ctx: MarkupContext, first: Optional[str] = None, second: Optiona[str] = None, *tail: str ) -> str: """ Choose a random number. @@ -237,7 +237,7 @@ def macro_choose(ctx: MarkupContext, *choices: str): return random.choice(choices) -def macro_round(ctx: MarkupContext, n: str, digits: str | None = None) -> str: +def macro_round(ctx: MarkupContext, n: str, digits: Optional[str] = None) -> str: "round() function, same as Python's." if digits: res = round(float(n), int(digits))