diff --git a/src/octoprint/schema/__init__.py b/src/octoprint/schema/__init__.py index 3103d3cb6..e6938842c 100644 --- a/src/octoprint/schema/__init__.py +++ b/src/octoprint/schema/__init__.py @@ -1,2 +1,9 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" + +from pydantic import BaseModel as PydanticBaseModel + + +class BaseModel(PydanticBaseModel): + class Config: + use_enum_values = True diff --git a/src/octoprint/schema/config/__init__.py b/src/octoprint/schema/config/__init__.py index 59b6582cb..32cc388df 100644 --- a/src/octoprint/schema/config/__init__.py +++ b/src/octoprint/schema/config/__init__.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import List, Union -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs from .access_control import AccessControlConfig diff --git a/src/octoprint/schema/config/access_control.py b/src/octoprint/schema/config/access_control.py index f84aa5425..051ed5f46 100644 --- a/src/octoprint/schema/config/access_control.py +++ b/src/octoprint/schema/config/access_control.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import List, Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/api.py b/src/octoprint/schema/config/api.py index 300b56e71..24252d02c 100644 --- a/src/octoprint/schema/config/api.py +++ b/src/octoprint/schema/config/api.py @@ -1,16 +1,15 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" -from typing import Dict - -from pydantic import BaseModel +from typing import Dict, Optional +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs @with_attrs_docs class ApiConfig(BaseModel): - key: str = None + key: Optional[str] = None """Global API key, deprecated, use User API keys instead. Unset by default, will be generated on first run.""" apps: Dict[str, str] = {} diff --git a/src/octoprint/schema/config/appearance.py b/src/octoprint/schema/config/appearance.py index c136acd74..f72cd25ca 100644 --- a/src/octoprint/schema/config/appearance.py +++ b/src/octoprint/schema/config/appearance.py @@ -4,8 +4,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum from typing import List -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs @@ -141,7 +140,7 @@ class AppearanceConfig(BaseModel): name: str = "" """Use this to give your OctoPrint instance a name. It will be displayed in the title bar (as " [OctoPrint]") and in the navigation bar (as "OctoPrint: <>")""" - color: ColorEnum = "default" + color: ColorEnum = ColorEnum.default """Use this to color the navigation bar.""" colorTransparent: bool = False diff --git a/src/octoprint/schema/config/controls.py b/src/octoprint/schema/config/controls.py index 39fbf486f..a74b7addf 100644 --- a/src/octoprint/schema/config/controls.py +++ b/src/octoprint/schema/config/controls.py @@ -4,9 +4,9 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum from typing import List, Optional, Union -from pydantic import BaseModel +from pydantic_settings import with_attrs_docs -from octoprint.vendor.with_attrs_docs import with_attrs_docs +from octoprint.schema import BaseModel class LayoutEnum(str, Enum): @@ -47,7 +47,7 @@ class ContainerConfig(BaseModel): name: Optional[str] = None """A name to display above the container, basically a section header.""" - layout: LayoutEnum = "vertical" + layout: LayoutEnum = LayoutEnum.vertical """The layout to use for laying out the contained children, either from top to bottom (`vertical`) or from left to right (`horizontal`).""" diff --git a/src/octoprint/schema/config/devel.py b/src/octoprint/schema/config/devel.py index 9a6759d12..569328963 100644 --- a/src/octoprint/schema/config/devel.py +++ b/src/octoprint/schema/config/devel.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs @@ -38,7 +37,7 @@ class DevelCacheConfig(BaseModel): @with_attrs_docs class DevelConfig(BaseModel): - stylesheet: StylesheetEnum = "css" + stylesheet: StylesheetEnum = StylesheetEnum.css """Settings for stylesheet preference. OctoPrint will prefer to use the stylesheet type specified here. Usually (on a production install) that will be the compiled css (default). Developers may specify less here too.""" cache: DevelCacheConfig = DevelCacheConfig() diff --git a/src/octoprint/schema/config/estimation.py b/src/octoprint/schema/config/estimation.py index 9675b0522..3240afcff 100644 --- a/src/octoprint/schema/config/estimation.py +++ b/src/octoprint/schema/config/estimation.py @@ -1,8 +1,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/events.py b/src/octoprint/schema/config/events.py index a27e5aeea..ae8652a5d 100644 --- a/src/octoprint/schema/config/events.py +++ b/src/octoprint/schema/config/events.py @@ -4,8 +4,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum from typing import List -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/feature.py b/src/octoprint/schema/config/feature.py index 154a59405..98d70e5de 100644 --- a/src/octoprint/schema/config/feature.py +++ b/src/octoprint/schema/config/feature.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import List -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/folder.py b/src/octoprint/schema/config/folder.py index fbfcbeef5..91f1147e3 100644 --- a/src/octoprint/schema/config/folder.py +++ b/src/octoprint/schema/config/folder.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/gcode_analysis.py b/src/octoprint/schema/config/gcode_analysis.py index 9141e3d5e..1a442f1a0 100644 --- a/src/octoprint/schema/config/gcode_analysis.py +++ b/src/octoprint/schema/config/gcode_analysis.py @@ -3,15 +3,14 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs class RunAtEnum(str, Enum): - never: str = "never" - idle: str = "idle" - always: str = "always" + never = "never" + idle = "idle" + always = "always" @with_attrs_docs @@ -28,7 +27,7 @@ class GcodeAnalysisConfig(BaseModel): throttle_lines: int = 100 """GCODE line batch size.""" - runAt: RunAtEnum = "idle" + runAt: RunAtEnum = RunAtEnum.idle """Whether to run the analysis only when idle (not printing), regardless of printing state or never.""" bedZ: float = 0.0 diff --git a/src/octoprint/schema/config/plugins.py b/src/octoprint/schema/config/plugins.py index d689ae1f9..02163aaf6 100644 --- a/src/octoprint/schema/config/plugins.py +++ b/src/octoprint/schema/config/plugins.py @@ -3,8 +3,9 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import Dict, List -from pydantic import BaseModel, Field +from pydantic import Field +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/printer_parameters.py b/src/octoprint/schema/config/printer_parameters.py index 387a53681..eec603151 100644 --- a/src/octoprint/schema/config/printer_parameters.py +++ b/src/octoprint/schema/config/printer_parameters.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import List -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/printer_profiles.py b/src/octoprint/schema/config/printer_profiles.py index b4f6852d4..bd04a47b7 100644 --- a/src/octoprint/schema/config/printer_profiles.py +++ b/src/octoprint/schema/config/printer_profiles.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/scripts.py b/src/octoprint/schema/config/scripts.py index 16e8ee1e8..06fb4bd9d 100644 --- a/src/octoprint/schema/config/scripts.py +++ b/src/octoprint/schema/config/scripts.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import Dict, Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/serial.py b/src/octoprint/schema/config/serial.py index 53a8b99a9..61d453580 100644 --- a/src/octoprint/schema/config/serial.py +++ b/src/octoprint/schema/config/serial.py @@ -4,8 +4,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum from typing import List, Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/server.py b/src/octoprint/schema/config/server.py index c85e113cf..5124abf6b 100644 --- a/src/octoprint/schema/config/server.py +++ b/src/octoprint/schema/config/server.py @@ -4,8 +4,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum from typing import Dict, List, Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs CONST_15MIN = 15 * 60 diff --git a/src/octoprint/schema/config/slicing.py b/src/octoprint/schema/config/slicing.py index 1fcd3b0ab..8b24b6618 100644 --- a/src/octoprint/schema/config/slicing.py +++ b/src/octoprint/schema/config/slicing.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import Dict, Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/system.py b/src/octoprint/schema/config/system.py index 41794a821..b27a852d2 100644 --- a/src/octoprint/schema/config/system.py +++ b/src/octoprint/schema/config/system.py @@ -3,8 +3,9 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import List, Optional -from pydantic import BaseModel, Field +from pydantic import Field +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/temperature.py b/src/octoprint/schema/config/temperature.py index f09cc2987..e331be1ea 100644 --- a/src/octoprint/schema/config/temperature.py +++ b/src/octoprint/schema/config/temperature.py @@ -3,8 +3,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from typing import List -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/terminalfilters.py b/src/octoprint/schema/config/terminalfilters.py index e2cc38743..923b4677e 100644 --- a/src/octoprint/schema/config/terminalfilters.py +++ b/src/octoprint/schema/config/terminalfilters.py @@ -1,8 +1,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs diff --git a/src/octoprint/schema/config/webcam.py b/src/octoprint/schema/config/webcam.py index c6bfb1826..42587c4cc 100644 --- a/src/octoprint/schema/config/webcam.py +++ b/src/octoprint/schema/config/webcam.py @@ -4,8 +4,7 @@ __copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms from enum import Enum from typing import List, Optional -from pydantic import BaseModel - +from octoprint.schema import BaseModel from octoprint.vendor.with_attrs_docs import with_attrs_docs @@ -34,7 +33,7 @@ class TimelapseOptions(BaseModel): @with_attrs_docs class TimelapseConfig(BaseModel): - type: TimelapseTypeEnum = "off" + type: TimelapseTypeEnum = TimelapseTypeEnum.off """The timelapse type.""" fps: int = 25