fastapi-mongo-base 1.3.0__tar.gz → 1.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {fastapi_mongo_base-1.3.0/src/fastapi_mongo_base.egg-info → fastapi_mongo_base-1.3.2}/PKG-INFO +5 -3
  2. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/pyproject.toml +7 -5
  3. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/app_factory.py +6 -7
  4. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/models.py +3 -2
  5. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/routes.py +1 -1
  6. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/schemas.py +7 -3
  7. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/sql.py +2 -1
  8. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/tasks.py +2 -1
  9. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/utils/basic.py +2 -2
  10. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2/src/fastapi_mongo_base.egg-info}/PKG-INFO +5 -3
  11. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base.egg-info/requires.txt +3 -0
  12. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/LICENSE.txt +0 -0
  13. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/MANIFEST.in +0 -0
  14. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/README.md +0 -0
  15. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/boilerplate.md +0 -0
  16. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/changelog.md +0 -0
  17. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/contributing.md +0 -0
  18. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/endpoints.md +0 -0
  19. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/extra.css +0 -0
  20. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/index.md +0 -0
  21. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/installation.md +0 -0
  22. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/license.md +0 -0
  23. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/quickstart.md +0 -0
  24. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/settings.md +0 -0
  25. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/tutorial.md +0 -0
  26. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/docs/usage.md +0 -0
  27. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/mkdocs.yml +0 -0
  28. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/pytest.ini +0 -0
  29. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/setup.cfg +0 -0
  30. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/__init__.py +0 -0
  31. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/__init__.py +0 -0
  32. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/config.py +0 -0
  33. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/db.py +0 -0
  34. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/enums.py +0 -0
  35. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/errors/mongodb_errors.py +0 -0
  36. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/errors/resource_errors.py +0 -0
  37. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/core/exceptions.py +0 -0
  38. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/py.typed +0 -0
  39. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/utils/__init__.py +0 -0
  40. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/utils/bsontools.py +0 -0
  41. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/utils/timezone.py +0 -0
  42. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base/utils/usso_routes.py +0 -0
  43. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base.egg-info/SOURCES.txt +0 -0
  44. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base.egg-info/dependency_links.txt +0 -0
  45. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/src/fastapi_mongo_base.egg-info/top_level.txt +0 -0
  46. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/__init__.py +0 -0
  47. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/app/__init__.py +0 -0
  48. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/app/logs/app.log +0 -0
  49. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/app/main.py +0 -0
  50. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/app/server.py +0 -0
  51. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/conftest.py +0 -0
  52. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/test_apis.py +0 -0
  53. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/test_app.py +0 -0
  54. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/test_mongodb_errors.py +0 -0
  55. {fastapi_mongo_base-1.3.0 → fastapi_mongo_base-1.3.2}/tests/test_resource_errors.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-mongo-base
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -15,11 +15,12 @@ Classifier: Development Status :: 3 - Alpha
15
15
  Classifier: Intended Audience :: Developers
16
16
  Classifier: Topic :: Software Development :: Build Tools
17
17
  Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
18
20
  Classifier: Programming Language :: Python :: 3.12
19
21
  Classifier: Programming Language :: Python :: 3.13
20
- Classifier: Programming Language :: Python :: 3.14
21
22
  Classifier: Programming Language :: Python :: 3 :: Only
22
- Requires-Python: >=3.12
23
+ Requires-Python: >=3.10
23
24
  Description-Content-Type: text/markdown
24
25
  License-File: LICENSE.txt
25
26
  Requires-Dist: pydantic>=2.13.4
@@ -31,6 +32,7 @@ Requires-Dist: beanie>=1.30.0
31
32
  Requires-Dist: fastapi>=0.129.0
32
33
  Requires-Dist: uvicorn[standard]>=0.41.0
33
34
  Requires-Dist: uuid6>=2025.0.1
35
+ Requires-Dist: typing_extensions>=4.5.0; python_version < "3.11"
34
36
  Provides-Extra: usso
35
37
  Requires-Dist: usso>=0.30.1; extra == "usso"
36
38
  Provides-Extra: sql
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fastapi-mongo-base"
7
- version = "1.3.0"
7
+ version = "1.3.2"
8
8
  description = "A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB"
9
9
  readme = "README.md"
10
- requires-python = ">=3.12"
10
+ requires-python = ">=3.10"
11
11
  license = "MIT"
12
12
  license-files = ["LICENSE.txt"]
13
13
  keywords = ["fastapi", "mongodb", "beanie"]
@@ -18,9 +18,10 @@ classifiers = [
18
18
  "Intended Audience :: Developers",
19
19
  "Topic :: Software Development :: Build Tools",
20
20
  "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
21
23
  "Programming Language :: Python :: 3.12",
22
24
  "Programming Language :: Python :: 3.13",
23
- "Programming Language :: Python :: 3.14",
24
25
  "Programming Language :: Python :: 3 :: Only",
25
26
  ]
