Fixes: 1) Add `# ty: ignore` comments to suppress type errors in multiple files; 2) Correct method argument annotations and definitions to align with type hints; 3) Fix cases of invalid or missing imports and unresolved attributes; Extra: Refactor method definitions to use tuple-based method declarations; replace custom type aliases with `Any`; improve caching utility and error handling logic in utility scripts.
26 lines
902 B
Python
26 lines
902 B
Python
import graphene
|
|
from graphene import Mutation
|
|
from rest_framework.exceptions import PermissionDenied
|
|
|
|
from engine.core.utils.messages import permission_denied_message
|
|
from engine.payments.graphene.object_types import TransactionType
|
|
from engine.payments.models import Transaction
|
|
|
|
|
|
class Deposit(Mutation):
|
|
class Arguments:
|
|
amount = graphene.Float(required=True)
|
|
|
|
transaction = graphene.Field(TransactionType)
|
|
|
|
def mutate(self, info, amount):
|
|
if info.context.user.is_authenticated:
|
|
transaction = Transaction.objects.create(
|
|
balance=info.context.user.payments_balance,
|
|
amount=amount,
|
|
currency="EUR",
|
|
)
|
|
# noinspection PyTypeChecker
|
|
return Deposit(transaction=transaction) # ty: ignore[unknown-argument]
|
|
else:
|
|
raise PermissionDenied(permission_denied_message)
|