Skip to content

Commit

Permalink
Merge pull request #35 from permitio/asaf/per-5576-python-sdk-fix-38-…
Browse files Browse the repository at this point in the history
…support

Fix python 3.8 support
  • Loading branch information
asafc authored May 22, 2023
2 parents a0143f4 + ddfec64 commit e76dfcc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions permit/api/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import functools
from typing import Optional, Type, TypeVar
from typing import Optional, Type, TypeVar, Union

import aiohttp
from loguru import logger
Expand Down Expand Up @@ -71,7 +71,7 @@ def _log_response(self, url: str, method: str, status: int) -> None:
)

def _prepare_json(
self, json: Optional[TData | dict | list] = None
self, json: Optional[Union[TData, dict, list]] = None
) -> Optional[dict]:
if json is None:
return None
Expand Down Expand Up @@ -100,7 +100,7 @@ async def post(
self,
url,
model: Type[TModel],
json: Optional[TData | dict | list] = None,
json: Optional[Union[TData, dict, list]] = None,
**kwargs,
) -> TModel:
url = f"{self._base_url}{url}"
Expand All @@ -119,7 +119,7 @@ async def put(
self,
url,
model: Type[TModel],
json: Optional[TData | dict | list] = None,
json: Optional[Union[TData, dict, list]] = None,
**kwargs,
) -> TModel:
url = f"{self._base_url}{url}"
Expand All @@ -138,7 +138,7 @@ async def patch(
self,
url,
model: Type[TModel],
json: Optional[TData | dict | list] = None,
json: Optional[Union[TData, dict, list]] = None,
**kwargs,
) -> TModel:
url = f"{self._base_url}{url}"
Expand All @@ -156,10 +156,10 @@ async def patch(
async def delete(
self,
url,
model: Type[TModel] | None = None,
json: Optional[TData | dict | list] = None,
model: Optional[Type[TModel]] = None,
json: Optional[Union[TData, dict, list]] = None,
**kwargs,
) -> TModel | None:
) -> Optional[TModel]:
url = f"{self._base_url}{url}"
async with aiohttp.ClientSession(**self._client_config) as client:
self._log_request(url, "DELETE")
Expand Down
2 changes: 1 addition & 1 deletion permit/api/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ async def delete_resource(self, resource_key: str):

@deprecated("use permit.elements.login_as() instead")
async def elements_login_as(
self, user_id: str | UUID, tenant_id: str | UUID
self, user_id: Union[str, UUID], tenant_id: Union[str, UUID]
) -> EmbeddedLoginRequestOutput:
return await self.__elements.login_as(user_id=user_id, tenant_id=tenant_id)
4 changes: 2 additions & 2 deletions permit/api/elements.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Optional
from typing import Optional, Union
from uuid import UUID

from pydantic import BaseModel, Field
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self, config: PermitConfig):
self.__auth = self._build_http_client("/v2/auth")

async def login_as(
self, user_id: str | UUID, tenant_id: str | UUID
self, user_id: Union[str, UUID], tenant_id: Union[str, UUID]
) -> UserLoginAsResponse:
if isinstance(user_id, UUID):
user_id = user_id.hex
Expand Down
4 changes: 2 additions & 2 deletions permit/api/users.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import List, Optional, Union

from pydantic import validate_arguments

Expand Down Expand Up @@ -152,7 +152,7 @@ async def update(self, user_key: str, user_data: UserUpdate) -> UserRead:

@ensure_context(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY)
@validate_arguments
async def sync(self, user: UserCreate | dict) -> UserRead:
async def sync(self, user: Union[UserCreate, dict]) -> UserRead:
"""
Synchronizes user data by creating or updating a user.
Expand Down
4 changes: 2 additions & 2 deletions permit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
self,
message: str,
response: aiohttp.ClientResponse,
response_json: dict | None = None,
response_json: Optional[dict] = None,
):
super().__init__(message)
self._response = response
Expand All @@ -55,7 +55,7 @@ def response(self) -> aiohttp.ClientResponse:
return self._response

@property
def details(self) -> dict | None:
def details(self) -> Optional[dict]:
"""
Get the HTTP response JSON body. Contains details about the error.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def get_requirements(env=""):

setup(
name="permit",
version="2.0.0",
version="2.0.1",
packages=find_packages(),
author="Asaf Cohen",
author_email="[email protected]",
license="Apache 2.0",
python_requires=">=3.7",
python_requires=">=3.8",
description="Permit.io python sdk",
install_requires=get_requirements(),
classifiers=[
Expand Down

0 comments on commit e76dfcc

Please sign in to comment.