Skip to content

Commit

Permalink
fix: cycle of references between helpers and types
Browse files Browse the repository at this point in the history
  • Loading branch information
leynier committed Oct 18, 2021
1 parent 3ab70a5 commit fcad1af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
11 changes: 1 addition & 10 deletions gotrue/common/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Optional, TypeVar, Union
from typing import Any, Callable, TypeVar, Union
from urllib.parse import quote

from httpx import Response
Expand All @@ -12,15 +12,6 @@ def encode_uri_component(uri: str) -> str:
return quote(uri.encode("utf-8"))


def parse_none(
value: Optional[T],
func: Callable[[Any], T],
) -> Optional[T]:
if value is None:
return None
return func(value)


def parse_response(response: Response, func: Callable[[Any], T]) -> T:
if response.status_code == 200:
json = response.json()
Expand Down
13 changes: 11 additions & 2 deletions gotrue/common/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from dataclasses import dataclass
from enum import Enum
from typing import Any, Callable, Dict, Optional
from typing import Any, Callable, Dict, Optional, TypeVar

from .helpers import parse_none
T = TypeVar("T")


def parse_none(
value: Optional[T],
func: Callable[[Any], T],
) -> Optional[T]:
if value is None:
return None
return func(value)


@dataclass
Expand Down

0 comments on commit fcad1af

Please sign in to comment.