Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cms/grading/scoretypes/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

"""

import functools
import logging
import re
from typing import TypedDict, NotRequired
Expand All @@ -54,6 +55,11 @@ def N_(message: str):
return message


@functools.lru_cache(maxsize=None)
def _compile_template(template: str) -> Template:
return GLOBAL_ENVIRONMENT.from_string(template)


class ScoreType(metaclass=ABCMeta):
"""Base class for all score types, that must implement all methods
defined here.
Expand Down Expand Up @@ -91,7 +97,7 @@ def __init__(
"values for the score type parameters): %s." % e
)

self.template: Template = GLOBAL_ENVIRONMENT.from_string(self.TEMPLATE)
self.template: Template = _compile_template(self.TEMPLATE)

@staticmethod
def format_score(
Expand Down
Loading