cuneus 0.2.3__py3-none-any.whl → 0.2.5__py3-none-any.whl

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.
cuneus/cli.py CHANGED
@@ -13,9 +13,16 @@ from .core.settings import Settings
13
13
 
14
14
  def import_from_string(import_str: str) -> Any:
15
15
  """Import an object from a module:attribute string."""
16
+ # Ensure cwd is in path for local imports
17
+ cwd = str(Path.cwd())
18
+ if cwd not in sys.path:
19
+ sys.path.insert(0, cwd)
20
+
16
21
  module_path, _, attr = import_str.partition(":")
17
22
  if not attr:
18
- attr = "app" # default attribute name
23
+ raise ValueError(
24
+ f"module_path missing function {import_str} expecting 'module.path:name'"
25
+ )
19
26
 
20
27
  module = importlib.import_module(module_path)
21
28
  return getattr(module, attr)
@@ -40,10 +47,6 @@ def get_user_cli() -> click.Group | None:
40
47
  def cli(ctx: click.Context) -> None:
41
48
  """Cuneus CLI - FastAPI application framework."""
42
49
  ctx.ensure_object(dict)
43
- # Ensure cwd is in path for local imports
44
- cwd = str(Path.cwd())
45
- if cwd not in sys.path:
46
- sys.path.insert(0, cwd)
47
50
 
48
51
 
49
52
  @cli.command()
@@ -6,6 +6,7 @@ Lightweight lifespan management for FastAPI applications.
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ import inspect
9
10
  from contextlib import AsyncExitStack, asynccontextmanager
10
11
  from typing import Any, AsyncIterator, Callable
11
12
 
@@ -33,13 +34,21 @@ DEFAULT_EXTENSIONS = (
33
34
  def _instantiate_extension(
34
35
  ext: ExtensionInput, settings: Settings | None = None
35
36
  ) -> Extension:
36
- if isinstance(ext, type):
37
- # It's a class, instantiate it
38
- return ext(settings)
39
- if callable(ext):
40
- # It's a factory function
41
- return ext(settings)
42
- # Already an instance
37
+ if isinstance(ext, type) or callable(ext):
38
+ sig = inspect.signature(ext)
39
+
40
+ # Check if it accepts a 'settings' parameter
41
+ if "settings" in sig.parameters:
42
+ return ext(settings=settings)
43
+
44
+ # Check if it accepts **kwargs
45
+ has_var_keyword = any(
46
+ p.kind == inspect.Parameter.VAR_KEYWORD for p in sig.parameters.values()
47
+ )
48
+ if has_var_keyword:
49
+ return ext(settings=settings)
50
+
51
+ return ext()
43
52
  return ext
44
53
 
45
54
 
cuneus/core/extensions.py CHANGED
@@ -33,8 +33,6 @@ class Extension(Protocol):
33
33
  - Return state to merge into lifespan state
34
34
  """
35
35
 
36
- def __init__(self, settings: Settings | None = None) -> None: ...
37
-
38
36
  def register(
39
37
  self, registry: svcs.Registry, app: FastAPI
40
38
  ) -> AsyncContextManager[dict[str, Any]]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuneus
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: ASGI application wrapper
5
5
  Project-URL: Homepage, https://github.com/rmyers/cuneus
6
6
  Project-URL: Documentation, https://github.com/rmyers/cuneus#readme
@@ -1,15 +1,15 @@
1
1
  cuneus/__init__.py,sha256=JJ3nZ4757GU9KKuurxP1FfJSdSVrcO-xaorLFSvUJ5E,1211
2
- cuneus/cli.py,sha256=2zi4k4xIyxJEhJO6beHLLtDFT8HhXSBxZAj-SK0lA50,3639
2
+ cuneus/cli.py,sha256=NHk_hI_KtXPQ0EXCCfottDwOFrSG6vcYSZPrzuzyZk8,3715
3
3
  cuneus/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cuneus/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- cuneus/core/application.py,sha256=MlVjGWjuKGut5YaIP8BdjuCXFi-tpCwhL4g6N5NRL4U,3773
5
+ cuneus/core/application.py,sha256=6yKbrkkSaWlt3UHiKo68Dc9B1EAcNXd6BxO5W8ZTZuc,4058
6
6
  cuneus/core/execptions.py,sha256=beQE3gD-14BUK4Se6yE2J2U92xgr0yarVmVeibkudxs,5753
7
- cuneus/core/extensions.py,sha256=wdsn5DSHSrzduQwwLgKr38hgvQJi6zsh3MNnE1mINF0,2586
7
+ cuneus/core/extensions.py,sha256=qqBnAD_wN6wTTun7C2hfVqxHhA3WgScNSrgRTMsYa04,2515
8
8
  cuneus/core/logging.py,sha256=OlcWxBCLDqBORzTXZXKlMc_rGD8OkfOBfHgSwEpMCM4,6778
9
9
  cuneus/core/settings.py,sha256=PaYXQ_ubeSt3AFpxNNErii-h1_ehHYPrajFWRT42mTI,1703
10
10
  cuneus/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  cuneus/ext/health.py,sha256=5dWVVEPFL1tWFBhQwZv8C-IvZRzg28V-4sk_g1jJ0vc,3854
12
- cuneus-0.2.3.dist-info/METADATA,sha256=jOOTVqFrGvMAYOD2gVQTg6dl4Ey9-sQqcq3iNQSAJZo,6794
13
- cuneus-0.2.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
- cuneus-0.2.3.dist-info/entry_points.txt,sha256=tzPgom-_UkpP_uLKv3V_XyoIsKg84FBAc9ddjYl0W0Y,43
15
- cuneus-0.2.3.dist-info/RECORD,,
12
+ cuneus-0.2.5.dist-info/METADATA,sha256=hIVlKfIT3uwqzSeoX8nXeEN6oCnfKcb5HaT-y3YETBQ,6794
13
+ cuneus-0.2.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
+ cuneus-0.2.5.dist-info/entry_points.txt,sha256=tzPgom-_UkpP_uLKv3V_XyoIsKg84FBAc9ddjYl0W0Y,43
15
+ cuneus-0.2.5.dist-info/RECORD,,
File without changes