Skip to content

Commit 3a223d7

Browse files
authored
Typing Stub 지원 (#34)
* 타입 정의 파일 추가 * Travis-CI 테스트에 mypy 테스트 추가 * 배포시 pyi 포함되도록 설정 * Travis-CI에서 mypy가 지원하지 않는 pypy/2.7/3.4는 제외하도록 설정
1 parent d6a2421 commit 3a223d7

File tree

4 files changed

+103
-6
lines changed

4 files changed

+103
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ crashlytics.properties
107107
crashlytics-build.properties
108108

109109
.pytest_cache/
110+
.mypy_cache/
110111
.python-version
111112
venv/
112113

.travis.yml

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
language: python
22
sudo: false
3-
python:
4-
- pypy
5-
- 2.7
6-
- 3.4
7-
- 3.5
8-
- 3.6
3+
jobs:
4+
includes:
5+
- python: pypy
6+
env: RUN_MYPY=false
7+
- python: 2.7
8+
env: RUN_MYPY=false
9+
- python: 3.4
10+
env: RUN_MYPY=false
11+
- python: 3.5
12+
env: RUN_MYPY=true
13+
- python: 3.6
14+
env: RUN_MYPY=true
915
install:
1016
- pip install tox-travis flake8 collective.checkdocs Pygments
17+
- $RUN_MYPY && pip install mypy || true
1118
script:
1219
- flake8 .
1320
- python setup.py checkdocs
1421
- tox
22+
- $RUN_MYPY && mypy iamport || true
1523
after_success:
1624
- bash <(curl -s https://codecov.io/bash)

iamport/client.pyi

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from typing import Any, Dict, Optional, Union
2+
3+
import requests
4+
5+
IAMPORT_API_URL: str = ...
6+
Amount = Union[int, float]
7+
8+
class Iamport(object):
9+
requests_session: requests.Session
10+
11+
def __init__(self, imp_key: str, imp_secret: str, imp_url: str = ...) -> None: ...
12+
13+
class ResponseError(Exception):
14+
code: Any
15+
message: Any
16+
def __init__(self, code: Optional[Any] = ..., message: Optional[Any] = ...) -> None: ...
17+
18+
class HttpError(Exception):
19+
code: Any
20+
message: Any
21+
def __init__(self, code: Optional[Any] = ..., message: Optional[Any] = ...) -> None: ...
22+
23+
@staticmethod
24+
def get_response(response: requests.Response) -> Dict: ...
25+
26+
def _get_token(self) -> str: ...
27+
28+
def get_headers(self) -> Dict[str, str]: ...
29+
30+
def _get(self, url: str, payload: Optional[Dict[str, Any]] = ...) -> Dict: ...
31+
32+
def _post(self, url: str, payload: Optional[Dict[str, Any]] = ...) -> Dict: ...
33+
34+
def find_by_merchant_uid(self, merchant_uid: str) -> Dict: ...
35+
36+
def find_by_imp_uid(self, imp_uid: str) -> Dict: ...
37+
38+
def find(self, **kwargs) -> Dict: ...
39+
40+
def _cancel(self, payload: Dict[str, Any]) -> Dict: ...
41+
42+
def pay_onetime(self, **kwargs) -> Dict: ...
43+
44+
def pay_again(self, **kwargs) -> Dict: ...
45+
46+
def customer_create(self, **kwargs) -> Dict: ...
47+
48+
def customer_get(self, customer_uid: str) -> Dict: ...
49+
50+
def pay_foreign(self, **kwargs) -> Dict: ...
51+
52+
def pay_schedule(self, **kwargs) -> Dict: ...
53+
54+
def pay_unschedule(self, **kwargs) -> Dict: ...
55+
56+
def cancel_by_merchant_uid(self, merchant_uid: str, reason: str, **kwargs) -> Dict: ...
57+
58+
def cancel_by_imp_uid(self, imp_uid: str, reason: str, **kwargs) -> Dict: ...
59+
60+
def cancel(self, reason: str, **kwargs) -> Dict: ...
61+
62+
def is_paid(self, amount: Amount, **kwargs) -> bool: ...
63+
64+
def prepare(self, merchant_uid: str, amount: Amount) -> Dict: ...
65+
66+
def prepare_validate(self, merchant_uid: str, amount: Amount) -> Dict: ...

setup.py

+22
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@ def readme():
2323
long_description=readme(),
2424
license='MIT',
2525
zip_safe=False,
26+
data_files=[
27+
(
28+
'shared/typehints/python2.7',
29+
['iamport/client.pyi'],
30+
),
31+
(
32+
'shared/typehints/python3.5',
33+
['iamport/client.pyi'],
34+
),
35+
(
36+
'shared/typehints/python3.6',
37+
['iamport/client.pyi'],
38+
),
39+
(
40+
'shared/typehints/python3.7',
41+
['iamport/client.pyi'],
42+
),
43+
(
44+
'shared/typehints/python3.8',
45+
['iamport/client.pyi'],
46+
),
47+
],
2648
classifiers=[
2749
'Development Status :: 2 - Pre-Alpha',
2850
'Environment :: Web Environment',

0 commit comments

Comments
 (0)