engin 0.0.19__py3-none-any.whl → 0.0.20__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.
engin/_dependency.py CHANGED
@@ -33,7 +33,7 @@ class Dependency(ABC, Option, Generic[P, T]):
33
33
  def __init__(self, func: Func[P, T]) -> None:
34
34
  self._func = func
35
35
  self._is_async = iscoroutinefunction(func)
36
- self._signature = inspect.signature(self._func)
36
+ self._signature = inspect.signature(self._func, eval_str=True)
37
37
  self._block_name: str | None = None
38
38
 
39
39
  source_frame = get_first_external_frame()
@@ -154,24 +154,24 @@ class Entrypoint(Invoke):
154
154
  class Provide(Dependency[Any, T]):
155
155
  def __init__(
156
156
  self,
157
- builder: Func[P, T],
157
+ factory: Func[P, T],
158
158
  *,
159
159
  scope: str | None = None,
160
160
  as_type: type | None = None,
161
161
  override: bool = False,
162
162
  ) -> None:
163
163
  """
164
- Provide a type via a builder or factory function.
164
+ Provide a type via a factory function.
165
165
 
166
166
  Args:
167
- builder: the builder function that returns the type.
167
+ factory: the factory function that returns the type.
168
168
  scope: (optional) associate this provider with a specific scope.
169
169
  as_type: (optional) allows you to explicitly specify the provided type, e.g.
170
170
  to type erase a concrete type, or to provide a mock implementation.
171
171
  override: (optional) allow this provider to override other providers for the
172
172
  same type from the same package.
173
173
  """
174
- super().__init__(func=builder)
174
+ super().__init__(func=factory)
175
175
  self._scope = scope
176
176
  self._override = override
177
177
  self._explicit_type = as_type
@@ -231,9 +231,9 @@ class Provide(Dependency[Any, T]):
231
231
  # overwriting a dependency from the same package must be explicit
232
232
  if is_same_package and not self._override:
233
233
  msg = (
234
- f"Provider '{self.name}' is implicitly overriding "
235
- f"'{existing_provider.name}', if this is intended specify "
236
- "`override=True` for the overriding Provider"
234
+ f"{self} from '{self._source_frame}' is implicitly overriding "
235
+ f"{existing_provider} from '{existing_provider.source_module}', if this "
236
+ "is intentional specify `override=True` for the overriding Provider"
237
237
  )
238
238
  raise RuntimeError(msg)
239
239
 
@@ -243,7 +243,7 @@ class Provide(Dependency[Any, T]):
243
243
  return hash(self.return_type_id)
244
244
 
245
245
  def __str__(self) -> str:
246
- return f"Provide({self.return_type_id})"
246
+ return f"Provide(factory={self.func_name}, type={self._return_type_id})"
247
247
 
248
248
  def _resolve_return_type(self) -> type[T]:
249
249
  if self._explicit_type is not None:
@@ -279,7 +279,14 @@ class Supply(Provide, Generic[T]):
279
279
  same type from the same package.
