-
Notifications
You must be signed in to change notification settings - Fork 1.2k
sdk/python: use typing.List in classes that define a list method
#1477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| import re | ||
| import threading | ||
| from dataclasses import dataclass | ||
| from typing import Dict, Union | ||
| from typing import Dict, List, Union | ||
|
|
||
| import requests | ||
|
|
||
|
|
@@ -198,9 +198,9 @@ def _validate_mount_path(path: str) -> str: | |
| return path | ||
|
|
||
|
|
||
| def _serialize_volume_mounts(mounts: VolumeMountsArg) -> list[dict[str, object]]: | ||
| def _serialize_volume_mounts(mounts: VolumeMountsArg) -> List[dict[str, object]]: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| """Serialize the e2b-style ``{path: volume}`` mapping into the wire format.""" | ||
| serialized: list[dict[str, object]] = [] | ||
| serialized: List[dict[str, object]] = [] | ||
| for path, value in mounts.items(): | ||
| if isinstance(value, VolumeMount): | ||
| volume = value.volume | ||
|
|
@@ -244,7 +244,7 @@ class Volume: | |
| sb.files.write("/workspace/note.txt", "persisted!") | ||
|
|
||
| # List / get_info / connect / destroy | ||
| for v in Volume.list(): # list[VolumeInfo] | ||
| for v in Volume.list(): # List[VolumeInfo] | ||
| print(v.volume_id, v.name) | ||
| Volume.get_info(vol.volume_id) # VolumeInfo | ||
| vol = Volume.connect("my-data") # Volume instance (== e2b) | ||
|
|
@@ -376,7 +376,7 @@ def create( | |
| return cls._from_info(VolumeInfo.from_dict(resp.json()), cfg) | ||
|
|
||
| @classmethod | ||
| def list(cls, *, config: Config | None = None) -> list[VolumeInfo]: | ||
| def list(cls, *, config: Config | None = None) -> List[VolumeInfo]: | ||
| """GET /volumes — List all volumes. | ||
|
|
||
| The returned entries never carry a ``token`` (it is only surfaced on | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rewrite isn't needed:
TemplateBuild(likeTemplateInfo) doesn't define alistmethod, solist[str]here already resolves to the builtin for both mypy and runtime. Only annotations lexically insideTemplate(which defineslist) were affected by the shadowing — the same applies toreplicas(line 83) andbuilds(line 87), which could staylist[...].Reverting these three keeps the diff focused on the actual defect and consistent with the PEP-585
list[...]style used elsewhere in the same files (_models.py,_commands.py). It also avoids introducingtyping.Listin scopes where the builtin isn't shadowed, which ruff'sUP006(enabled viaselect = ["E", "F", "I", "UP"]insdk/python/pyproject.toml) would flag if a fullruff checkis ever run. (Not blocking — the changes are harmless.)