Skip to content

Commit

Permalink
Merge pull request #1046 from appwrite/add-python-types
Browse files Browse the repository at this point in the history
fix: add typing module for python 3.13
  • Loading branch information
christyjacob4 authored Mar 10, 2025
2 parents f0ee4cc + 646d88a commit 2518f24
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
Python310,
Python311,
Python312,
Python313,
Ruby27,
Ruby30,
Ruby31,
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Python.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ public function getTypeName(array $parameter, array $spec = []): string
return 'str';
case self::TYPE_ARRAY:
if (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type'])) {
return 'list[' . $this->getTypeName($parameter['array']) . ']';
return 'List[' . $this->getTypeName($parameter['array']) . ']';
}
return 'list[str]';
return 'List[str]';
case self::TYPE_OBJECT:
return 'dict';
default:
Expand Down
1 change: 1 addition & 0 deletions templates/python/package/services/service.py.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..service import Service
from typing import List
from ..exception import AppwriteException
{% set added = [] %}
{% for method in service.methods %}
Expand Down
34 changes: 34 additions & 0 deletions tests/Python313Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Tests;

class Python313Test extends Base
{
protected string $sdkName = 'python';
protected string $sdkPlatform = 'server';
protected string $sdkLanguage = 'python';
protected string $version = '0.0.1';

protected string $language = 'python';
protected string $class = 'Appwrite\SDK\Language\Python';
protected array $build = [
'cp tests/languages/python/tests.py tests/sdks/python/test.py',
'echo "" > tests/sdks/python/__init__.py',
'docker run --rm -v $(pwd):/app -w /app --env PIP_TARGET=tests/sdks/python/vendor python:3.13-alpine pip install -r tests/sdks/python/requirements.txt --upgrade',
];
protected string $command =
'docker run --network="mockapi" --rm -v $(pwd):/app -w /app --env PIP_TARGET=tests/sdks/python/vendor --env PYTHONPATH=tests/sdks/python/vendor python:3.13-alpine python tests/sdks/python/test.py';

protected array $expectedOutput = [
...Base::FOO_RESPONSES,
...Base::BAR_RESPONSES,
...Base::GENERAL_RESPONSES,
...Base::UPLOAD_RESPONSES,
...Base::ENUM_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::OAUTH_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
...Base::PERMISSION_HELPER_RESPONSES,
...Base::ID_HELPER_RESPONSES
];
}

0 comments on commit 2518f24

Please sign in to comment.