contree-sdk 0.3.2__tar.gz → 0.3.4__tar.gz

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.
Files changed (99) hide show
  1. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/PKG-INFO +5 -13
  2. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/README.md +3 -11
  3. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/files.py +5 -5
  4. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/lib/mixins.py +4 -2
  5. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/models/instance.py +2 -0
  6. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/deprecation.py +2 -2
  7. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/exception.py +3 -1
  8. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/typing.py +1 -1
  9. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_like/_async.py +1 -1
  10. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_like/_base.py +12 -5
  11. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_like/_sync.py +2 -2
  12. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/run.py +2 -0
  13. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/session/_base.py +1 -1
  14. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/subprocess/_base.py +2 -1
  15. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/io_wrap.py +1 -1
  16. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/pyproject.toml +6 -20
  17. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/.gitignore +0 -0
  18. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/LICENSE +0 -0
  19. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/SECURITY.md +0 -0
  20. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/__init__.py +0 -0
  21. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/README.md +0 -0
  22. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/__init__.py +0 -0
  23. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/__init__.py +0 -0
  24. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/client.py +0 -0
  25. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/__init__.py +0 -0
  26. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/auth.py +0 -0
  27. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/common.py +0 -0
  28. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/images.py +0 -0
  29. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/inspect.py +0 -0
  30. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/instances.py +0 -0
  31. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/client/v1/operations.py +0 -0
  32. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/lib/__init__.py +0 -0
  33. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/lib/api_decorator.py +0 -0
  34. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/lib/client_base.py +0 -0
  35. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/lib/helpers.py +0 -0
  36. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/lib/types.py +0 -0
  37. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/models/__init__.py +0 -0
  38. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/models/file.py +0 -0
  39. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/models/image.py +0 -0
  40. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/models/image_import.py +0 -0
  41. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/models/operation.py +0 -0
  42. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/__init__.py +0 -0
  43. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/auth_ini.py +0 -0
  44. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/circuit_retrier.py +0 -0
  45. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/config.py +0 -0
  46. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/other.py +0 -0
  47. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/_internals/utils/wrapper.py +0 -0
  48. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/auth.py +0 -0
  49. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/config.py +0 -0
  50. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/__init__.py +0 -0
  51. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/client/__init__.py +0 -0
  52. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/client/_async.py +0 -0
  53. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/client/_base.py +0 -0
  54. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/client/_sync.py +0 -0
  55. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/exceptions/__init__.py +0 -0
  56. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/exceptions/api.py +0 -0
  57. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/exceptions/base.py +0 -0
  58. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/exceptions/image.py +0 -0
  59. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/exceptions/operation.py +0 -0
  60. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/exceptions/other.py +0 -0
  61. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/__init__.py +0 -0
  62. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/_base.py +0 -0
  63. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/files/__init__.py +0 -0
  64. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/files/_async.py +0 -0
  65. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/files/_base.py +0 -0
  66. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/files/_sync.py +0 -0
  67. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/images/__init__.py +0 -0
  68. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/images/_async.py +0 -0
  69. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/images/_base.py +0 -0
  70. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/managers/images/_sync.py +0 -0
  71. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/__init__.py +0 -0
  72. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image/__init__.py +0 -0
  73. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image/_async.py +0 -0
  74. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image/_base.py +0 -0
  75. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image/_sync.py +0 -0
  76. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_fs/__init__.py +0 -0
  77. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_fs/_async.py +0 -0
  78. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_fs/_base.py +0 -0
  79. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_fs/_sync.py +0 -0
  80. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_like/__init__.py +0 -0
  81. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_like/result.py +0 -0
  82. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/image_like/state.py +0 -0
  83. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/session/__init__.py +0 -0
  84. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/session/_async.py +0 -0
  85. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/session/_sync.py +0 -0
  86. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/subprocess/__init__.py +0 -0
  87. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/subprocess/_async.py +0 -0
  88. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/sdk/objects/subprocess/_sync.py +0 -0
  89. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/shell/__init__.py +0 -0
  90. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/shell/__main__.py +0 -0
  91. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/__init__.py +0 -0
  92. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/codecs.py +0 -0
  93. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/models/__init__.py +0 -0
  94. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/models/auth.py +0 -0
  95. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/models/file.py +0 -0
  96. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/models/image.py +0 -0
  97. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/models/operation.py +0 -0
  98. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/models/stream.py +0 -0
  99. {contree_sdk-0.3.2 → contree_sdk-0.3.4}/contree_sdk/utils/oci.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contree-sdk
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: SDK for ConTree container runtime with versioned filesystem state
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -19,7 +19,6 @@ Requires-Dist: httpx
19
19
  Requires-Dist: strenum
