Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12.6
3.13
14 changes: 7 additions & 7 deletions examples/pydantic_source/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi import FastAPI
from typing import Type, Tuple, Any
from typing import Any

from pydantic import Field, BaseModel
from pydantic_settings import (
Expand Down Expand Up @@ -65,12 +65,12 @@ class RRTreeSource(BaseSettings):
@classmethod
def settings_customise_sources(
cls,
settings_cls: Type[BaseSettings],
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]:
) -> tuple[PydanticBaseSettingsSource, ...]:
return (
init_settings,
ConfigTreeSource(
Expand Down Expand Up @@ -121,12 +121,12 @@ class RRTreeSourceWithPrefix(BaseSettings):
@classmethod
def settings_customise_sources(
cls,
settings_cls: Type[BaseSettings],
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]:
) -> tuple[PydanticBaseSettingsSource, ...]:
return (
init_settings,
ConfigTreeSource(
Expand Down Expand Up @@ -204,12 +204,12 @@ class RRTreeSourceLocal(BaseSettings):
@classmethod
def settings_customise_sources(
cls,
settings_cls: Type[BaseSettings],
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]:
) -> tuple[PydanticBaseSettingsSource, ...]:
return (
init_settings,
ConfigTreeSource(
Expand Down
13 changes: 7 additions & 6 deletions pydantic_source/source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ast
from typing import Any, Type, Dict, Iterable
from typing import Any
from collections.abc import Iterable
from benedict import benedict
from pathlib import Path

Expand All @@ -13,7 +14,7 @@
class ConfigTreeSource(PydanticBaseSettingsSource):
def __init__(
self,
settings_cls: Type["BaseSettings"],
settings_cls: type["BaseSettings"],
config: Configuration,
tree_name: str = "default",
key_prefix: str = "",
Expand Down Expand Up @@ -74,7 +75,7 @@ def _load_config_tree(self):
return processed_data

# * Methods to process the tree
def _extract_data_api(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
def _extract_data_api(self, input_data: dict[str, Any]) -> dict[str, Any]:
return {
key: self._decode_value(value.get("data"))
for key, value in input_data.items()
Expand Down Expand Up @@ -119,8 +120,8 @@ def _split_metadata(self, data: Iterable) -> Iterable:
return content

# * This method is extracting the data from the raw data and removing the top level prefix
def _process_config_tree(self, raw_data: Dict[str, Any]) -> Dict[str, Any]:
d: Dict[str, Any] = {}
def _process_config_tree(self, raw_data: dict[str, Any]) -> dict[str, Any]:
d: dict[str, Any] = {}
prefix_length = len(self._top_prefix)

if prefix_length == 0:
Expand All @@ -135,7 +136,7 @@ def _process_config_tree(self, raw_data: Dict[str, Any]) -> Dict[str, Any]:
def __call__(self) -> dict[str, Any]:
if self.settings_cls.model_config.get("extra") == "allow":
return self._configtree_data
d: Dict[str, Any] = {}
d: dict[str, Any] = {}

for field_name, field in self.settings_cls.model_fields.items():
field_value, field_key, value_is_complex = self.get_field_value(
Expand Down
10 changes: 3 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ dynamic = ["version"]
description = "Python SDK for rapyuta.io v2 APIs"
dependencies = [
"httpx>=0.27.2",
"munch>=4.0.0",
"pydantic-settings>=2.7.1",
"python-benedict>=0.34.1",
"pyyaml>=6.0.2",
]
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">= 3.8"
requires-python = ">= 3.10"

[build-system]
requires = ["hatchling"]
Expand Down Expand Up @@ -74,18 +73,15 @@ exclude = [
"venv",
]

# Same as Black.
target-version = "py310"
line-length = 90
indent-width = 4

# Assume Python 3.8
target-version = "py38"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "B", "Q", "W", "N816"]
select = ["E4", "E7", "E9", "F", "B", "Q", "W", "N816", "UP"]
ignore = ["E741", "B904"]

# Allow fix for all enabled rules (when `--fix`) is provided.
Expand Down
31 changes: 30 additions & 1 deletion rapyuta_io_sdk_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,33 @@
from rapyuta_io_sdk_v2.config import Configuration
from rapyuta_io_sdk_v2.utils import walk_pages

__version__ = "0.0.1"
# Import all models directly into the main namespace
from .models import (
# Core models
Secret,
StaticRoute,
Disk,
Deployment,
Package,
Project,
Network,
User,
Organization,
# List models
ProjectList,
DeploymentList,
DiskList,
NetworkList,
PackageList,
SecretList,
StaticRouteList,
# Managed service models
ManagedServiceProvider,
ManagedServiceBinding,
ManagedServiceBindingList,
ManagedServiceInstance,
ManagedServiceInstanceList,
ManagedServiceProviderList,
)

__version__ = "0.3.0"
Loading