280
280
  """
281
281
  self._value = value
282
- super().__init__(builder=self._get_val, as_type=as_type, override=override)
282
+ super().__init__(factory=self._get_val, as_type=as_type, override=override)
283
+
284
+ @property
285
+ def name(self) -> str:
286
+ if self._block_name:
287
+ return f"{self._block_name}.supply"
288
+ else:
289
+ return f"{self._source_frame}.supply"
283
290
 
284
291
  def _resolve_return_type(self) -> type[T]:
285
292
  if self._explicit_type is not None:
@@ -292,4 +299,4 @@ class Supply(Provide, Generic[T]):
292
299
  return self._value
293
300
 
294
301
  def __str__(self) -> str:
295
- return f"Supply({self.return_type_id})"
302
+ return f"Supply(value={self._value}, type={self.return_type_id})"
engin/_type_utils.py CHANGED
@@ -33,8 +33,8 @@ class TypeId:
33
33
  return TypeId(type=type_, multi=False)
34
34
 
35
35
  def __str__(self) -> str:
36
- module = self.type.__module__
37
- out = f"{module}." if module not in _implict_modules else ""
36
+ module = getattr(self.type, "__module__", None)
37
+ out = f"{module}." if module and module not in _implict_modules else ""
38
38
  out += _args_to_str(self.type)
39
39
  if self.multi:
40
40
  out += "[]"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: engin
3
- Version: 0.0.19
3
+ Version: 0.0.20
4
4
  Summary: An async-first modular application framework
5
5
  Project-URL: Homepage, https://github.com/invokermain/engin
6
6
  Project-URL: Documentation, https://engin.readthedocs.io/en/latest/
@@ -1,13 +1,13 @@
1
1
  engin/__init__.py,sha256=A8TE_ci7idoR683535YoBrWZbYTgXXS-q7Y2y51nZ5M,486
2
2
  engin/_assembler.py,sha256=-ENSrXPMWacionIYrTSQO7th9DDBOPyAT8ybPbBRtQw,11318
3
3
  engin/_block.py,sha256=IacP4PoJKRhSQCbQSdoyCtmu362a4vj6qoUQKyaJwzI,3062
4
- engin/_dependency.py,sha256=Nfq6L92LN4X53QpiMCIF3MjmWfuntYVOnZmmoPYYJEw,9165
4
+ engin/_dependency.py,sha256=xINk3sudxzsTmkUkNAKQwzBc0G0DfhpnrZli4z3ALBY,9459
5
5
  engin/_engin.py,sha256=yIpZdeqvm8hv0RxOV0veFuvyu9xQ054JSaeuUWwHdOQ,7380
6
6
  engin/_graph.py,sha256=y1g7Lm_Zy5GPEgRsggCKV5DDaDzcwUl8v3IZCK8jyGI,1631
7
7
  engin/_introspect.py,sha256=VdREX6Lhhga5SnEP9G7mjHkgJR4mpqk_SMnmL2zTcqY,966
8
8
  engin/_lifecycle.py,sha256=cSWe3euZkmpxmUPFvph2lsTtvuZbxttEfBL-RnOI7lo,5325
9
9
  engin/_option.py,sha256=nZcdrehp1QwgxMUoIpsM0PJuu1q1pbXzhcVsetbsHpc,223
10
- engin/_type_utils.py,sha256=Pmm4m1_WdevT5KTe8tzY_BseNxPyhu_nKsLGgyNcPpo,2247
10
+ engin/_type_utils.py,sha256=H3Tl-kJr2wY2RhaTXP9GrMqa2RsXMijHbjHKe1AxGmc,2276
11
11
  engin/exceptions.py,sha256=-VPwPReZb9YEIkrWMR9TW2K5HEwmHHgEO7QWH6wfV8c,1946
12
12
  engin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  engin/_cli/__init__.py,sha256=koD5WTkZXb8QQIiVU5bJiSR1wwPGb5rv2iwd-v-BA7A,564
@@ -18,8 +18,8 @@ engin/_cli/_inspect.py,sha256=0jm25d4wcbXVNJkyaeECSKY-irsxd-EIYBH1GDW_Yjc,3163
18
18
  engin/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  engin/extensions/asgi.py,sha256=d5Z6gtMVWDZdAlvrTaMt987sKyiq__A0X4gJQ7IETmA,3247
20
20
  engin/extensions/fastapi.py,sha256=e8F4L_nZ9dU9j8mb9lXKwJG6CTu5aIk4N5faRj4EyUA,6369
21
- engin-0.0.19.dist-info/METADATA,sha256=Rb1VPxLjnzVxhnq8Llie5XRxpI0GANR-dK31BEcPAqg,2354
22
- engin-0.0.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- engin-0.0.19.dist-info/entry_points.txt,sha256=sW247zZUMxm0b5UKYvPuqQQljYDtU-j2zK3cu7gHwM0,41
24
- engin-0.0.19.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
25
- engin-0.0.19.dist-info/RECORD,,
21
+ engin-0.0.20.dist-info/METADATA,sha256=KiKW4DvikfKJJNzoXh7oC4RMdr02W0PkhtxXB8DN6bo,2354
22
+ engin-0.0.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ engin-0.0.20.dist-info/entry_points.txt,sha256=sW247zZUMxm0b5UKYvPuqQQljYDtU-j2zK3cu7gHwM0,41
24
+ engin-0.0.20.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
25
+ engin-0.0.20.dist-info/RECORD,,
File without changes