20
20
  Requires-Dist: typing-extensions; python_version < '3.13'
21
21
  Provides-Extra: dev
22
- Requires-Dist: basedpyright; extra == 'dev'
23
22
  Requires-Dist: dprint-py; extra == 'dev'
24
23
  Requires-Dist: pytest-asyncio; extra == 'dev'
25
24
  Requires-Dist: pytest-cov; extra == 'dev'
@@ -35,6 +34,7 @@ Requires-Dist: rich; extra == 'dev'
35
34
  Requires-Dist: ruff; extra == 'dev'
36
35
  Requires-Dist: tomli; (python_version < '3.11') and extra == 'dev'
37
36
  Requires-Dist: typing-extensions; extra == 'dev'
37
+ Requires-Dist: ty~=0.0.51; extra == 'dev'
38
38
  Provides-Extra: dev-security
39
39
  Requires-Dist: semgrep; extra == 'dev-security'
40
40
  Provides-Extra: docs
@@ -238,9 +238,7 @@ async def amain():
238
238
  env=dict(http_proxy="http://10.20.30.40:1234"),
239
239
  files=[
240
240
  UploadFileSpec(source="/local/files/app.sh", mode=stat.S_IXUSR),
241
- UploadFileSpec(
242
- source="/local/files/data_ver1.csv", path=PurePosixPath("/data.csv")
243
- ),
241
+ UploadFileSpec(source="/local/files/data_ver1.csv", path=PurePosixPath("/data.csv")),
244
242
  ],
245
243
  )
246
244
  print(result0.stdout)
@@ -265,9 +263,7 @@ async def amain():
265
263
  session = busybox_image.session()
266
264
  await session.run(
267
265
  command="/bin/app",
268
- files=[
269
- UploadFileSpec(source="/local/files/app", path="bin/app", mode=stat.S_IXUSR)
270
- ],
266
+ files=[UploadFileSpec(source="/local/files/app", path="bin/app", mode=stat.S_IXUSR)],
271
267
  )
272
268
  res = await session.run(command="/bin/cat", args=("result.txt",))
273
269
  print(res.stdout)
@@ -342,11 +338,7 @@ def main():
342
338
  session = busybox_image.session()
343
339
  session.run(
344
340
  command="/bin/app",
345
- files=[
346
- UploadFileSpec(
347
- source="/local/files/app", path="/bin/app", mode=stat.S_IXUSR
348
- )
349
- ],
341
+ files=[UploadFileSpec(source="/local/files/app", path="/bin/app", mode=stat.S_IXUSR)],
350
342
  ).wait()
351
343
  res = session.run(command="cat", args=("result.txt",)).wait()
352
344
  print(res.stdout)
@@ -193,9 +193,7 @@ async def amain():
193
193
  env=dict(http_proxy="http://10.20.30.40:1234"),
194
194
  files=[
195
195
  UploadFileSpec(source="/local/files/app.sh", mode=stat.S_IXUSR),
196
- UploadFileSpec(
197
- source="/local/files/data_ver1.csv", path=PurePosixPath("/data.csv")
198
- ),
196
+ UploadFileSpec(source="/local/files/data_ver1.csv", path=PurePosixPath("/data.csv")),
199
197
  ],
200
198
  )
201
199
  print(result0.stdout)
@@ -220,9 +218,7 @@ async def amain():
220
218
  session = busybox_image.session()
221
219
  await session.run(
222
220
  command="/bin/app",
223
- files=[
224
- UploadFileSpec(source="/local/files/app", path="bin/app", mode=stat.S_IXUSR)
225
- ],
221
+ files=[UploadFileSpec(source="/local/files/app", path="bin/app", mode=stat.S_IXUSR)],
226
222
  )
227
223
  res = await session.run(command="/bin/cat", args=("result.txt",))
228
224
  print(res.stdout)
@@ -297,11 +293,7 @@ def main():
297
293
  session = busybox_image.session()
298
294
  session.run(
299
295
  command="/bin/app",
300
- files=[
301
- UploadFileSpec(
302
- source="/local/files/app", path="/bin/app", mode=stat.S_IXUSR
303
- )
304
- ],
296
+ files=[UploadFileSpec(source="/local/files/app", path="/bin/app", mode=stat.S_IXUSR)],
305
297
  ).wait()
306
298
  res = session.run(command="cat", args=("result.txt",)).wait()
307
299
  print(res.stdout)
@@ -12,16 +12,16 @@ class FilesMixin:
12
12
  @overload
