rats-apps 0.1.2__py3-none-any.whl → 0.1.2.dev1__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.
rats/apps/__init__.py CHANGED
@@ -4,7 +4,6 @@ Provides a small set of libraries to help create new applications.
4
4
  Applications give you the ability to define a development experience to match your project's
5
5
  domain.
6
6
  """
7
-
8
7
  from ._annotations import (
9
8
  AnnotatedContainer,
10
9
  config,
rats/apps/_annotations.py CHANGED
@@ -19,7 +19,6 @@ class GroupAnnotations(NamedTuple):
19
19
  The `name` attribute is the name of the function, and the `namespace` attribute represents a
20
20
  specific meaning for the group of services.
21
21
  """
22
-
23
22
  name: str
24
23
  namespace: str
25
24
  groups: tuple[ServiceId[Any], ...]
@@ -31,7 +30,6 @@ class FunctionAnnotations(NamedTuple):
31
30
 
32
31
  Loosely inspired by: https://peps.python.org/pep-3107/.
33
32
  """
34
-
35
33
  providers: tuple[GroupAnnotations, ...]
36
34
 
37
35
  def group_in_namespace(
@@ -67,7 +65,8 @@ class FunctionAnnotationsBuilder:
67
65
 
68
66
 
69
67
  class AnnotatedContainer(Container):
70
- def get_namespaced_group(
68
+
69
+ def get_namespace(
71
70
  self,
72
71
  namespace: str,
73
72
  group_id: ServiceId[T_ServiceType],
@@ -81,7 +80,7 @@ class AnnotatedContainer(Container):
81
80
 
82
81
  for container in containers:
83
82
  c = getattr(self, container.name)()
84
- yield from c.get_namespaced_group(namespace, group_id)
83
+ yield from c.get_namespace(namespace, group_id)
85
84
 
86
85
 
87
86
  def service(
@@ -10,10 +10,10 @@ class CompositeContainer(Container):
10
10
  def __init__(self, *containers: Container) -> None:
11
11
  self._containers = containers
12
12
 
13
- def get_namespaced_group(
13
+ def get_namespace(
14
14
  self,
15
15
  namespace: str,
16
16
  group_id: ServiceId[T_ServiceType],
17
17
  ) -> Iterator[T_ServiceType]:
18
18
  for container in self._containers:
19
- yield from container.get_namespaced_group(namespace, group_id)
19
+ yield from container.get_namespace(namespace, group_id)
rats/apps/_container.py CHANGED
@@ -7,12 +7,14 @@ from ._namespaces import ProviderNamespaces
7
7
 
8
8
 
9
9
  class ServiceProvider(Protocol[Tco_ServiceType]):
10
+
10
11
  @abstractmethod
11
12
  def __call__(self) -> Tco_ServiceType:
12
13
  """Return the service instance."""
13
14
 
14
15
 
15
16
  class ConfigProvider(ServiceProvider[Tco_ConfigType], Protocol[Tco_ConfigType]):
17
+
16
18
  @abstractmethod
17
19
  def __call__(self) -> Tco_ConfigType:
18
20
  """Return the config instance."""
@@ -35,16 +37,16 @@ class Container(Protocol):
35
37
 
36
38
  def has_namespace(self, namespace: str, group_id: ServiceId[T_ServiceType]) -> bool:
37
39
  try:
38
- return next(self.get_namespaced_group(namespace, group_id)) is not None
40
+ return next(self.get_namespace(namespace, group_id)) is not None
39
41
  except StopIteration:
40
42
  return False
41
43
 
42
44
  def get(self, service_id: ServiceId[T_ServiceType]) -> T_ServiceType:
43
45
  """Retrieve a service instance by its id."""
44
- services = list(self.get_namespaced_group(ProviderNamespaces.SERVICES, service_id))
46
+ services = list(self.get_namespace(ProviderNamespaces.SERVICES, service_id))
45
47
  if len(services) == 0:
46
48
  services.extend(
47
- list(self.get_namespaced_group(ProviderNamespaces.FALLBACK_SERVICES, service_id)),
49
+ list(self.get_namespace(ProviderNamespaces.FALLBACK_SERVICES, service_id)),
48
50
  )
49
51
 
50
52
  if len(services) > 1:
@@ -60,12 +62,12 @@ class Container(Protocol):
60
62
  ) -> Iterator[T_ServiceType]:
61
63
  """Retrieve a service group by its id."""
62
64
  if not self.has_namespace(ProviderNamespaces.GROUPS, group_id):
63
- yield from self.get_namespaced_group(ProviderNamespaces.FALLBACK_GROUPS, group_id)
65
+ yield from self.get_namespace(ProviderNamespaces.FALLBACK_GROUPS, group_id)
64
66
 
65
- yield from self.get_namespaced_group(ProviderNamespaces.GROUPS, group_id)
67
+ yield from self.get_namespace(ProviderNamespaces.GROUPS, group_id)
66
68
 
67
69
  @abstractmethod
68
- def get_namespaced_group(
70
+ def get_namespace(
69
71
  self,
70
72
  namespace: str,
71
73
  group_id: ServiceId[T_ServiceType],
@@ -14,13 +14,13 @@ class PluginContainers(Container):
14
14
  self._app = app
15
15
  self._group = group
16
16
 
17
- def get_namespaced_group(
17
+ def get_namespace(
18
18
  self,
19
19
  namespace: str,
20
20
  group_id: ServiceId[T_ServiceType],
21
21
  ) -> Iterator[T_ServiceType]:
22
22
  for container in self._load_containers():
23
- yield from container.get_namespaced_group(namespace, group_id)
23
+ yield from container.get_namespace(namespace, group_id)
24
24
 
25
25
  @cache # noqa: B019
26
26
  def _load_containers(self) -> Iterable[Container]:
rats/apps/_scoping.py CHANGED
@@ -15,7 +15,6 @@ def autoscope(cls: type[T]) -> type[T]:
15
15
  The scoped ServiceId instances have a prefix to eliminate the chance of conflicts across
16
16
  packages.
17
17
  """
