2025-07-29 12:39:42 +02:00
|
|
|
ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../..)
|
|
|
|
|
|
2024-07-05 18:12:28 -07:00
|
|
|
generate-api:
|
2026-03-26 01:37:46 +01:00
|
|
|
python $(ROOT_DIR)/spec/remove_extra_tags.py sandboxes snapshots templates tags volumes
|
2025-07-29 12:39:42 +02:00
|
|
|
openapi-python-client generate --output-path $(ROOT_DIR)/packages/python-sdk/e2b/api/api --overwrite --path $(ROOT_DIR)/spec/openapi_generated.yml
|
2024-07-05 18:12:28 -07:00
|
|
|
rm -rf e2b/api/client
|
|
|
|
|
mv e2b/api/api/e2b_api_client e2b/api/client
|
|
|
|
|
rm -rf e2b/api/api
|
2025-08-31 21:06:00 +02:00
|
|
|
ruff format .
|
2025-07-28 13:47:26 +02:00
|
|
|
|
2026-03-26 01:37:46 +01:00
|
|
|
generate-volume-api:
|
|
|
|
|
openapi-python-client generate --output-path $(ROOT_DIR)/packages/python-sdk/e2b/volume/api --overwrite --path $(ROOT_DIR)/spec/openapi-volumecontent.yml
|
|
|
|
|
rm -rf e2b/volume/client
|
|
|
|
|
mv e2b/volume/api/e2b_api_client e2b/volume/client
|
|
|
|
|
rm -rf e2b/volume/api
|
|
|
|
|
ruff format .
|
|
|
|
|
|
2025-07-28 13:47:26 +02:00
|
|
|
generate-envd:
|
|
|
|
|
if [ ! -f "/go/bin/protoc-gen-connect-python" ]; then \
|
2025-07-29 12:39:42 +02:00
|
|
|
$(MAKE) -C $(ROOT_DIR)/packages/connect-python build; \
|
2025-07-28 13:47:26 +02:00
|
|
|
fi
|
|
|
|
|
|
2025-07-29 12:39:42 +02:00
|
|
|
cd $(ROOT_DIR)/spec/envd && pwd && buf generate --template buf-python.gen.yaml
|
|
|
|
|
./scripts/fix-python-pb.sh
|
|
|
|
|
|
2025-08-31 21:06:00 +02:00
|
|
|
ruff format .
|
2025-07-28 13:47:26 +02:00
|
|
|
|
2026-03-26 01:37:46 +01:00
|
|
|
generate: generate-api generate-envd generate-mcp generate-volume-api
|
2023-09-29 16:27:26 +02:00
|
|
|
|
2024-07-05 18:12:28 -07:00
|
|
|
init:
|
2025-10-09 01:37:32 -07:00
|
|
|
pip install openapi-python-client datamodel-code-generator
|
2025-06-05 14:52:48 +02:00
|
|
|
|
Fix Python SDK type issues with ty type checker (#1122)
## Summary
- Resolved 43 type diagnostics reported by ty (Astral's Python type
checker)
- Fixed Self type issues on class singletons
- Added explicit type annotations for shadowed attributes
- Replaced None with UNSET for auto-generated API parameters
- Fixed method signature alignment for protocol matching
- Added targeted type: ignore suppressions for pattern-based limitations
All checks pass: ty check, ruff format, ruff check.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Mostly typing/CI changes, but some adjustments affect sandbox
connect/pause overload dispatch and API response/parameter handling
(`UNSET` vs `None`), which could alter edge-case runtime behavior.
>
> **Overview**
> Fixes Python SDK static typing issues for Astral’s `ty` checker and
wires typechecking into CI.
>
> Adds a new `Typecheck` GitHub Action plus workspace `typecheck`
scripts (TS packages via `tsc`, Python SDK via `make typecheck` running
`ty`), and publishes a patch changeset for `@e2b/python-sdk`.
>
> Across the Python SDK, adjusts type annotations and overloads (e.g.,
`Self`/singleton typing, `connect` overloads, optional
`user`/token/domain handling), tightens API model parsing with
`cast`/`Optional` checks and `UNSET` usage, and adds a few targeted `ty`
ignore comments in tests/protocols to silence checker limitations.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f66402847c40cee7e44e1aaa7caa97e271ba9978. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-02-12 17:23:39 +01:00
|
|
|
typecheck:
|
|
|
|
|
ty check
|
|
|
|
|
|
2025-06-05 14:52:48 +02:00
|
|
|
lint:
|
|
|
|
|
ruff check .
|
2026-01-27 14:41:24 +01:00
|
|
|
ruff format --check .
|
2025-08-31 21:06:00 +02:00
|
|
|
|
|
|
|
|
format:
|
2025-10-09 01:37:32 -07:00
|
|
|
ruff format .
|
|
|
|
|
|
|
|
|
|
generate-mcp:
|
|
|
|
|
datamodel-codegen \
|
|
|
|
|
--input ../../spec/mcp-server.json \
|
|
|
|
|
--input-file-type jsonschema \
|
|
|
|
|
--output e2b/sandbox/mcp.py \
|
|
|
|
|
--output-model-type typing.TypedDict \
|
2026-01-26 03:40:19 -08:00
|
|
|
--target-python-version 3.10 \
|
2025-10-09 01:37:32 -07:00
|
|
|
--class-name McpServer \
|
|
|
|
|
--use-field-description \
|
|
|
|
|
--disable-timestamp \
|
2025-11-13 17:58:30 -08:00
|
|
|
--extra-fields forbid
|
|
|
|
|
|
|
|
|
|
.PHONY: setup
|
|
|
|
|
setup:
|
|
|
|
|
poetry install
|
|
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
|
test: setup
|
|
|
|
|
poetry run pytest --verbose --numprocesses=4
|