13
13
  def get_file_by_sha256(self: SyncClientMixin, sha256: str) -> UploadedFile: ...
14
14
 
15
- @get("/v1/files", json=True)
15
+ @get("/v1/files/{sha256}", json=True)
16
16
  def get_file_by_sha256(self, sha256: str) -> UploadedFile: ...
17
17
 
18
18
  @overload
19
- async def check_file_exists(self: AsyncClientMixin, uuid: str) -> bool: ...
19
+ async def check_file_exists(self: AsyncClientMixin, sha256: str) -> bool: ...
20
20
  @overload
21
- def check_file_exists(self: SyncClientMixin, uuid: str) -> bool: ...
21
+ def check_file_exists(self: SyncClientMixin, sha256: str) -> bool: ...
22
22
 
23
- @head("/v1/files")
24
- def check_file_exists(self, uuid: str) -> bool: ...
23
+ @head("/v1/files/{sha256}")
24
+ def check_file_exists(self, sha256: str) -> bool: ...
25
25
 
26
26
  @overload
27
27
  async def upload_file(self: AsyncClientMixin, data: Annotated[FileContent, OctetFile]) -> UploadedFile: ...
@@ -19,7 +19,9 @@ class SyncClientMixin:
19
19
  def _send_request(self, request: Request) -> Response:
20
20
  return self._client.send(request, follow_redirects=True)
21
21
 
22
- def _handle_api_call(self: ClientBase, endpoint_info: ApiEndpointInfo, data: dict) -> ReturnType | dict | Response:
22
+ def _handle_api_call(
23
+ self: ClientBase, endpoint_info: ApiEndpointInfo, data: dict
24
+ ) -> ReturnType | dict | Response | str | bytes:
23
25
  with wrap_api_call():
24
26
  request = self._build_request(endpoint_info=endpoint_info, data=data)
25
27
  resp = self._send_request(request)
@@ -43,7 +45,7 @@ class AsyncClientMixin:
43
45
 
44
46
  async def _handle_api_call(
45
47
  self: ClientBase, endpoint_info: ApiEndpointInfo, data: dict
46
- ) -> ReturnType | dict | Response:
48
+ ) -> ReturnType | dict | Response | str | bytes:
47
49
  with wrap_api_call():
48
50
  request = self._build_request(endpoint_info=endpoint_info, data=data)
49
51
 
@@ -58,6 +58,7 @@ class InstanceOperationMetadata:
58
58
  stdin: StreamDescription
59
59
  timeout: int
60
60
  truncate_output_at: int
61
+ preserve_env: bool = False
61
62
 
62
63
 
63
64
  @dataclass
@@ -88,3 +89,4 @@ class InstanceSpawnRequest:
88
89
  timeout: int = 60
89
90
  truncate_output_at: int
90
91
  files: dict[str, InstanceFileSpec]
92
+ preserve_env: bool = False
@@ -36,7 +36,7 @@ else:
36
36
  """
37
37
 
38
38
  def decorator(func: Callable[P, T]) -> Callable[P, T]:
39
- typed_func: Callable[P, T] = _typing_deprecated(message)(func) # type: ignore[arg-type]
39
+ typed_func: Callable[P, T] = _typing_deprecated(message)(func) # ty: ignore[invalid-argument-type]
40
40
  warn_msg = f"{func.__qualname__} is deprecated. {message}"
41
41
 
42
42
  if asyncio.iscoroutinefunction(func):
@@ -46,7 +46,7 @@ else:
46
46
  warnings.warn(warn_msg, category=category, stacklevel=stacklevel + 1)
47
47
  return await func(*args, **kwargs)
48
48
 
49
- return async_wrapper # type: ignore[return-value]
49
+ return async_wrapper # ty: ignore[invalid-return-type]
50
50
 
51
51
  @wraps(typed_func)
52
52
  def sync_wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
@@ -55,7 +55,9 @@ def wrap_api_exception(exc: HTTPError, kwargs: dict | None = None) -> ContreeErr
55
55
  elif response.status_code == 429:
56
56
  class_ = TooManyRequestsError
57
57
  return class_(
58
- **{k: data[k] for k in ["status", "error"] if k in data}, request=request_info, response=response_info
58
+ **{k: data[k] for k in ["status", "error"] if k in data}, # ty: ignore[invalid-argument-type]
59
+ request=request_info,
60
+ response=response_info,
59
61
  )
60
62
 
61
63
  return UnknownContreeError(exception=exc)
@@ -24,7 +24,7 @@ def keep_signature(original_func: Callable[..., Any]) -> Any:
24
24
  wrapped = wraps(original_func)(func)
25
25
  wrapped.__name__ = func.__name__
26
26
  wrapped.__qualname__ = func.__qualname__
27
- wrapped.__signature__ = signature(original_func) # type: ignore[reportAttributeAccessIssue]
27
+ wrapped.__signature__ = signature(original_func)
28
28
  return wrapped
29
29
 
30
30
  return decorator
@@ -40,7 +40,7 @@ class _ImageLike(_ImageLikeBase):
40
40
  """