18
-
19
18
  def wrap(func: Callable[..., Any]) -> Callable[..., Any]:
20
19
  def wrapper(*args: P.args, **kwargs: P.kwargs) -> ServiceId[Any]:
21
20
  result = func(*args, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rats-apps
3
- Version: 0.1.2
3
+ Version: 0.1.2.dev1
4
4
  Summary: research analysis tools for building applications
5
5
  Home-page: https://github.com/microsoft/rats/
6
6
  License: MIT
@@ -0,0 +1,13 @@
1
+ rats/apps/__init__.py,sha256=EHza57K66uM7w8pFBJBqMWaJ7Xn_7E4hn0xA7k8Ag5U,857
2
+ rats/apps/_annotations.py,sha256=QXx78Qbiikn_4uV09J9N0c2aNK6bj-RtUcbgCy3Q718,5110
3
+ rats/apps/_composite_container.py,sha256=-o942CbRgczz2GXDN1gABF8vLTKDOXGddOpob1tZaNw,539
4
+ rats/apps/_container.py,sha256=dm1wRAuPWM0hV2BtNyBmfZ-cybId55w7oua4rvKuiis,3089
5
+ rats/apps/_ids.py,sha256=dxWCPMpMA_vpaTDJEKNByIBJaX97Db203XqWLhaOezo,457
6
+ rats/apps/_namespaces.py,sha256=THUV_Xj5PtweC23Ob-zsSpk8exC4fT-qRwjpQ6IDm0U,188
7
+ rats/apps/_plugin_container.py,sha256=jKD1ft5Ph-DJU7fw2NKC7_FKwSqhWTvZoJTd7lHt6_s,839
8
+ rats/apps/_scoping.py,sha256=-5hl0RoOdQGkxWLIn42hthMUyX8_84sV8H3u40y-gIU,1304
9
+ rats/apps/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ rats_apps-0.1.2.dev1.dist-info/METADATA,sha256=rruFi8kx_YgyUixzfULJ-c2QgStNJOx0BzXFjo6RggY,716
11
+ rats_apps-0.1.2.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ rats_apps-0.1.2.dev1.dist-info/entry_points.txt,sha256=Vu1IgAPQvL4xMJzW_OG2JSPFac7HalCHyXiRr0-OfCI,86
13
+ rats_apps-0.1.2.dev1.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- rats/apps/__init__.py,sha256=JYVss3L2R4uxdOp4Ozfg_cHWgRvCWq79OyVZefFw9wY,858
2
- rats/apps/_annotations.py,sha256=NGCw1JMZdPMoK_pE61iXgjeI1Xn7P5WXLt7t8zWligg,5125
3
- rats/apps/_composite_container.py,sha256=wSWVQWPin2xxIlEoSgk_D1rlc3N2gpTxQ2y9UFdqXy0,553
4
- rats/apps/_container.py,sha256=5uiCyxN6HS2z97XcTOFP-t72cNoB1U1sJMkMcfSfDps,3129
5
- rats/apps/_ids.py,sha256=dxWCPMpMA_vpaTDJEKNByIBJaX97Db203XqWLhaOezo,457
6
- rats/apps/_namespaces.py,sha256=THUV_Xj5PtweC23Ob-zsSpk8exC4fT-qRwjpQ6IDm0U,188
7
- rats/apps/_plugin_container.py,sha256=W_xQD2btc0N2dEb3c5tXM-ZZ4A4diMpkCjbOZdlXYuI,853
8
- rats/apps/_scoping.py,sha256=lRV1DDq-U4mr4WOQhvFjTiCQe2dKY95LNn6b0RXRjFA,1305
9
- rats/apps/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- rats_apps-0.1.2.dist-info/METADATA,sha256=CwHSo9ZWpDzbbE60oLdJO4IG4aV9ub07NzfWoilk0xE,711
11
- rats_apps-0.1.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- rats_apps-0.1.2.dist-info/entry_points.txt,sha256=Vu1IgAPQvL4xMJzW_OG2JSPFac7HalCHyXiRr0-OfCI,86
13
- rats_apps-0.1.2.dist-info/RECORD,,