Skip to content

Commit

Permalink
Merge pull request #33 from mdaehnert/master
Browse files Browse the repository at this point in the history
Static typings added.
  • Loading branch information
jaymccon authored Feb 11, 2020
2 parents 08d2627 + 1c04b22 commit 006d4e9
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ coverage.xml
/.pytest_cache/
/build/
*.egg-info/
/.mypy_cache/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trapping, and detailed configurable logging.
* JSON logging that includes request id's, stack id's and request type to assist in tracing logs relevant to a
particular CloudFormation event
* Catches function timeouts and sends CloudFormation a failure response
* Static typing (mypy) compatible

## Installation

Expand Down
7 changes: 7 additions & 0 deletions crhelper/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
*.pyi files are auto-generated with the following commands:
$> pip install mypy
$> stubgen ./crhelper -o .
"""
from crhelper.resource_helper import CfnResource as CfnResource, FAILED as FAILED, SUCCESS as SUCCESS
10 changes: 10 additions & 0 deletions crhelper/log_helper.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import logging
from typing import Any, Optional

class JsonFormatter(logging.Formatter):
format_dict: Any = ...
default_json_formatter: Any = ...
def __init__(self, **kwargs: Any) -> None: ...
def format(self, record: Any): ...

def setup(level: str = ..., formatter_cls: Any = ..., boto_level: Optional[Any] = ..., **kwargs: Any) -> None: ...
25 changes: 25 additions & 0 deletions crhelper/resource_helper.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from crhelper import log_helper as log_helper
from typing import Any

logger: Any
SUCCESS: str
FAILED: str

class CfnResource:
Status: str = ...
Reason: str = ...
PhysicalResourceId: str = ...
StackId: str = ...
RequestId: str = ...
LogicalResourceId: str = ...
Data: Any = ...
def __init__(self, json_logging: bool = ..., log_level: str = ..., boto_level: str = ..., polling_interval: int = ..., sleep_on_delete: int = ...) -> None: ...
def __call__(self, event: Any, context: Any) -> None: ...
def generate_physical_id(self, event: Any): ...
def create(self, func: Any): ...
def update(self, func: Any): ...
def delete(self, func: Any): ...
def poll_create(self, func: Any): ...
def poll_update(self, func: Any): ...
def poll_delete(self, func: Any): ...
def init_failure(self, error: Any) -> None: ...
3 changes: 3 additions & 0 deletions crhelper/utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

logger: Any
Empty file added py.typed
Empty file.

0 comments on commit 006d4e9

Please sign in to comment.