41
41
  return await self._download(image_path, local_path)
42
42
 
43
- async def read(self, image_path: str | Path) -> bytes:
43
+ async def read(self, image_path: str | PurePosixPath) -> bytes:
44
44
  """Read file contents from the image.
45
45
 
46
46
  Args:
@@ -5,6 +5,7 @@ from collections.abc import Iterable
5
5
  from copy import copy
6
6
  from dataclasses import replace
7
7
  from datetime import timedelta
8
+ from io import IOBase
8
9
  from math import ceil
9
10
  from pathlib import Path, PurePosixPath
10
11
  from typing import IO, TYPE_CHECKING, TypeVar, overload
@@ -99,6 +100,7 @@ class _ImageLikeBase:
99
100
  timeout: float | timedelta | None = None,
100
101
  disposable: bool = True,
101
102
  truncate_output_at: int | None = None,
103
+ preserve_env: bool = False,
102
104
  ) -> _T: ...
103
105
 
104
106
  @overload
@@ -118,6 +120,7 @@ class _ImageLikeBase:
118
120
  timeout: float | timedelta | None = None,
119
121
  disposable: bool = True,
120
122
  truncate_output_at: int | None = None,
123
+ preserve_env: bool = False,
121
124
  ) -> _T: ...
122
125
 
123
126
  def run( # noqa: PLR0913
@@ -137,6 +140,7 @@ class _ImageLikeBase:
137
140
  timeout: float | timedelta | None = None,
138
141
  disposable: bool = True,
139
142
  truncate_output_at: int | None = None,
143
+ preserve_env: bool = False,
140
144
  ) -> _T:
141
145
  """Prepare image for command execution.
142
146
 
@@ -155,6 +159,7 @@ class _ImageLikeBase:
155
159
  timeout: Execution timeout in seconds or as timedelta.
156
160
  disposable: If True, image is discarded after execution.
157
161
  truncate_output_at: number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
162
+ preserve_env: If True, environment variables are preserved in resulting image after execution.
158
163
 
159
164
  Returns:
160
165
  New image instance configured for execution.
@@ -192,6 +197,7 @@ class _ImageLikeBase:
192
197
  stderr=stderr,
193
198
  disposable=disposable,
194
199
  truncate_output_at=truncate_output_at,
200
+ preserve_env=preserve_env,
195
201
  )
196
202
  new_self._prepare_stdin(stdin)
197
203
  return new_self
@@ -308,6 +314,7 @@ class _ImageLikeBase:
308
314
  stdin=stdin,
309
315
  files=files,
310
316
  truncate_output_at=req.truncate_output_at or self._client.config.default_truncate_output_at,
317
+ preserve_env=req.preserve_env,
311
318
  )
312
319
  )
