<filename>src/piper/package/piper/config/sanitizers/python_sanitizer.py<gh_stars>1-10
import re
from typing import Optional

from piper.config.sanitizers import asserter

_VERSION = re.compile(r"^\d+\.\d+.\d+$")


def sanitize_version(version: str, nullable: bool = False) -> Optional[str]:
    if version is None and nullable:
        return None
    return asserter.regex(_VERSION, version)

<filename>src/piper/package/piper/config/sanitizers/python_sanitizer.py<gh_stars>1-10
import re
from typing import Optional

from piper.config.sanitizers import asserter

_VERSION = re.compile(r"^\d+\.\d+.\d+$")


def sanitize_version(version: str, nullable: bool = False) -> Optional[str]:
    if version is None and nullable:
        return None
    return asserter.regex(_VERSION, version)
