cuneus 0.2.4__tar.gz → 0.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuneus
3
- Version: 0.2.4
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "cuneus"
3
- version = "0.2.4"
3
+ version = "0.2.5"
4
4
  description = "ASGI application wrapper"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Robert Myers", email = "robert@julython.org" }]
@@ -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
 
@@ -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]]:
@@ -249,7 +249,7 @@ toml = [
249
249
 
250
250
  [[package]]
251
251
  name = "cuneus"
252
- version = "0.2.2"
252
+ version = "0.2.4"
253
253
  source = { editable = "." }
254
254
  dependencies = [
255
255
  { name = "click" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes