Skip to content

Commit 547c3b9

Browse files
committed
Refactor #28
1 parent ea9d3f7 commit 547c3b9

File tree

31 files changed

+46
-49
lines changed

31 files changed

+46
-49
lines changed

benchmarks/p2p/test_performance.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pip install pytest-benchmark pyqiwip2p
22
import os
3+
from typing import Any, Callable, Dict, Tuple
34

45
import pytest
56
from pyqiwip2p.AioQiwip2p import AioQiwiP2P
@@ -26,7 +27,9 @@ async def create_bill_with_pyQiwiP2P():
2627

2728

2829
@pytest.fixture()
29-
def aio_benchmark(benchmark: BenchmarkFixture) -> BenchmarkFixture:
30+
def aio_benchmark(
31+
benchmark: BenchmarkFixture,
32+
) -> Callable[[Any, Tuple[Any, ...], Dict[str, Any]], None]:
3033
import asyncio
3134
import threading
3235

glQiwiApi/core/event_fetching/class_based/bill.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def bill_id(self) -> str:
2222

2323
@property
2424
def bill_sum(self) -> Amount:
25-
return self.event.amount
25+
return self.event.value
2626

2727
@property
2828
def pay_url(self) -> str:

glQiwiApi/core/event_fetching/dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self) -> None:
4848

4949
async def process_event(self, event: Event, *args: Any) -> None:
5050
"""
51-
Feed handlers withf\\ event.
51+
Feed handlers with event.
5252
5353
:param event: any object that will be propagated to handlers
5454
"""

glQiwiApi/core/event_fetching/webhooks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from . import app # noqa
44
from .views import QiwiBillWebhookView, QiwiTransactionWebhookView
55

6-
__all__ = ('QiwiBillWebhookView', 'QiwiTransactionWebhookView', 'BaseWebhookView', 'app.py')
6+
__all__ = ('QiwiBillWebhookView', 'QiwiTransactionWebhookView', 'BaseWebhookView', 'app')

glQiwiApi/core/session/holder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import abc
44
from dataclasses import dataclass
55
from types import TracebackType
6-
from typing import Any, Dict, Generic, Mapping, Optional, Set, Type, TypeVar, cast
6+
from typing import Any, Dict, Generic, Mapping, Optional, Type, TypeVar, cast
77

88
import aiohttp
99
from aiohttp import ClientResponse

glQiwiApi/qiwi/clients/p2p/methods/create_p2p_bill.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import uuid
22
from datetime import datetime, timedelta
3-
from typing import Any, ClassVar, Dict, List, Optional, Union
3+
from typing import Any, ClassVar, Dict, List, Optional
44

55
from pydantic import Field, validator
66

glQiwiApi/qiwi/clients/p2p/types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Customer(HashableBase):
2020

2121

2222
class BillStatus(HashableBase):
23-
amount: str
23+
value: str
2424
changed_datetime: Optional[datetime] = Field(None, alias='changedDateTime')
2525

2626

@@ -61,13 +61,13 @@ def invoice_uid(self) -> str:
6161
class RefundedBill(HashableBase):
6262
"""object: RefundedBill"""
6363

64-
amount: Amount
64+
value: Amount
6565
datetime: datetime
6666
refund_id: str = Field(..., alias='refundId')
6767
status: str
6868

6969
def __str__(self) -> str:
70-
return f'№{self.refund_id} {self.status} {self.amount} {self.datetime}'
70+
return f'№{self.refund_id} {self.status} {self.value} {self.datetime}'
7171

7272

7373
class BillWebhookPayload(Bill):
@@ -79,13 +79,13 @@ class BillWebhook(HashableBase):
7979
bill: BillWebhookPayload = Field(..., alias='bill')
8080

8181
def __repr__(self) -> str:
82-
return f'#{self.bill.id} {self.bill.amount} {self.bill.status} '
82+
return f'#{self.bill.id} {self.bill.value} {self.bill.status} '
8383

8484
def verify_signature(self, sha256_signature: str, secret_p2p_key: str) -> None:
8585
webhook_key = base64.b64decode(bytes(secret_p2p_key, 'utf-8'))
8686
bill = self.bill
8787

88-
invoice_params = f'{bill.amount.currency}|{bill.amount.amount}|{bill.id}|{bill.site_id}|{bill.status.amount}'
88+
invoice_params = f'{bill.value.currency}|{bill.value.value}|{bill.id}|{bill.site_id}|{bill.status.value}'
8989
generated_signature = hmac.new(
9090
webhook_key, invoice_params.encode('utf-8'), hashlib.sha256
9191
).hexdigest()

glQiwiApi/qiwi/clients/wallet/methods/authenticate_wallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, ClassVar, Dict, Optional
1+
from typing import Any, ClassVar, Dict
22

33
from pydantic import Field
44

glQiwiApi/qiwi/clients/wallet/methods/detect_mobile_number.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DetectMobileNumber(QiwiAPIMethod[MobileOperator]):
1818
@classmethod
1919
def parse_http_response(cls, response: HTTPResponse) -> ReturningType:
2020
mobile_operator: MobileOperator = super().parse_http_response(response)
21-
if mobile_operator.code.amount == '2' or mobile_operator.code.name == 'ERROR':
21+
if mobile_operator.code.value == '2' or mobile_operator.code.name == 'ERROR':
2222
raise MobileOperatorCannotBeDeterminedError(
2323
response, custom_message=mobile_operator.message
2424
)

glQiwiApi/qiwi/clients/wallet/methods/get_available_balances.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import ClassVar, List
22

33
from glQiwiApi.qiwi.base import QiwiAPIMethod
4-
from glQiwiApi.qiwi.clients.wallet.types import Balance
54
from glQiwiApi.qiwi.clients.wallet.types.balance import AvailableBalance
65

76

0 commit comments

Comments
 (0)