Skip to content

Commit

Permalink
Typing Stub 지원 (#34)
Browse files Browse the repository at this point in the history
* 타입 정의 파일 추가

* Travis-CI 테스트에 mypy 테스트 추가

* 배포시 pyi 포함되도록 설정

* Travis-CI에서 mypy가 지원하지 않는 pypy/2.7/3.4는 제외하도록 설정
  • Loading branch information
item4 authored Mar 4, 2020
1 parent d6a2421 commit 3a223d7
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ crashlytics.properties
crashlytics-build.properties

.pytest_cache/
.mypy_cache/
.python-version
venv/

20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
language: python
sudo: false
python:
- pypy
- 2.7
- 3.4
- 3.5
- 3.6
jobs:
includes:
- python: pypy
env: RUN_MYPY=false
- python: 2.7
env: RUN_MYPY=false
- python: 3.4
env: RUN_MYPY=false
- python: 3.5
env: RUN_MYPY=true
- python: 3.6
env: RUN_MYPY=true
install:
- pip install tox-travis flake8 collective.checkdocs Pygments
- $RUN_MYPY && pip install mypy || true
script:
- flake8 .
- python setup.py checkdocs
- tox
- $RUN_MYPY && mypy iamport || true
after_success:
- bash <(curl -s https://codecov.io/bash)
66 changes: 66 additions & 0 deletions iamport/client.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from typing import Any, Dict, Optional, Union

import requests

IAMPORT_API_URL: str = ...
Amount = Union[int, float]

class Iamport(object):
requests_session: requests.Session

def __init__(self, imp_key: str, imp_secret: str, imp_url: str = ...) -> None: ...

class ResponseError(Exception):
code: Any
message: Any
def __init__(self, code: Optional[Any] = ..., message: Optional[Any] = ...) -> None: ...

class HttpError(Exception):
code: Any
message: Any
def __init__(self, code: Optional[Any] = ..., message: Optional[Any] = ...) -> None: ...

@staticmethod
def get_response(response: requests.Response) -> Dict: ...

def _get_token(self) -> str: ...

def get_headers(self) -> Dict[str, str]: ...

def _get(self, url: str, payload: Optional[Dict[str, Any]] = ...) -> Dict: ...

def _post(self, url: str, payload: Optional[Dict[str, Any]] = ...) -> Dict: ...

def find_by_merchant_uid(self, merchant_uid: str) -> Dict: ...

def find_by_imp_uid(self, imp_uid: str) -> Dict: ...

def find(self, **kwargs) -> Dict: ...

def _cancel(self, payload: Dict[str, Any]) -> Dict: ...

def pay_onetime(self, **kwargs) -> Dict: ...

def pay_again(self, **kwargs) -> Dict: ...

def customer_create(self, **kwargs) -> Dict: ...

def customer_get(self, customer_uid: str) -> Dict: ...

def pay_foreign(self, **kwargs) -> Dict: ...

def pay_schedule(self, **kwargs) -> Dict: ...

def pay_unschedule(self, **kwargs) -> Dict: ...

def cancel_by_merchant_uid(self, merchant_uid: str, reason: str, **kwargs) -> Dict: ...

def cancel_by_imp_uid(self, imp_uid: str, reason: str, **kwargs) -> Dict: ...

def cancel(self, reason: str, **kwargs) -> Dict: ...

def is_paid(self, amount: Amount, **kwargs) -> bool: ...

def prepare(self, merchant_uid: str, amount: Amount) -> Dict: ...

def prepare_validate(self, merchant_uid: str, amount: Amount) -> Dict: ...
22 changes: 22 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ def readme():
long_description=readme(),
license='MIT',
zip_safe=False,
data_files=[
(
'shared/typehints/python2.7',
['iamport/client.pyi'],
),
(
'shared/typehints/python3.5',
['iamport/client.pyi'],
),
(
'shared/typehints/python3.6',
['iamport/client.pyi'],
),
(
'shared/typehints/python3.7',
['iamport/client.pyi'],
),
(
'shared/typehints/python3.8',
['iamport/client.pyi'],
),
],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Environment :: Web Environment',
Expand Down

0 comments on commit 3a223d7

Please sign in to comment.