26
27
  dependencies = [
@@ -33,6 +34,7 @@ dependencies = [
33
34
  "fastapi>=0.129.0",
34
35
  "uvicorn[standard]>=0.41.0",
35
36
  "uuid6>=2025.0.1",
37
+ "typing_extensions>=4.5.0; python_version<'3.11'",
36
38
  ]
37
39
 
38
40
  [project.optional-dependencies]
@@ -52,7 +54,7 @@ package-data = { "usso" = ["*.dat"] }
52
54
 
53
55
  [tool.ruff]
54
56
  line-length = 79
55
- target-version = "py313"
57
+ target-version = "py310"
56
58
  fix = true
57
59
  unsafe-fixes = true
58
60
  preview = true
@@ -92,7 +94,7 @@ ignore = ["TRY003", "COM812", "B008", "D202", "D203", "D209", "D212", "D413"]
92
94
  quote-style = "double"
93
95
 
94
96
  [tool.mypy]
95
- python_version = "3.13"
97
+ python_version = "3.10"
96
98
  ignore_missing_imports = true
97
99
  check_untyped_defs = false
98
100
  disallow_untyped_defs = false
@@ -6,7 +6,6 @@ import logging
6
6
  from collections import deque
7
7
  from collections.abc import AsyncGenerator, Callable
8
8
  from contextlib import asynccontextmanager
9
- from typing import Any
10
9
 
11
10
  import fastapi
12
11
  from fastapi.responses import RedirectResponse
@@ -33,7 +32,7 @@ def health(request: fastapi.Request) -> dict[str, str]:
33
32
  async def lifespan(
34
33
  *,
35
34
  app: fastapi.FastAPI,
36
- worker: Callable[[], Any] | None = None,
35
+ worker: Callable[[], object] | None = None,
37
36
  init_functions: list | None = None,
38
37
  settings: config.Settings | None = None,
39
38
  ) -> AsyncGenerator[None]:
@@ -122,13 +121,13 @@ def get_app_kwargs(
122
121
  title: str | None = None,
123
122
  description: str | None = None,
124
123
  version: str = "0.1.0",
125
- lifespan_func: Callable[[fastapi.FastAPI], Any] | None = None,
126
- worker: Callable[[], Any] | None = None,
124
+ lifespan_func: Callable[[fastapi.FastAPI], object] | None = None,
125
+ worker: Callable[[], object] | None = None,
127
126
  init_functions: list | None = None,
128
127
  contact: dict[str, str] | None = None,
129
128
  license_info: dict[str, str] | None = None,
130
129
  **kwargs: object,
131
- ) -> dict[str, Any]:
130
+ ) -> dict[str, object]:
132
131
  """
133
132
  Generate keyword arguments for FastAPI app creation.
134
133
 
@@ -208,8 +207,8 @@ def create_app(
208
207
  version: str = "0.1.0",
209
208
  serve_coverage: bool = False,
210
209
  origins: list | None = None,
211
- lifespan_func: Callable[[fastapi.FastAPI], Any] | None = None,
212
- worker: Callable[[], Any] | None = None,
210
+ lifespan_func: Callable[[fastapi.FastAPI], object] | None = None,
211
+ worker: Callable[[], object] | None = None,
213
212
  init_functions: list | None = None,
214
213
  contact: dict[str, str] | None = None,
215
214
  license_info: dict[str, str] | None = None,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import logging
4
4
  from datetime import datetime
5
- from typing import Any, ClassVar, Self, cast
5
+ from typing import ClassVar, cast
6
6
 
7
7
  from beanie import (
8
8
  Document,
@@ -16,6 +16,7 @@ from beanie import (
16
16
  from beanie.odm.queries.find import FindMany
17
17
  from pydantic import ConfigDict
18
18
  from pymongo import ASCENDING, IndexModel
19
+ from typing_extensions import Self
19
20
 
20
21
  from .core.config import Settings
21
22
  from .schemas import (
@@ -69,7 +70,7 @@ class BaseEntity(BaseEntitySchema, Document):
69
70
  self.updated_at = datetime.now(timezone.tz)
70
71
 
71
72
  @classmethod
72
- def _build_extra_filters(cls, **kwargs: dict[str, Any]) -> dict:
73
+ def _build_extra_filters(cls, **kwargs: dict[str, object]) -> dict:
73
74
  """
74
75
  Build MongoDB filter dictionary from keyword arguments.
75
76
 
@@ -266,7 +266,7 @@ class AbstractBaseRouter(metaclass=singleton.Singleton):
266
266
  if item is None:
