Skip to content

Commit

Permalink
Runs bump-pydantic script
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort committed Jul 6, 2023
1 parent 2dc194a commit 3fdce88
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions quota_notifier/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from tempfile import NamedTemporaryFile
from typing import Any, List, Literal, Optional, Set, Tuple, Union

from pydantic import BaseSettings, Field, validator
from pydantic import field_validator, Field
from pydantic_settings import BaseSettings

DEFAULT_DB_PATH = Path.cwd().resolve() / 'notifier_data.db'

Expand Down Expand Up @@ -42,7 +43,8 @@ class FileSystemSchema(BaseSettings):
title='Notification Thresholds',
description='Usage percentages to issue notifications for.')

@validator('name')
@field_validator('name')
@classmethod
def validate_name(cls, value: str) -> str:
"""Ensure the given name is not blank
Expand All @@ -59,7 +61,8 @@ def validate_name(cls, value: str) -> str:

return stripped

@validator('path')
@field_validator('path')
@classmethod
def validate_path(cls, value: Path) -> Path:
"""Ensure the given system path exists
Expand All @@ -78,7 +81,8 @@ def validate_path(cls, value: Path) -> Path:

return value

@validator('thresholds')
@field_validator('thresholds')
@classmethod
def validate_thresholds(cls, value: list) -> list:
"""Validate threshold values are between 0 and 100 (exclusive)
Expand Down Expand Up @@ -188,7 +192,8 @@ class SettingsSchema(BaseSettings):
default=False,
description='Disable database commits and email notifications. Useful for development and testing.')

@validator('file_systems')
@field_validator('file_systems')
@classmethod
def validate_unique_file_systems(cls, value: List[FileSystemSchema]) -> List[FileSystemSchema]:
"""Ensure file systems have unique names/paths
Expand Down

0 comments on commit 3fdce88

Please sign in to comment.