313
320
  image_metadata, result = await self._client._wait_operation(
@@ -316,8 +323,8 @@ class _ImageLikeBase:
316
323
 
317
324
  new_self._transition_state(ImageState.SUCCEEDED)
318
325
  new_uuid = result.image
319
- new_self.uuid = new_uuid and UUID(new_uuid) # type: ignore[reportAttributeAccessIssue]
320
- new_self.tag = result.tag # type: ignore[reportAttributeAccessIssue]
326
+ new_self.uuid = new_uuid and UUID(new_uuid)
327
+ new_self.tag = result.tag
321
328
  new_self._result = ContreeResult.from_result(image_metadata, request=req)
322
329
  if req.tag:
323
330
  new_self = await new_self._tag_as(req.tag)
@@ -381,17 +388,17 @@ class _ImageLikeBase:
381
388
  return self._result
382
389
 
383
390
  @property
384
- def stdin(self) -> IO | None:
391
+ def stdin(self) -> IO | IOBase | None:
385
392
  """Configured stdin source."""
386
393
  return self._stdin
387
394
 
388
395
  @property
389
- def stdout(self) -> IO_TYPES | None:
396
+ def stdout(self) -> IO_TYPES:
390
397
  """Stdout output from the execution."""
391
398
  return self.result.stdout
392
399
 
393
400
  @property
394
- def stderr(self) -> IO_TYPES | None:
401
+ def stderr(self) -> IO_TYPES:
395
402
  """Stderr output from the execution."""
396
403
  return self.result.stderr
397
404
 
@@ -51,7 +51,7 @@ class _ImageLikeSync(_ImageLikeBase):
51
51
  """
52
52
  return coro_sync(self._download(image_path, local_path))
53
53
 
54
- def read(self, image_path: str | Path) -> bytes:
54
+ def read(self, image_path: str | PurePosixPath) -> bytes:
55
55
  """Read file contents from the image.
56
56
 
57
57
  Args:
@@ -107,7 +107,7 @@ class _ImageLikeSync(_ImageLikeBase):
107
107
  output_type = str if text else text
108
108
 
109
109
  return ContreeProcessSync(
110
- self.run( # type: ignore[call-overload]
110
+ self.run( # ty: ignore[no-matching-overload]
111
111
  stdin=input or stdin,
112
112
  cwd=cwd,
113
113
  env=env,
@@ -27,3 +27,5 @@ class RunRequest:
27
27
  stdout: REQUEST_IO_TYPES = None
28
28
 
29
29
  truncate_output_at: int | None = None
30
+
31
+ preserve_env: bool = False
@@ -10,7 +10,7 @@ _T = TypeVar("_T", bound="_ContreeSessionBase")
10
10
 
11
11
  class _ContreeSessionBase(_ImageLikeBase):
12
12
  def __init__(self, image: _ImageLikeBase):
13
- super().__init__(image._client, image.uuid, image.tag) # type: ignore[reportArgumentType]
13
+ super().__init__(image._client, image.uuid, image.tag)
14
14
 
15
15
  def _copy_self(self: _T, *_, **__) -> _T:
16
16
  return self
@@ -1,4 +1,5 @@
1
1
  from datetime import timedelta
2
+ from io import IOBase
2
3
  from subprocess import CalledProcessError
3
4
  from typing import IO
4
5
 
@@ -12,7 +13,7 @@ class ContreeProcessBase:
12
13
  self._check = check
13
14
 
14
15
  @property
15
- def stdin(self) -> IO:
16
+ def stdin(self) -> IO | IOBase | None:
16
17
  return self._image.stdin
17
18
 
18
19
  @property
@@ -52,7 +52,7 @@ class IOMode(StrEnum):
52
52
 
53
53
 
54
54
  PipeLiteral = Literal[-1] # subprocess.PIPE
55
- IO_TYPES: TypeAlias = str | bytes | Path | IO[str] | IO[bytes] | PipeLiteral
55
+ IO_TYPES: TypeAlias = str | bytes | Path | IO[str] | IO[bytes] | IOBase | PipeLiteral
56
56
 
57
57
 
58
58
  def get_io_by_obj(obj: IO_TYPES | None, mode: IOMode) -> IOBase | IO | None:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "contree-sdk"
3
- version = "0.3.2"
3
+ version = "0.3.4"
4
4
  readme = "README.md"
5
5
  description = "SDK for ConTree container runtime with versioned filesystem state"
6
6
  license = { text = "Apache-2.0" }
@@ -43,7 +43,7 @@ dev = [
43
43
  "pytest-markdown-docs",
44
44
  "dprint-py",
45
45
  "pytest-examples",
46
- "basedpyright",
46
+ "ty~=0.0.51",
47
47
  "ruff",
48
48
  "typing-extensions",
49
49
  ]
@@ -243,6 +243,10 @@ extend-ignore = [
243
243
  "PLC2701", # import-private-name
244
244
  ]
245
245
 
246
+ "!tests/**" = [
247
+ "PT", # flake8-pytest-style
248
+ ]
249
+
246
250
  "!examples/**" = [
247
251
  "PLC2701", # import-private-name
248
252
  ]
@@ -277,21 +281,3 @@ runtime-evaluated-base-classes = [
277
281
 
278
282
  [tool.ruff.lint.pylint]
279
283
  max-args = 12
280
-
281
- [tool.pyright]
282
- include = ["contree_sdk", "tests"]
283
-
284
- exclude = [
285
- "tests/unit/docs/_tmp/**"
286
- ]
287
-
288
- pythonVersion = "3.10"
289
- pythonPlatform = "Linux"
290
-
291
- typeCheckingMode = "standard"
292
-
293
- baselineFile = "./.basedpyright/baseline.json"
294
-
295
- # ignores
296
- reportGeneralTypeIssues = "warning"
297
- reportMissingTypeArgument = "warning"
File without changes
File without changes
File without changes