From af02c410e5d985f12b60d95f8f06e7539171a857 Mon Sep 17 00:00:00 2001 From: ldericher <40151420+ldericher@users.noreply.github.com> Date: Tue, 12 Oct 2021 19:08:35 +0200 Subject: [PATCH] config.py imports --- kiwi_scp/config.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kiwi_scp/config.py b/kiwi_scp/config.py index ea5ba12..9efe0e2 100644 --- a/kiwi_scp/config.py +++ b/kiwi_scp/config.py @@ -2,27 +2,27 @@ from ipaddress import IPv4Network from pathlib import Path from typing import Optional, Dict, List -import pydantic +from pydantic import BaseModel, constr, root_validator, validator from ._constants import RE_SEMVER, RE_VARNAME -class _Storage(pydantic.BaseModel): +class _Storage(BaseModel): """a storage subsection""" directory: Path -class _Project(pydantic.BaseModel): +class _Project(BaseModel): """a project subsection""" - name: pydantic.constr( + name: constr( regex=RE_VARNAME ) enabled: bool = True override_storage: Optional[_Storage] - @pydantic.root_validator(pre=True) + @root_validator(pre=True) @classmethod def unify_project(cls, values): """parse different project notations""" @@ -46,20 +46,20 @@ class _Project(pydantic.BaseModel): raise ValueError -class _Network(pydantic.BaseModel): +class _Network(BaseModel): """a network subsection""" - name: pydantic.constr( + name: constr( to_lower=True, regex=RE_VARNAME ) cidr: IPv4Network -class Config(pydantic.BaseModel): +class Config(BaseModel): """represents a kiwi.yml""" - version: pydantic.constr( + version: constr( regex=RE_SEMVER ) shells: Optional[List[str]] @@ -69,7 +69,7 @@ class Config(pydantic.BaseModel): storage: _Storage network: _Network - @pydantic.validator("environment", pre=True) + @validator("environment", pre=True) @classmethod def unify_environment(cls, value) -> Optional[Dict[str, Optional[str]]]: """parse different environment notations"""