Skip to content

Commit c56d99a

Browse files
committed
Context now inherits from dict. Would be nice to remove it
1 parent 04a5c22 commit c56d99a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/posit/connect/context.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,28 @@ def wrapper(instance: ContextManager, *args, **kwargs):
2727
return decorator
2828

2929

30-
class Context:
30+
# Big mystery: `Context` is a subclass of `dict`. However, this is unnecessary.
31+
# BUT, when `dict` is removed, the following errors occur:
32+
# ```
33+
# uv run pyright
34+
# /Users/barret/Documents/git/rstudio/posit-sdk-py/posit-sdk-py.nosync/src/posit/connect/client.py
35+
# /Users/barret/Documents/git/rstudio/posit-sdk-py/posit-sdk-py.nosync/src/posit/connect/client.py:274:25 - error: Argument of type "Context" cannot be assigned to parameter "iterable" of type "Iterable[Package]" in function "__new__"
36+
# "Context" is incompatible with protocol "Iterable[Package]"
37+
# "__iter__" is not present (reportArgumentType)
38+
# /Users/barret/Documents/git/rstudio/posit-sdk-py/posit-sdk-py.nosync/src/posit/connect/jobs.py
39+
# /Users/barret/Documents/git/rstudio/posit-sdk-py/posit-sdk-py.nosync/src/posit/connect/jobs.py:302:21 - error: Argument of type "ContentItemContext" cannot be assigned to parameter "iterable" of type "Iterable[Job]" in function "__new__"
40+
# "ContentItemContext" is incompatible with protocol "Iterable[Job]"
41+
# "__iter__" is not present (reportArgumentType)
42+
# /Users/barret/Documents/git/rstudio/posit-sdk-py/posit-sdk-py.nosync/src/posit/connect/packages.py
43+
# /Users/barret/Documents/git/rstudio/posit-sdk-py/posit-sdk-py.nosync/src/posit/connect/packages.py:102:32 - error: Argument of type "ContentItemContext" cannot be assigned to parameter "iterable" of type "Iterable[ContentPackage]" in function "__new__"
44+
# "ContentItemContext" is incompatible with protocol "Iterable[ContentPackage]"
45+
# "__iter__" is not present (reportArgumentType)
46+
# 3 errors, 0 warnings, 0 informations
47+
# ```
48+
# This is a mystery because `Context` is not used as an iterable in the codebase.
49+
50+
51+
class Context(dict):
3152
def __init__(self, session: requests.Session, url: Url):
3253
self.session = session
3354
self.url = url

0 commit comments

Comments
 (0)