Skip to content

Commit

Permalink
Hotfix/sdk py38 (#5279)
Browse files Browse the repository at this point in the history
* replace unsupported Annotated, MappingProxyType, is_annotated_dc

* fix package builder
  • Loading branch information
montezdesousa authored Aug 3, 2023
1 parent 61afffb commit 70f70a8
Show file tree
Hide file tree
Showing 19 changed files with 1,181 additions and 952 deletions.
3 changes: 2 additions & 1 deletion openbb_sdk/sdk/core/openbb_core/api/dependency/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime, timedelta
from typing import Annotated, Optional
from typing import Optional

from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer
Expand All @@ -11,6 +11,7 @@
from openbb_core.app.service.user_service import UserService
from passlib.context import CryptContext
from pymongo import MongoClient
from typing_extensions import Annotated

SECRET_KEY = "a0657288545d1d2e991195841782ae2a22574a22954081db0c2888c5f5ddbecc" # nosec # pragma: allowlist secret
ALGORITHM = "HS256"
Expand Down
3 changes: 1 addition & 2 deletions openbb_sdk/sdk/core/openbb_core/api/router/account.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Annotated

from fastapi import APIRouter, Depends, Form, HTTPException, status
from fastapi.security import OAuth2PasswordRequestForm
from openbb_core.api.dependency.user import (
Expand All @@ -14,6 +12,7 @@
from openbb_core.api.model.token_response import TokenResponse
from openbb_core.app.model.user_settings import UserSettings
from openbb_core.app.service.hub_service import HubService
from typing_extensions import Annotated

router = APIRouter(prefix="/account", tags=["Account"])

Expand Down
4 changes: 2 additions & 2 deletions openbb_sdk/sdk/core/openbb_core/api/router/commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import partial, wraps
from inspect import Parameter, Signature, signature
from typing import Annotated, Any, Callable, Dict, Tuple, TypeVar
from typing import Any, Callable, Dict, Tuple, TypeVar

from fastapi import APIRouter, Depends
from fastapi.routing import APIRoute
Expand All @@ -10,7 +10,7 @@
from openbb_core.app.model.user_settings import UserSettings
from openbb_core.app.router import RouterLoader
from openbb_core.app.service.system_service import SystemService
from typing_extensions import ParamSpec
from typing_extensions import Annotated, ParamSpec

T = TypeVar("T")
P = ParamSpec("P")
Expand Down
3 changes: 1 addition & 2 deletions openbb_sdk/sdk/core/openbb_core/api/router/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Annotated

from fastapi import APIRouter, Depends
from openbb_core.api.dependency.user import (
UserService,
Expand All @@ -8,6 +6,7 @@
)
from openbb_core.app.model.credentials import Credentials
from openbb_core.app.model.user_settings import UserSettings
from typing_extensions import Annotated

router = APIRouter(prefix="/settings", tags=["Settings"])

Expand Down
3 changes: 1 addition & 2 deletions openbb_sdk/sdk/core/openbb_core/api/router/system.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Annotated

from fastapi import APIRouter, Depends
from openbb_core.api.dependency.system import get_system_settings
from openbb_core.app.model.system_settings import SystemSettings
from typing_extensions import Annotated

router = APIRouter(prefix="/system", tags=["System"])

Expand Down
9 changes: 4 additions & 5 deletions openbb_sdk/sdk/core/openbb_core/app/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import warnings
from functools import partial
from inspect import Parameter, Signature, signature
from types import MappingProxyType
from typing import (
Annotated,
Any,
Callable,
Dict,
List,
Mapping,
Optional,
Type,
get_args,
get_origin,
get_type_hints,
overload,
)
Expand All @@ -22,6 +20,7 @@
from pydantic import BaseModel
from pydantic.config import BaseConfig
from pydantic.validators import find_validators
from typing_extensions import Annotated, _AnnotatedAlias

from openbb_core.app.model.abstract.warning import OpenBBWarning
from openbb_core.app.model.command_context import CommandContext
Expand Down Expand Up @@ -73,15 +72,15 @@ def is_serializable_value_type(cls, value_type: Type) -> bool:

@staticmethod
def is_annotated_dc(annotation) -> bool:
return get_origin(annotation) == Annotated and hasattr(
return type(annotation) is _AnnotatedAlias and hasattr(
annotation.__args__[0], "__dataclass_fields__"
)

@staticmethod
def check_reserved_param(
name: str,
expected_annot: Any,
parameter_map: MappingProxyType[str, Parameter],
parameter_map: Mapping[str, Parameter],
func: Callable,
sig: Signature,
):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###



from openbb_core.app.static.container import Container


Expand Down
4 changes: 2 additions & 2 deletions openbb_sdk/sdk/core/openbb_core/app/static/package/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datetime
import typing
from typing import Literal, Optional, Union
from typing import Literal, Union

from pydantic import validate_arguments

Expand All @@ -20,7 +20,7 @@ def load(
start_date: Union[datetime.date, None, str] = None,
end_date: Union[datetime.date, None, str] = None,
chart: bool = False,
provider: Optional[Literal["fmp", "polygon"]] = None,
provider: Union[Literal["fmp", "polygon"], None] = None,
**kwargs
) -> CommandOutput[typing.List]:
r"""Crypto Intraday Price.
Expand Down
Loading

0 comments on commit 70f70a8

Please sign in to comment.