Skip to content

Commit 029d5a0

Browse files
authored
Merge pull request #26 from fastapi-startkit/inertia-ping-crm
feat: inertia ping crm
2 parents 99e5ba3 + 3a1cf94 commit 029d5a0

208 files changed

Lines changed: 3054 additions & 1384 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fastapi_startkit/pyproject.toml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fastapi-startkit"
3-
version = "0.13.7"
3+
version = "0.13.6"
44
description = "Fastapi Starter kit components"
55
authors = [
66
{name = "Bedram Tamang", email = "tmgbedu@gmail.com"}
@@ -46,7 +46,6 @@ dev = [
4646
"dumpdie>=1.5.0",
4747
"pytest>=9.0.3",
4848
"pytest-asyncio>=1.3.0",
49-
"ruff>=0.15.12",
5049
"twine>=6.2.0",
5150
]
5251

@@ -60,14 +59,3 @@ build-backend = "uv_build"
6059

6160
[tool.uv]
6261
workspace = { members = ["application", "example/*"] }
63-
64-
[tool.ruff]
65-
line-length = 120
66-
67-
[tool.ruff.lint]
68-
select = ["E", "F", "I"]
69-
ignore = ["E501"]
70-
fixable = ["ALL"]
71-
72-
[tool.ruff.lint.per-file-ignores]
73-
"__init__.py" = ["F401"]

fastapi_startkit/src/fastapi_startkit/application.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import os
22
from pathlib import Path
3-
from typing import TYPE_CHECKING, Any, Callable, Generic, List, Optional, Type, TypeVar
3+
from typing import TYPE_CHECKING, Optional
4+
from typing import Type, Callable, Any, List, TypeVar, Generic
45

56
from fastapi_startkit.providers.app_provider import AppProvider
6-
77
from .config import AppConfig
88
from .configuration.providers import ConfigurationProvider
99
from .container import Container
1010
from .environment.environment import LoadEnvironment
1111

1212
if TYPE_CHECKING:
13-
from fastapi import APIRouter, FastAPI
13+
from fastapi import FastAPI, APIRouter
1414
from starlette.middleware.base import BaseHTTPMiddleware
1515

1616
from fastapi_startkit.exceptions import ExceptionHandler
@@ -64,7 +64,9 @@ def __init__(
6464
self.load_providers()
6565

6666
def configure_exception_handler(self):
67-
self.exception_manager: ExceptionHandler = self._exception_handler_class(application=self)
67+
self.exception_manager: ExceptionHandler = self._exception_handler_class(
68+
application=self
69+
)
6870
self.exception_manager.register()
6971
self.exception_manager.install()
7072
self.bind("exception_manager", self.exception_manager)
@@ -75,8 +77,6 @@ def register_providers(self):
7577
config = {}
7678
if isinstance(provider_data, tuple):
7779
provider_class, config = provider_data
78-
if callable(config):
79-
config = config()
8080
else:
8181
provider_class = provider_data
8282

@@ -129,8 +129,9 @@ def include_router(self, router: "APIRouter", **kwargs):
129129
return self
130130

131131
# Add middleware
132-
def add_middleware(self, middleware_class: type[Any], *args: Any, **kwargs: Any) -> None:
133-
self._fastapi.add_middleware(middleware_class, *args, **kwargs)
132+
def add_middleware(self, middleware_class: Type["BaseHTTPMiddleware"], **options):
133+
self._fastapi.add_middleware(middleware_class, **options)
134+
return self
134135

135136
# Add event handlers (startup/shutdown)
136137
def add_event_handler(self, event_type: str, func: Callable[..., Any]):
@@ -143,7 +144,9 @@ def mount(self, path: str, app_instance: "FastAPI", **kwargs):
143144
return self
144145

145146
# Add custom exception handlers
146-
def add_exception_handler(self, exc_class_or_status_code: Any, handler: Callable[..., Any]):
147+
def add_exception_handler(
148+
self, exc_class_or_status_code: Any, handler: Callable[..., Any]
149+
):
147150
self._fastapi.add_exception_handler(exc_class_or_status_code, handler)
148151
return self
149152

@@ -153,7 +156,9 @@ def fastapi(self) -> "FastAPI":
153156
try:
154157
from fastapi import FastAPI
155158
except ImportError:
156-
raise RuntimeError("FastAPI is not installed. Install it with: pip install fastapi")
159+
raise RuntimeError(
160+
"FastAPI is not installed. Install it with: pip install fastapi"
161+
)
157162
self._fastapi = FastAPI()
158163
# Making the type hint work
159164
assert self._fastapi is not None

fastapi_startkit/src/fastapi_startkit/collection/collection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ def pluck(self, value, key=None, keep_nulls=True):
276276

277277
if k == value:
278278
if key:
279-
attributes[self._data_get(item, key)] = self._data_get(item, value)
279+
attributes[self._data_get(item, key)] = self._data_get(
280+
item, value
281+
)
280282
else:
281283
attributes.append(v)
282284

fastapi_startkit/src/fastapi_startkit/commands/publish_command.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from cleo.commands.command import Command
66
from cleo.helpers import option
7-
87
from fastapi_startkit.helpers.string import Str
98

109
if TYPE_CHECKING:
@@ -16,7 +15,12 @@ class PublishCommand(Command):
1615
description = "Publish provider config files into the project."
1716

1817
options = [
19-
option("provider", "p", description="Provider name to publish (e.g. LogProvider, log_provider).", flag=False),
18+
option(
19+
"provider",
20+
"p",
21+
description="Provider name to publish (e.g. LogProvider, log_provider).",
22+
flag=False,
23+
),
2024
]
2125

2226
def handle(self):
@@ -33,10 +37,14 @@ def handle(self):
3337
if provider_arg:
3438
target = Str.slugify(provider_arg)
3539
resources = {
36-
name: files for name, files in application.published_resources.items() if Str.slugify(name) == target
40+
name: files
41+
for name, files in application.published_resources.items()
42+
if Str.slugify(name) == target
3743
}
3844
if not resources:
39-
self.line(f"<error>No provider found matching '{provider_arg}'.</error>")
45+
self.line(
46+
f"<error>No provider found matching '{provider_arg}'.</error>"
47+
)
4048
return
4149
else:
4250
resources = application.published_resources
@@ -47,10 +55,13 @@ def handle(self):
4755

4856
if os.path.exists(dest_path):
4957
overwrite = self.confirm(
50-
f" <comment>{destination}</comment> already exists. Overwrite?", default=False
58+
f" <comment>{destination}</comment> already exists. Overwrite?",
59+
default=False,
5160
)
5261
if not overwrite:
53-
self.line(f" [{provider_key}] Skipped <comment>{destination}</comment>")
62+
self.line(
63+
f" [{provider_key}] Skipped <comment>{destination}</comment>"
64+
)
5465
continue
5566

5667
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os
2-
from dataclasses import dataclass, field
3-
2+
from dataclasses import field, dataclass
43
from fastapi_startkit.environment.environment import env
54

65

76
@dataclass
87
class AppConfig:
9-
name: str = field(default_factory=lambda: os.getenv("APP_NAME", "FastAPI starter kit"))
8+
name: str = field(
9+
default_factory=lambda: os.getenv("APP_NAME", "FastAPI starter kit")
10+
)
1011
env: str = field(default_factory=lambda: os.getenv("APP_ENV", "development"))
1112
debug: bool = field(default_factory=lambda: env("APP_DEBUG", "true"))
1213
timezone: str = field(default_factory=lambda: os.getenv("APP_TIMEZONE", "UTC"))

fastapi_startkit/src/fastapi_startkit/config/facades/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Type, TypeVar
1+
from typing import TypeVar, Type, TYPE_CHECKING
22

33
if TYPE_CHECKING:
44
from fastapi_startkit.config import AppConfig

fastapi_startkit/src/fastapi_startkit/configuration/Configuration.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from fastapi_startkit.loader import Loader
2-
3-
from ..exceptions import InvalidConfigurationSetup
42
from ..utils.structures import data
3+
from ..exceptions import InvalidConfigurationLocation, InvalidConfigurationSetup
54

65

76
class Configuration:
@@ -27,7 +26,9 @@ def __init__(self, application):
2726
def load(self):
2827
"""At boot load configuration from all files and store them in here."""
2928
config_root = self.application.make("config.location")
30-
for module_name, module in Loader().get_modules(config_root, raise_exception=True).items():
29+
for module_name, module in (
30+
Loader().get_modules(config_root, raise_exception=True).items()
31+
):
3132
params = Loader().get_parameters(module)
3233
for name, value in params.items():
3334
self._config[f"{module_name}.{name.lower()}"] = value
@@ -41,7 +42,9 @@ def merge_with(self, path, external_config):
4142
(such as 'application').
4243
"""
4344
if path in self.reserved_keys:
44-
raise InvalidConfigurationSetup(f"{path} is a reserved configuration key name. Please use an other key.")
45+
raise InvalidConfigurationSetup(
46+
f"{path} is a reserved configuration key name. Please use an other key."
47+
)
4548
if isinstance(external_config, str):
4649
# config is a path and should be loaded
4750
params = Loader().get_parameters(external_config)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .Configuration import Configuration
21
from .helpers import config
2+
from .Configuration import Configuration

fastapi_startkit/src/fastapi_startkit/configuration/providers/ConfigurationProvider.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ...providers import Provider
2+
23
from ..Configuration import Configuration
34

45

fastapi_startkit/src/fastapi_startkit/console.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from cleo.application import Application as BaseApplication
22
from cleo.io.io import IO
3-
43
from fastapi_startkit.application import Application
54

65

0 commit comments

Comments
 (0)