Skip to content

Commit

Permalink
v2.5: fix type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
benkehoe committed Jan 20, 2022
1 parent b98ab00 commit 0684cbf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
shell: bash
- run: poetry run pytest
shell: bash
- run: poetry run mypy aws_error_utils --ignore-missing-imports
shell: bash
build-and-publish:
needs: test
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

`aws-error-utils` uses [monotonic versioning](blog.appliedcompscilab.com/monotonic_versioning_manifesto/).

## v2.5
* Fix type annotations.

## v2.4
* Require Python 3.6 as 3.5 is EOL.
* Update `AWSErrorInfo` to be a dataclass.
Expand Down
10 changes: 5 additions & 5 deletions aws_error_utils/aws_error_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
operation_name = e.operation_name
"""

__version__ = "2.4.0" # update here and pyproject.toml
__version__ = "2.5.0" # update here and pyproject.toml

__all__ = [
"AWSErrorInfo",
Expand All @@ -37,7 +37,7 @@

import dataclasses
import sys
from typing import Optional, List, Union, Callable
from typing import Optional, List, Union, Callable, Type

from botocore.exceptions import BotoCoreError, ClientError

Expand Down Expand Up @@ -130,7 +130,7 @@ def catch_aws_error(
*args: Union[str, Callable],
code: Union[None, str, List[str]] = None,
operation_name: Union[None, str, List[str]] = None
) -> Exception:
) -> Type[BaseException]:
"""For use in an except statement, returns the current error's type if it matches the arguments, otherwise a non-matching error type
Any positional arguments and the contents of the 'code' kwarg are matched
Expand Down Expand Up @@ -163,7 +163,7 @@ def catch_aws_error(
if args[0](client_error):
matched = True
elif aws_error_matches(
client_error, *args, code=code, operation_name=operation_name
client_error, *args, code=code, operation_name=operation_name # type: ignore
):
matched = True
if matched:
Expand All @@ -180,7 +180,7 @@ def catch_aws_error(

# Use a metaclass to hook into field access on the class
class _ErrorsMeta(type):
def __getattr__(self, name) -> Exception:
def __getattr__(self, name) -> Type[BaseException]:
if not sys.exc_info()[0]:
raise RuntimeError(
"You must use {}.{} inside an except statement".format(
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aws-error-utils"
version = "2.4.0" # update here and aws_error_utils.py
version = "2.5.0" # update here and aws_error_utils.py
description = "Error-handling functions for boto3/botocore"
authors = ["Ben Kehoe"]
license = "Apache-2.0"
Expand All @@ -24,6 +24,8 @@ dataclasses = { version = "*", python = "<3.7" }
[tool.poetry.dev-dependencies]
pylint = "*"
pytest = "^6.2.5"
mypy = "^0.931"
types-dataclasses = { version = "*", python = "<3.7" }

[build-system]
requires = ["poetry>=0.12"]
Expand Down

0 comments on commit 0684cbf

Please sign in to comment.