Skip to content

Commit 9b19f14

Browse files
authored
Decrease minimum python version (#168)
1 parent 5e4302b commit 9b19f14

File tree

9 files changed

+37
-21
lines changed

9 files changed

+37
-21
lines changed

examples/server/v1/components.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import random
44
import struct
55
import sys
6-
from collections.abc import AsyncIterator
6+
7+
if sys.version_info.minor >= 9:
8+
from collections.abc import AsyncIterator
9+
else:
10+
from typing import AsyncIterator
11+
712
from datetime import timedelta
813
from multiprocessing import Lock, Queue
914
from pathlib import Path

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ packages = [
1111
include = ["LICENSE", "src/viam/rpc/libviam_rust_utils.*"]
1212

1313
[tool.poetry.dependencies]
14-
python = ">=3.9,<3.11"
14+
python = ">=3.8,<3.11"
1515
grpclib = "^0.4.2"
1616
googleapis-common-protos = "^1.56.3"
1717
typing-extensions = "^4.2.0"

src/viam/media/media.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from collections.abc import AsyncIterator
1+
import sys
2+
3+
if sys.version_info.minor >= 9:
4+
from collections.abc import AsyncIterator
5+
else:
6+
from typing import AsyncIterator
7+
28
from typing import Protocol, TypeVar
39

410
MediaType = TypeVar("MediaType", covariant=True)

src/viam/registry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def lookup(cls, component_name: str) -> ComponentRegistration:
9797
raise ComponentNotFoundError("component", component_name)
9898

9999
@classmethod
100-
@property
101100
def REGISTERED_COMPONENTS(cls) -> Mapping[str, ComponentRegistration]:
102101
"""The dictionary of all registered components
103102
- Key: Name of the component type

src/viam/robot/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def _generate_status(self, resource_names: Iterable[ResourceName]) -> List
5151
statuses: List[Status] = []
5252

5353
for component in self.manager.components.values():
54-
for registration in Registry.REGISTERED_COMPONENTS.values():
54+
for registration in Registry.REGISTERED_COMPONENTS().values():
5555
if isinstance(component, registration.component_type):
5656
if resource_names and component.get_resource_name(component.name) not in resource_names:
5757
continue

src/viam/rpc/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, components: List[ComponentBase]):
3636
services = [
3737
SignalingService(),
3838
RobotService(manager=self),
39-
*[registration.rpc_service(manager=self) for registration in Registry.REGISTERED_COMPONENTS.values()],
39+
*[registration.rpc_service(manager=self) for registration in Registry.REGISTERED_COMPONENTS().values()],
4040
]
4141
services = ServerReflection.extend(services)
4242
self._server = GRPCServer(services)

src/viam/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def resource_names_for_component(component: ComponentBase) -> List[ResourceName]
7979
rns: List[ResourceName] = []
8080
for klass in component.__class__.mro():
8181
component_type = ""
82-
for registration in Registry.REGISTERED_COMPONENTS.values():
82+
for registration in Registry.REGISTERED_COMPONENTS().values():
8383
if klass is registration.component_type:
8484
component_type = registration.name
8585

tests/mocks/components.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from collections.abc import AsyncIterator
1+
import sys
2+
3+
if sys.version_info.minor >= 9:
4+
from collections.abc import AsyncIterator
5+
else:
6+
from typing import AsyncIterator
7+
28
from dataclasses import dataclass
39
from multiprocessing import Queue
410
from secrets import choice

tests/test_registry.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ def __init__(self, name: str, channel: Channel):
2121

2222

2323
def test_components_register_themselves_correctly():
24-
assert "arm" in Registry.REGISTERED_COMPONENTS
25-
assert "base" in Registry.REGISTERED_COMPONENTS
26-
assert "board" in Registry.REGISTERED_COMPONENTS
27-
assert "camera" in Registry.REGISTERED_COMPONENTS
28-
assert "gantry" in Registry.REGISTERED_COMPONENTS
29-
assert "gripper" in Registry.REGISTERED_COMPONENTS
30-
assert "motor" in Registry.REGISTERED_COMPONENTS
31-
assert "movement_sensor" in Registry.REGISTERED_COMPONENTS
32-
assert "pose_tracker" in Registry.REGISTERED_COMPONENTS
33-
assert "sensor" in Registry.REGISTERED_COMPONENTS
34-
assert "servo" in Registry.REGISTERED_COMPONENTS
24+
assert "arm" in Registry.REGISTERED_COMPONENTS()
25+
assert "base" in Registry.REGISTERED_COMPONENTS()
26+
assert "board" in Registry.REGISTERED_COMPONENTS()
27+
assert "camera" in Registry.REGISTERED_COMPONENTS()
28+
assert "gantry" in Registry.REGISTERED_COMPONENTS()
29+
assert "gripper" in Registry.REGISTERED_COMPONENTS()
30+
assert "motor" in Registry.REGISTERED_COMPONENTS()
31+
assert "movement_sensor" in Registry.REGISTERED_COMPONENTS()
32+
assert "pose_tracker" in Registry.REGISTERED_COMPONENTS()
33+
assert "sensor" in Registry.REGISTERED_COMPONENTS()
34+
assert "servo" in Registry.REGISTERED_COMPONENTS()
3535

3636

3737
def test_lookup():
@@ -43,14 +43,14 @@ def test_lookup():
4343

4444

4545
def test_registration():
46-
assert "fake_component" not in Registry.REGISTERED_COMPONENTS
46+
assert "fake_component" not in Registry.REGISTERED_COMPONENTS()
4747

4848
Registry.register(
4949
ComponentRegistration(
5050
FakeComponent, "fake_component", FakeComponentService, lambda name, channel: FakeComponentClient(name, channel)
5151
)
5252
)
53-
assert "fake_component" in Registry.REGISTERED_COMPONENTS
53+
assert "fake_component" in Registry.REGISTERED_COMPONENTS()
5454
component = Registry.lookup("fake_component")
5555
assert component is not None
5656

0 commit comments

Comments
 (0)