Skip to content

Commit f739138

Browse files
committed
feat(pyproject.toml): move to poetry
1 parent f8cf190 commit f739138

File tree

14 files changed

+1131
-155
lines changed

14 files changed

+1131
-155
lines changed

python/.bumpversion.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[bumpversion]
2+
current_version = 0.5.0
3+
commit = False
4+
tag = True
5+
6+
[bumpversion:file:pyproject.toml]
7+
8+
[bumpversion:file:aws_lambda_powertools/__init__.py]
9+
search = __version__ = '{current_version}'
10+
replace = __version__ = '{new_version}'

python/.coveragerc

Lines changed: 0 additions & 25 deletions
This file was deleted.

python/.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[flake8]
2+
exclude = docs, .eggs, setup.py
3+
ignore = E203, E266, W503, BLK100, W291
4+
max-line-length = 120
5+
max-complexity = 18
6+
7+
[isort]
8+
multi_line_output = 3
9+
include_trailing_comma = true
10+
force_grid_wrap = 0
11+
use_parentheses = true
12+
line_length = 120

python/.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python.pythonPath": "/Users/lessa/.pyenv/aws-lambda-powertools-_w3KY4aG-py3.7/bin/python",
3+
"python.formatting.provider": "black"
4+
}

python/Makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,31 @@ target:
33
@$(MAKE) pr
44

55
dev:
6-
pip install --upgrade pipenv
7-
pipenv install
8-
pipenv install -d
6+
pip install --upgrade poetry
7+
poetry install
98

109
format:
11-
pipenv run isort -rc .
12-
pipenv run black aws_lambda_powertools
13-
pipenv run black tests
10+
poetry run isort -rc .
11+
poetry run black aws_lambda_powertools
12+
poetry run black tests
1413

1514
lint: format
16-
pipenv run flake8
15+
poetry run flake8
1716

1817
test:
19-
pipenv run pytest
18+
poetry run pytest
2019

2120
test-html:
22-
pipenv run pytest --cov-report html
21+
poetry run pytest --cov-report html
2322

2423
pr: lint test
2524

2625
release: pr
2726
python setup.py sdist bdist_wheel
28-
pipenv run twine upload dist/* --verbose
27+
poetry run twine upload dist/* --verbose
2928
rm -rf dist build
3029

3130
release-test: pr
3231
python setup.py sdist bdist_wheel
33-
pipenv run twine upload --repository testpypi dist/* --verbose
32+
poetry run twine upload --repository testpypi dist/* --verbose
3433
rm -rf dist build

python/aws_lambda_powertools/helper/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ def build_metric_unit_from_str(unit: Union[str, MetricUnit]) -> MetricUnit:
127127
metric_unit = MetricUnit[unit]
128128
except (TypeError, KeyError):
129129
metric_units = [units for units, _ in MetricUnit.__members__.items()]
130-
raise ValueError(
131-
f"Invalid Metric Unit - Received {unit}. Value Metric Units are {metric_units}"
132-
)
130+
raise ValueError(f"Invalid Metric Unit - Received {unit}. Value Metric Units are {metric_units}")
133131

134132
return metric_unit

python/aws_lambda_powertools/logging/logger.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
is_cold_start = True
1616

1717

18-
def logger_setup(
19-
service: str = "service_undefined", level: str = "INFO", sampling_rate: float = 0.0, **kwargs
20-
):
18+
def logger_setup(service: str = "service_undefined", level: str = "INFO", sampling_rate: float = 0.0, **kwargs):
2119
"""Setups root logger to format statements in JSON.
2220
2321
Includes service name and any additional key=value into logs
@@ -70,24 +68,20 @@ def logger_setup(
7068
try:
7169
if sampling_rate and random.random() <= float(sampling_rate):
7270
log_level = logging.DEBUG
73-
except ValueError:
71+
except ValueError:
7472
raise ValueError(
75-
f"Expected a float value ranging 0 to 1, but received {sampling_rate} instead. Please review POWERTOOLS_LOGGER_SAMPLE_RATE environment variable."
73+
"fExpected a float value ranging 0 to 1, but received {sampling_rate} instead. Please review POWERTOOLS_LOGGER_SAMPLE_RATE environment variable."
7674
)
7775

7876
logger.setLevel(log_level)
7977

8078
# Patch logger by structuring its outputs as JSON
81-
aws_lambda_logging.setup(
82-
level=log_level, service=service, sampling_rate=sampling_rate, **kwargs
83-
)
79+
aws_lambda_logging.setup(level=log_level, service=service, sampling_rate=sampling_rate, **kwargs)
8480

8581
return logger
8682

8783

88-
def logger_inject_lambda_context(
89-
lambda_handler: Callable[[Dict, Any], Any] = None, log_event: bool = False
90-
):
84+
def logger_inject_lambda_context(lambda_handler: Callable[[Dict, Any], Any] = None, log_event: bool = False):
9185
"""Decorator to capture Lambda contextual info and inject into struct logging
9286
9387
Parameters
@@ -179,12 +173,7 @@ def __is_cold_start() -> str:
179173

180174

181175
def log_metric(
182-
name: str,
183-
namespace: str,
184-
unit: MetricUnit,
185-
value: float = 0,
186-
service: str = "service_undefined",
187-
**dimensions,
176+
name: str, namespace: str, unit: MetricUnit, value: float = 0, service: str = "service_undefined", **dimensions,
188177
):
189178
"""Logs a custom metric in a statsD-esque format to stdout.
190179
@@ -248,9 +237,7 @@ def log_metric(
248237
keyword arguments as additional dimensions (e.g. customer=customerId)
249238
"""
250239

251-
logger.debug(
252-
f"Building new custom metric. Name: {name}, Unit: {unit}, Value: {value}, Dimensions: {dimensions}"
253-
)
240+
logger.debug(f"Building new custom metric. Name: {name}, Unit: {unit}, Value: {value}, Dimensions: {dimensions}")
254241
service = os.getenv("POWERTOOLS_SERVICE_NAME") or service
255242
dimensions = __build_dimensions(**dimensions)
256243
unit = build_metric_unit_from_str(unit)
@@ -283,9 +270,7 @@ def __build_dimensions(**dimensions) -> str:
283270
# so we take up to 9 values as additional dimensions
284271
# before we convert everything to a string of key=value
285272
dimensions_partition = dict(itertools.islice(dimensions.items(), MAX_DIMENSIONS))
286-
dimensions_list = [
287-
dimension + "=" + value for dimension, value in dimensions_partition.items() if value
288-
]
273+
dimensions_list = [dimension + "=" + value for dimension, value in dimensions_partition.items() if value]
289274
dimension = ",".join(dimensions_list)
290275

291276
return dimension

python/aws_lambda_powertools/tracing/tracer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ class Tracer:
9696
"""
9797

9898
def __init__(
99-
self,
100-
service: str = "service_undefined",
101-
disabled: bool = False,
102-
provider: xray_recorder = xray_recorder,
99+
self, service: str = "service_undefined", disabled: bool = False, provider: xray_recorder = xray_recorder,
103100
):
104101
self.provider = provider
105102
self.disabled = self.__is_trace_disabled() or disabled

0 commit comments

Comments
 (0)