Skip to content

Commit e0d20ee

Browse files
committed
feat: add factory support to resource sequences
1 parent 39e1eb0 commit e0d20ee

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/posit/connect/resources.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import posixpath
44
import warnings
55
from abc import ABC
6-
from typing import ItemsView, Type, cast
6+
from typing import ItemsView
77

88
from typing_extensions import (
99
TYPE_CHECKING,
@@ -92,8 +92,8 @@ def update(self, **attributes): # type: ignore[reportIncompatibleMethodOverride
9292
super().update(**result)
9393

9494

95-
_T = TypeVar("_T", bound=Resource)
96-
_T_co = TypeVar("_T_co", bound=Resource, covariant=True)
95+
_T = TypeVar("_T", bound=_Resource)
96+
_T_co = TypeVar("_T_co", bound=_Resource, covariant=True)
9797

9898

9999
class ResourceFactory(Protocol[_T_co]):
@@ -121,13 +121,13 @@ def __init__(
121121
self,
122122
ctx: Context,
123123
path: str,
124-
factory: ResourceFactory[_T] | None = None,
124+
factory: ResourceFactory[_T] = _Resource,
125125
uid: str = "guid",
126126
):
127127
self._ctx = ctx
128128
self._path = path
129+
self._factory = factory
129130
self._uid = uid
130-
self._factory = factory or cast(ResourceFactory[_T], _Resource)
131131

132132
def __getitem__(self, index):
133133
return list(self.fetch())[index]

0 commit comments

Comments
 (0)