Skip to content

Commit 4f51270

Browse files
author
Janos Tolgyesi
committed
Configure linter
1 parent f41bb0a commit 4f51270

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

dynamodb_mapping/dynamodb_mapping.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import mypy_boto3_dynamodb
1919
DynamoDBTable = mypy_boto3_dynamodb.service_resource.Table
2020
except ImportError:
21-
DynamoDBTable = Any # type: ignore
21+
DynamoDBTable = Any # type: ignore
2222

2323
DynamoDBKeyPrimitiveTypes = (str, bytes, bytearray, int, Decimal)
2424
"""DynamoDB primary key primitive choices."""
@@ -49,7 +49,7 @@
4949
"""DynamoDB value type choices."""
5050

5151
DynamoDBValue = Union[
52-
bytes, bytearray, str, int, Decimal,bool,
52+
bytes, bytearray, str, int, Decimal, bool,
5353
Set[int], Set[Decimal], Set[str], Set[bytes], Set[bytearray],
5454
Sequence[Any], Mapping[str, Any], None,
5555
]
@@ -60,6 +60,7 @@
6060

6161
logger = logging.getLogger(__name__)
6262

63+
6364
def _boto3_session_from_config(config: Dict[str, Any]) -> Optional[boto3.Session]:
6465
if "aws_access_key_id" in config and "aws_secret_access_key" in config:
6566
return boto3.Session(
@@ -71,6 +72,7 @@ def _boto3_session_from_config(config: Dict[str, Any]) -> Optional[boto3.Session
7172
else:
7273
return None
7374

75+
7476
def get_key_names(table: DynamoDBTable) -> DynamoDBKeyName:
7577
"""Gets the key names of the DynamoDB table.
7678
@@ -121,6 +123,7 @@ def create_tuple_keys(key: DynamoDBKeySimplified) -> DynamoDBKeyAny:
121123
else:
122124
return cast(DynamoDBKeySimple, (key,))
123125

126+
124127
def _log_keys_from_params(key_params: Dict[str, DynamoDBKeyPrimitive]) -> str:
125128
log_keys = list(key_params.values())
126129
res = log_keys[0] if len(log_keys) == 1 else log_keys
@@ -194,7 +197,8 @@ class DynamoDBItemAccessor(dict):
194197
initial_data (Dict): The initial item data.
195198
"""
196199

197-
def __init__(self,
200+
def __init__(
201+
self,
198202
parent: "DynamoDBMapping",
199203
item_keys: DynamoDBKeySimplified,
200204
initial_data: DynamoDBItemType,
@@ -268,7 +272,8 @@ class DynamoDBMapping(MutableMapping):
268272
the values are one of the `permitted DynamoDB value types`_. The ``DynamoDBItemType`` type
269273
reflects the possible item types.
270274
271-
.. _permitted DynamoDB value types: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/dynamodb.html
275+
.. _permitted DynamoDB value types: \
276+
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/dynamodb.html
272277
273278
Args:
274279
table_name: The name of the DynamoDB table.
@@ -278,7 +283,7 @@ class DynamoDBMapping(MutableMapping):
278283
"""
279284

280285
def __init__(
281-
self, table_name: str, boto3_session: Optional[boto3.session.Session]=None, **kwargs
286+
self, table_name: str, boto3_session: Optional[boto3.session.Session] = None, **kwargs
282287
) -> None:
283288
session = (
284289
boto3_session or
@@ -294,7 +299,7 @@ def _create_key_param(self, keys: DynamoDBKeySimplified) -> Dict[str, DynamoDBKe
294299
tuple_keys = create_tuple_keys(keys)
295300
if len(tuple_keys) != len(self.key_names):
296301
raise ValueError(f"You must provide a value for each of {self.key_names} keys.")
297-
param = { name: value for name, value in zip(self.key_names, tuple_keys) }
302+
param = {name: value for name, value in zip(self.key_names, tuple_keys)}
298303
return param
299304

300305
def scan(self, **kwargs) -> Iterator[DynamoDBItemType]:
@@ -356,7 +361,7 @@ def get_item(self, keys: DynamoDBKeySimplified, **kwargs) -> DynamoDBItemAccesso
356361
key_params = self._create_key_param(keys)
357362
logger.debug("Performing a get_item operation on %s table", self.table.name)
358363
response = self.table.get_item(Key=key_params, **kwargs)
359-
if not "Item" in response:
364+
if "Item" not in response:
360365
raise KeyError(_log_keys_from_params(key_params))
361366
data = response["Item"]
362367
return DynamoDBItemAccessor(parent=self, item_keys=keys, initial_data=data)
@@ -404,12 +409,13 @@ def del_item(self, keys: DynamoDBKeySimplified, check_existing=True, **kwargs) -
404409
:meth:`~DynamoDBTable.delete_item` operation.
405410
"""
406411
key_params = self._create_key_param(keys)
407-
if check_existing and not keys in self.keys():
412+
if check_existing and keys not in self.keys():
408413
raise KeyError(_log_keys_from_params(key_params))
409414
logger.debug("Performing a delete_item operation on %s table", self.table.name)
410415
self.table.delete_item(Key=key_params, **kwargs)
411416

412-
def modify_item(self,
417+
def modify_item(
418+
self,
413419
keys: DynamoDBKeySimplified,
414420
modifications: DynamoDBItemType,
415421
**kwargs

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ universal = 1
1616

1717
[flake8]
1818
exclude = docs
19+
max-line-length = 100
20+
1921
[tool:pytest]
2022
collect_ignore = ['setup.py']

tests/test_dynamodb_mapping.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import pytest
66

77

8-
from dynamodb_mapping import dynamodb_mapping
8+
# from dynamodb_mapping import DynamoDBMapping
99

10+
# mapping = DynamoDBMapping("foobar")
1011

1112
@pytest.fixture
1213
def response():

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ deps =
2323
commands =
2424
pip install -U pip
2525
pytest --basetemp={envtmpdir}
26-

0 commit comments

Comments
 (0)