Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
},

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-push-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
echo "Source files are not formatted correctly. Run 'tox -e ruff' to autoformat."
exit 1
fi
- name: Run Linter
run: |
tox -e flake8

build:
needs: lint
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jobs:
echo "Source files are not formatted correctly. Run 'tox -e ruff' to autoformat."
exit 1
fi
- name: Run Linter
run: |
tox -e flake8

build:
needs: lint
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ jobs:
echo "Source files are not formatted correctly. Run 'tox -e ruff' to autoformat."
exit 1
fi
- name: Run Linter
run: |
tox -e flake8

build:
needs: lint
Expand All @@ -64,4 +61,4 @@ jobs:
run: |
tox -e py`echo "${{ matrix.python_ver }}" | sed 's/\.//g'`
- name: Upload test coverage
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v5
32 changes: 13 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Dapr SDK for Python

[![PyPI - Version](https://img.shields.io/pypi/v/dapr?style=flat&logo=pypi&logoColor=white&label=Latest%20version)](https://pypi.org/project/dapr/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/dapr?style=flat&logo=pypi&logoColor=white&label=Downloads)](https://pypi.org/project/dapr/)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/dapr/python-sdk/.github%2Fworkflows%2Fbuild.yaml?branch=main&label=Build&logo=github)](https://github.com/dapr/python-sdk/actions/workflows/build.yaml)
[![codecov](https://codecov.io/gh/dapr/python-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/dapr/python-sdk)
[![GitHub License](https://img.shields.io/github/license/dapr/python-sdk?style=flat&label=License&logo=github)](https://github.com/dapr/python-sdk/blob/main/LICENSE)
[![GitHub issue custom search in repo](https://img.shields.io/github/issues-search/dapr/python-sdk?query=type%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22&label=Good%20first%20issues&style=flat&logo=github)](https://github.com/dapr/python-sdk/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
[![Discord](https://img.shields.io/discord/778680217417809931?label=Discord&style=flat&logo=discord)](http://bit.ly/dapr-discord)
[![YouTube Channel Views](https://img.shields.io/youtube/channel/views/UCtpSQ9BLB_3EXdWAUQYwnRA?style=flat&label=YouTube%20views&logo=youtube)](https://youtube.com/@daprdev)
[![PyPI - Version](https://img.shields.io/pypi/v/dapr?style=flat&logo=pypi&logoColor=white&label=Latest%20version)](https://pypi.org/project/dapr/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/dapr?style=flat&logo=pypi&logoColor=white&label=Downloads)](https://pypi.org/project/dapr/)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/dapr/python-sdk/.github%2Fworkflows%2Fbuild.yaml?branch=main&label=Build&logo=github)](https://github.com/dapr/python-sdk/actions/workflows/build.yaml)
[![codecov](https://codecov.io/gh/dapr/python-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/dapr/python-sdk)
[![GitHub License](https://img.shields.io/github/license/dapr/python-sdk?style=flat&label=License&logo=github)](https://github.com/dapr/python-sdk/blob/main/LICENSE)
[![GitHub issue custom search in repo](https://img.shields.io/github/issues-search/dapr/python-sdk?query=type%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22&label=Good%20first%20issues&style=flat&logo=github)](https://github.com/dapr/python-sdk/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
[![Discord](https://img.shields.io/discord/778680217417809931?label=Discord&style=flat&logo=discord)](http://bit.ly/dapr-discord)
[![YouTube Channel Views](https://img.shields.io/youtube/channel/views/UCtpSQ9BLB_3EXdWAUQYwnRA?style=flat&label=YouTube%20views&logo=youtube)](https://youtube.com/@daprdev)
<!-- IGNORE_LINKS -->
[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/daprdev?logo=x&style=flat)](https://twitter.com/daprdev)
<!-- END_IGNORE -->
Expand Down Expand Up @@ -94,31 +94,25 @@ pip3 install -e ./ext/dapr-ext-workflow/
pip3 install -r dev-requirements.txt
```

4. Run linter

```bash
tox -e flake8
```

5. Run autofix
4. Run linter and autofix

```bash
tox -e ruff
```

6. Run unit-test
5. Run unit-test

```bash
tox -e py311
```

7. Run type check
6. Run type check

```bash
tox -e type
```

8. Run examples
7. Run examples

```bash
tox -e examples
Expand Down Expand Up @@ -153,7 +147,7 @@ export DAPR_BRANCH=release-1.16 # Optional, defaults to master
./tools/regen_grpcclient.sh
```

> Note: The `grpcio-tools` version we're using doesn't support Python 3.13.
> Note: The `grpcio-tools` version we're using doesn't support Python 3.13.

## Help & Feedback

Expand Down
1 change: 0 additions & 1 deletion dapr/actor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from dapr.actor.runtime.remindable import Remindable
from dapr.actor.runtime.runtime import ActorRuntime


__all__ = [
'ActorInterface',
'ActorProxy',
Expand Down
5 changes: 2 additions & 3 deletions dapr/actor/client/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from dapr.actor.runtime._type_utils import get_dispatchable_attrs_from_interface
from dapr.clients import DaprActorClientBase, DaprActorHttpClient
from dapr.clients.retry import RetryPolicy
from dapr.serializers import Serializer, DefaultJSONSerializer
from dapr.conf import settings
from dapr.serializers import DefaultJSONSerializer, Serializer

# Actor factory Callable type hint.
ACTOR_FACTORY_CALLBACK = Callable[[ActorInterface, str, str], 'ActorProxy']
Expand All @@ -35,8 +35,7 @@ def create(
actor_type: str,
actor_id: ActorId,
actor_interface: Optional[Type[ActorInterface]] = None,
) -> 'ActorProxy':
...
) -> 'ActorProxy': ...


class ActorProxyFactory(ActorFactoryBase):
Expand Down
1 change: 0 additions & 1 deletion dapr/actor/runtime/_reminder_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""

import base64

from datetime import timedelta
from typing import Any, Dict, Optional

Expand Down
7 changes: 3 additions & 4 deletions dapr/actor/runtime/_state_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
"""

import io
from typing import Any, List, Tuple, Type

from typing import Any, List, Type, Tuple
from dapr.actor.runtime.state_change import StateChangeKind, ActorStateChange
from dapr.actor.runtime.state_change import ActorStateChange, StateChangeKind
from dapr.clients.base import DaprActorClientBase
from dapr.serializers import Serializer, DefaultJSONSerializer

from dapr.serializers import DefaultJSONSerializer, Serializer

# Mapping StateChangeKind to Dapr State Operation
_MAP_CHANGE_KIND_TO_OPERATION = {
Expand Down
6 changes: 3 additions & 3 deletions dapr/actor/runtime/_type_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
limitations under the License.
"""

from dapr.actor.runtime.remindable import Remindable
from dapr.actor.runtime._type_utils import is_dapr_actor, get_actor_interfaces
from typing import TYPE_CHECKING, List, Type

from typing import List, Type, TYPE_CHECKING
from dapr.actor.runtime._type_utils import get_actor_interfaces, is_dapr_actor
from dapr.actor.runtime.remindable import Remindable

if TYPE_CHECKING:
from dapr.actor.actor_interface import ActorInterface # noqa: F401
Expand Down
5 changes: 2 additions & 3 deletions dapr/actor/runtime/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
"""

import uuid

from datetime import timedelta
from typing import Any, Optional

from dapr.actor.id import ActorId
from dapr.actor.runtime._method_context import ActorMethodContext
from dapr.actor.runtime.context import ActorRuntimeContext
from dapr.actor.runtime.state_manager import ActorStateManager
from dapr.actor.runtime._reminder_data import ActorReminderData
from dapr.actor.runtime._timer_data import TIMER_CALLBACK, ActorTimerData
from dapr.actor.runtime.context import ActorRuntimeContext
from dapr.actor.runtime.state_manager import ActorStateManager


class Actor:
Expand Down
6 changes: 3 additions & 3 deletions dapr/actor/runtime/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
limitations under the License.
"""

from typing import TYPE_CHECKING, Callable, Optional

from dapr.actor.id import ActorId
from dapr.actor.runtime._state_provider import StateProvider
from dapr.clients.base import DaprActorClientBase
from dapr.serializers import Serializer

from typing import Callable, Optional, TYPE_CHECKING

if TYPE_CHECKING:
from dapr.actor.runtime.actor import Actor
from dapr.actor.runtime._type_information import ActorTypeInformation
from dapr.actor.runtime.actor import Actor


class ActorRuntimeContext:
Expand Down
7 changes: 3 additions & 4 deletions dapr/actor/runtime/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@

import asyncio
import uuid

from typing import Any, Callable, Coroutine, Dict, Optional

from dapr.actor.id import ActorId
from dapr.clients.exceptions import DaprInternalError
from dapr.actor.runtime._method_context import ActorMethodContext
from dapr.actor.runtime._reminder_data import ActorReminderData
from dapr.actor.runtime.actor import Actor
from dapr.actor.runtime.context import ActorRuntimeContext
from dapr.actor.runtime._method_context import ActorMethodContext
from dapr.actor.runtime.method_dispatcher import ActorMethodDispatcher
from dapr.actor.runtime._reminder_data import ActorReminderData
from dapr.actor.runtime.reentrancy_context import reentrancy_ctx
from dapr.clients.exceptions import DaprInternalError

TIMER_METHOD_NAME = 'fire_timer'
REMINDER_METHOD_NAME = 'receive_reminder'
Expand Down
3 changes: 2 additions & 1 deletion dapr/actor/runtime/method_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"""

from typing import Any, Dict, List
from dapr.actor.runtime.actor import Actor

from dapr.actor.runtime._type_information import ActorTypeInformation
from dapr.actor.runtime._type_utils import get_dispatchable_attrs
from dapr.actor.runtime.actor import Actor


class ActorMethodDispatcher:
Expand Down
2 changes: 1 addition & 1 deletion dapr/actor/runtime/reentrancy_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
limitations under the License.
"""

from typing import Optional
from contextvars import ContextVar
from typing import Optional

reentrancy_ctx: ContextVar[Optional[str]] = ContextVar('reentrancy_ctx', default=None)
10 changes: 4 additions & 6 deletions dapr/actor/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@
"""

import asyncio

from typing import Dict, List, Optional, Type, Callable
from typing import Callable, Dict, List, Optional, Type

from dapr.actor.id import ActorId
from dapr.actor.runtime._type_information import ActorTypeInformation
from dapr.actor.runtime.actor import Actor
from dapr.actor.runtime.config import ActorRuntimeConfig
from dapr.actor.runtime.context import ActorRuntimeContext
from dapr.actor.runtime._type_information import ActorTypeInformation
from dapr.actor.runtime.manager import ActorManager
from dapr.actor.runtime.reentrancy_context import reentrancy_ctx
from dapr.clients.http.dapr_actor_http_client import DaprActorHttpClient
from dapr.serializers import Serializer, DefaultJSONSerializer
from dapr.conf import settings

from dapr.actor.runtime.reentrancy_context import reentrancy_ctx
from dapr.serializers import DefaultJSONSerializer, Serializer


class ActorRuntime:
Expand Down
2 changes: 1 addition & 1 deletion dapr/actor/runtime/state_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""

from enum import Enum
from typing import TypeVar, Generic, Optional
from typing import Generic, Optional, TypeVar

T = TypeVar('T')

Expand Down
15 changes: 8 additions & 7 deletions dapr/aio/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

from typing import Callable, Dict, List, Optional, Union

from google.protobuf.message import Message as GrpcMessage

from dapr.aio.clients.grpc.client import DaprGrpcClientAsync, InvokeMethodResponse, MetadataTuple
from dapr.clients.base import DaprActorClientBase
from dapr.clients.exceptions import DaprInternalError, ERROR_CODE_UNKNOWN
from dapr.aio.clients.grpc.client import DaprGrpcClientAsync, MetadataTuple, InvokeMethodResponse
from dapr.clients.grpc._jobs import Job, FailurePolicy, DropFailurePolicy, ConstantFailurePolicy
from dapr.clients.exceptions import ERROR_CODE_UNKNOWN, DaprInternalError
from dapr.clients.grpc._jobs import ConstantFailurePolicy, DropFailurePolicy, FailurePolicy, Job
from dapr.clients.http.dapr_actor_http_client import DaprActorHttpClient
from dapr.clients.http.dapr_invocation_http_client import DaprInvocationHttpClient
from dapr.conf import settings
from google.protobuf.message import Message as GrpcMessage

__all__ = [
'DaprClient',
Expand All @@ -37,10 +38,10 @@
]

from grpc.aio import ( # type: ignore
UnaryUnaryClientInterceptor,
UnaryStreamClientInterceptor,
StreamUnaryClientInterceptor,
StreamStreamClientInterceptor,
StreamUnaryClientInterceptor,
UnaryStreamClientInterceptor,
UnaryUnaryClientInterceptor,
)


Expand Down
2 changes: 1 addition & 1 deletion dapr/aio/clients/grpc/_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io
from typing import Union

from dapr.clients.grpc._crypto import EncryptOptions, DecryptOptions
from dapr.clients.grpc._crypto import DecryptOptions, EncryptOptions
from dapr.clients.grpc._helpers import to_bytes
from dapr.clients.grpc._request import DaprRequest
from dapr.proto import api_v1, common_v1
Expand Down
8 changes: 3 additions & 5 deletions dapr/aio/clients/grpc/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from typing import AsyncGenerator, Generic

from dapr.proto import api_v1
from dapr.clients.grpc._response import DaprResponse, TCryptoResponse
from dapr.proto import api_v1


class CryptoResponse(DaprResponse, Generic[TCryptoResponse]):
Expand Down Expand Up @@ -83,9 +83,7 @@ async def read(self, size: int = -1) -> bytes:
return data[:size]


class EncryptResponse(CryptoResponse[api_v1.EncryptResponse]):
...
class EncryptResponse(CryptoResponse[api_v1.EncryptResponse]): ...


class DecryptResponse(CryptoResponse[api_v1.DecryptResponse]):
...
class DecryptResponse(CryptoResponse[api_v1.DecryptResponse]): ...
Loading