Skip to content

Commit

Permalink
MAINT: Clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd committed Oct 19, 2023
1 parent f572306 commit bcec1be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
17 changes: 6 additions & 11 deletions migas/operations.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
"""
Create queries and mutations to be sent to the graphql endpoint.
"""
import sys
import typing
from __future__ import annotations

import typing as ty

from migas.config import Config, logger, telemetry_enabled
from migas.request import request

if sys.version_info[:2] >= (3, 8):
from typing import TypedDict
else:
# TODO: 3.8 - Remove backport
from typing_extensions import TypedDict


DEFAULT_ERROR = '[migas-py] An error occurred.'


class OperationTemplate(TypedDict):
class OperationTemplate(ty.TypedDict):
operation: str
args: dict
response: dict
Expand Down Expand Up @@ -135,7 +130,7 @@ def add_project(
return res


def _introspec(func: typing.Callable, func_locals: dict) -> dict:
def _introspec(func: ty.Callable, func_locals: dict) -> dict:
"""Inspect a function and return all parameters (not defaults)."""
import inspect

Expand Down Expand Up @@ -164,7 +159,7 @@ def _formulate_query(params: dict, template: OperationTemplate) -> str:
return query


def _filter_response(response: typing.Union[dict, str], operation: str, fallback: dict):
def _filter_response(response: dict | str, operation: str, fallback: dict):
if isinstance(response, dict):
res = response.get("data")
# success
Expand Down
4 changes: 2 additions & 2 deletions migas/tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_operations(setup_migas):
time.sleep(2)
_test_get_usage()

def _test_add_project(setup_migas):
def _test_add_project():
res = add_project(test_project, __version__)
assert res['success'] is True
latest = res['latest_version']
Expand All @@ -43,7 +43,7 @@ def _test_add_project(setup_migas):
assert res['success'] is False
assert res['latest_version'] is None

def _test_get_usage(setup_migas):
def _test_get_usage():
"""This test requires `_test_add_project()` to be run before."""
res = get_usage(test_project, start=today)
assert res['success'] is True
Expand Down
4 changes: 0 additions & 4 deletions migas/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ def _check_server_available() -> bool:
return False
return True


def patched_add_project(project: str, project_version: str, **kwargs) -> dict:
return kwargs

do_server_tests = _check_server_available()

0 comments on commit bcec1be

Please sign in to comment.