267
267
  raise BaseHTTPException(
268
268
  status_code=404,
269
- error="item_not_found",
269
+ error_code="item_not_found",
270
270
  message={
271
271
  "en": f"{self.model.__name__.capitalize()} not found"
272
272
  },
@@ -1,10 +1,11 @@
1
1
  """Pydantic schemas for entities and responses."""
2
2
 
3
3
  from datetime import datetime
4
- from typing import Self
4
+ from typing import Generic, TypeVar
5
5
 
6
6
  import uuid6
7
7
  from pydantic import BaseModel, ConfigDict, Field, model_validator
8
+ from typing_extensions import Self
8
9
 
9
10
  from .core.config import Settings
10
11
  from .utils import timezone
@@ -153,11 +154,14 @@ class TenantOwnedEntitySchema(TenantScopedEntitySchema, OwnedEntitySchema):
153
154
  return list({*super().update_exclude_set(), "tenant_id", "owner_id"})
154
155
 
155
156
 
156
- class PaginatedResponse[TSCHEMA: BaseModel](BaseModel):
157
+ TSchema = TypeVar("TSchema", bound=BaseModel)
158
+
159
+
160
+ class PaginatedResponse(BaseModel, Generic[TSchema]):
157
161
  """Generic paginated response model for list endpoints."""
158
162
 
159
163
  heads: dict[str, dict[str, str]] = Field(default_factory=dict)
160
- items: list[TSCHEMA]
164
+ items: list[TSchema]
161
165
  total: int
162
166
  offset: int = Field(default=0)
163
167
  limit: int = Field(default=Settings.page_max_limit)
@@ -3,7 +3,8 @@
3
3
  import json
4
4
  import uuid
5
5
  from datetime import datetime
6
- from typing import Never, Self
6
+
7
+ from typing_extensions import Never, Self
7
8
 
8
9
  try:
9
10
  from sqlalchemy import JSON, event, select
@@ -6,11 +6,12 @@ import logging
6
6
  from collections.abc import Coroutine
7
7
  from datetime import datetime
8
8
  from enum import StrEnum
9
- from typing import Literal, Self, Union
9
+ from typing import Literal, Union
10
10
 
11
11
  import json_advanced as json
12
12
  from pydantic import BaseModel, Field, field_serializer, field_validator
13
13
  from singleton import Singleton
14
+ from typing_extensions import Self
14
15
 
15
16
  from .schemas import BaseEntitySchema
16
17
  from .utils import basic, timezone
@@ -237,7 +237,7 @@ def _async_retry_wrapper(
237
237
  if inspect.iscoroutinefunction(func):
238
238
  return await func(*args, **kwargs)
239
239
  return await asyncio.to_thread(func, *args, **kwargs)
240
- except Exception as e:
240
+ except Exception as e: # noqa: PERF203
241
241
  last_exception = e
242
242
  logging.warning(
243
243
  "Attempt %d failed for %s: %s",
@@ -260,7 +260,7 @@ def _sync_retry_wrapper(func: Callable, attempts: int, delay: int) -> Callable:
260
260
  for attempt in range(attempts):
261
261
  try:
262
262
  return func(*args, **kwargs)
263
- except Exception as e:
263
+ except Exception as e: # noqa: PERF203
264
264
  last_exception = e
265
265
  logging.warning(
266
266
  "Attempt %d failed for %s: %s",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-mongo-base
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -15,11 +15,12 @@ Classifier: Development Status :: 3 - Alpha
15
15
  Classifier: Intended Audience :: Developers
16
16
  Classifier: Topic :: Software Development :: Build Tools
17
17
  Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
18
20
  Classifier: Programming Language :: Python :: 3.12
19
21
  Classifier: Programming Language :: Python :: 3.13
20
- Classifier: Programming Language :: Python :: 3.14
21
22
  Classifier: Programming Language :: Python :: 3 :: Only
22
- Requires-Python: >=3.12
23
+ Requires-Python: >=3.10
23
24
  Description-Content-Type: text/markdown
24
25
  License-File: LICENSE.txt
25
26
  Requires-Dist: pydantic>=2.13.4
@@ -31,6 +32,7 @@ Requires-Dist: beanie>=1.30.0
31
32
  Requires-Dist: fastapi>=0.129.0
32
33
  Requires-Dist: uvicorn[standard]>=0.41.0
33
34
  Requires-Dist: uuid6>=2025.0.1
35
+ Requires-Dist: typing_extensions>=4.5.0; python_version < "3.11"
34
36
  Provides-Extra: usso
35
37
  Requires-Dist: usso>=0.30.1; extra == "usso"
36
38
  Provides-Extra: sql
@@ -8,6 +8,9 @@ fastapi>=0.129.0
8
8
  uvicorn[standard]>=0.41.0
9
9
  uuid6>=2025.0.1
10
10
 
11
+ [:python_version < "3.11"]
12
+ typing_extensions>=4.5.0
13
+
11
14
  [sql]
12
15
  sqlalchemy>=2.0.43
13
16