Skip to content

Commit a7d078c

Browse files
committed
feat: additional type annotation, toml, merge, etc
Signed-off-by: heitorlessa <[email protected]>
1 parent 9aef996 commit a7d078c

File tree

23 files changed

+52
-42
lines changed

23 files changed

+52
-42
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ assignees: ''
3636

3737
* **Powertools version used**:
3838
* **Packaging format (Layers, PyPi)**:
39-
* **AWS Lambda function runtime:**
39+
* **AWS Lambda function runtime:**
4040
* **Debugging logs**
4141

4242
> [How to enable debug mode](https://awslabs.github.io/aws-lambda-powertools-python/#debug-mode)**

.github/ISSUE_TEMPLATE/rfc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ assignees: ''
1010
## Key information
1111

1212
* RFC PR: (leave this empty)
13-
* Related issue(s), if known:
13+
* Related issue(s), if known:
1414
* Area: (i.e. Tracer, Metrics, Logger, etc.)
1515
* Meet [tenets](https://awslabs.github.io/aws-lambda-powertools-python/#tenets): (Yes/no)
1616

.pre-commit-config.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
# All checks can be run locally via `make pr`
55

66
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v2.4.0
9+
hooks:
10+
- id: check-merge-conflict
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- id: check-toml
14+
- repo: https://github.com/pre-commit/pygrep-hooks
15+
rev: v1.5.1
16+
hooks:
17+
- id: python-use-type-annotations
718
- repo: local
819
hooks:
920
- id: black
@@ -23,5 +34,5 @@ repos:
2334
entry: poetry run flake8
2435
language: system
2536
types: [python]
26-
exclude: example
37+
exclude: example
2738
fail_fast: true

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Changelog
1+
# Changelog
22
All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1212
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1313
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1414
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15-

aws_lambda_powertools/metrics/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@
111111
}
112112
}
113113
}
114-
}
114+
}

aws_lambda_powertools/middleware_factory/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def lambda_handler_decorator(decorator: Callable = None, trace_execution=False):
2727
Environment variables
2828
---------------------
2929
POWERTOOLS_TRACE_MIDDLEWARES : str
30-
uses `aws_lambda_powertools.tracing.Tracer`
30+
uses `aws_lambda_powertools.tracing.Tracer`
3131
to create sub-segments per middleware (e.g. `"true", "True", "TRUE"`)
3232
3333
Parameters

bandit.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,4 @@
223223
"test_name": "blacklist"
224224
}
225225
]
226-
}
226+
}

docs/content/core/logger.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can also explicitly set a service name via `service` param or via `POWERTOOL
3939
```python:title=app.py
4040
from aws_lambda_powertools.logging import Logger
4141
# POWERTOOLS_SERVICE_NAME defined
42-
logger = Logger() # highlight-line
42+
logger = Logger() # highlight-line
4343

4444
# Explicit definition
4545
Logger(service="payment", level="INFO")
@@ -58,7 +58,7 @@ Key | Type | Example | Description
5858
**sampling_rate** | int | 0.1 | Debug logging sampling rate in percentage e.g. 1% in this case
5959
**message** | any | "Collecting payment" | Log statement value. Unserializable JSON values will be casted to string
6060

61-
## Capturing context Lambda info
61+
## Capturing context Lambda info
6262

6363
You can enrich your structured logs with key Lambda context information via `inject_lambda_context`.
6464

@@ -109,7 +109,7 @@ Key | Type | Example
109109
<summary><strong>Exerpt output in CloudWatch Logs</strong></summary>
110110

111111
```json:title=cloudwatch_logs.json
112-
{
112+
{
113113
"timestamp":"2020-05-24 18:17:33,774",
114114
"level":"INFO",
115115
"location":"collect.handler:1",
@@ -125,7 +125,7 @@ Key | Type | Example
125125
"message": "Collecting payment"
126126
}
127127

128-
{
128+
{
129129
"timestamp":"2020-05-24 18:17:33,774",
130130
"level":"INFO",
131131
"location":"collect.handler:15",
@@ -137,7 +137,7 @@ Key | Type | Example
137137
"cold_start": true,
138138
"sampling_rate": 0.0,
139139
// highlight-start
140-
"message":{
140+
"message":{
141141
"operation":"collect_payment",
142142
"charge_id": "ch_AZFlk2345C0"
143143
}
@@ -148,7 +148,7 @@ Key | Type | Example
148148

149149
## Appending additional keys
150150

151-
You can append your own keys to your existing Logger via `structure_logs` with **append** param.
151+
You can append your own keys to your existing Logger via `structure_logs` with **append** param.
152152

153153
```python:title=collect.py
154154
from aws_lambda_powertools.logging import Logger
@@ -166,7 +166,7 @@ def handler(event, context)
166166
<summary><strong>Exerpt output in CloudWatch Logs</strong></summary>
167167

168168
```json:title=cloudwatch_logs.jsonn
169-
{
169+
{
170170
"timestamp": "2020-05-24 18:17:33,774",
171171
"level": "INFO",
172172
"location": "collect.handler:1",
@@ -209,7 +209,7 @@ def handler(event, context)
209209
<summary><strong>Exerpt output in CloudWatch Logs</strong></summary>
210210

211211
```json:title=cloudwatch_logs.json
212-
{
212+
{
213213
"timestamp": "2020-05-24 18:17:33,774",
214214
"level": "INFO",
215215
"location": "collect.handler:1",
@@ -223,4 +223,4 @@ def handler(event, context)
223223
"message": "Collecting payment"
224224
}
225225
```
226-
</details>
226+
</details>

docs/content/core/metrics.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ You can explicitly set a namespace name via `service` param or via `POWERTOOLS_S
3737
from aws_lambda_powertools.metrics import Metrics, MetricUnit
3838

3939
# POWERTOOLS_SERVICE_NAME defined
40-
metrics = Metrics() # highlight-line
40+
metrics = Metrics() # highlight-line
4141

4242
# Explicit definition
4343
Metrics(service="ServerlessAirline") # sets namespace to "ServerlessAirline"
@@ -67,7 +67,7 @@ CloudWatch EMF supports a max of 100 metrics. Metrics will automatically flush a
6767

6868
## Creating a metric with a different dimension
6969

70-
CloudWatch EMF uses the same dimensions across all your metrics. Use `single_metric` if you have a metric that should have different dimensions.
70+
CloudWatch EMF uses the same dimensions across all your metrics. Use `single_metric` if you have a metric that should have different dimensions.
7171

7272
<Note type="info">
7373
Generally, this would be an edge case since you <a href="https://aws.amazon.com/cloudwatch/pricing/">pay for unique metric</a>. Keep the following formula in mind:
@@ -103,7 +103,7 @@ def lambda_handler(evt, ctx):
103103

104104
`log_metrics` decorator **validates**, **serializes**, and **flushes** all your metrics. During metrics validation, if any of the following criteria is met, `SchemaValidationError` exception will be raised:
105105

106-
* At least of one Metric and Dimension
106+
* At least of one Metric and Dimension
107107
* Maximum of 9 dimensions
108108
* Namespace is set, and no more than one
109109
* Metric units must be [supported by CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html)
@@ -141,7 +141,7 @@ metrics.add_metric(name="ColdStart", unit="Count", value=1)
141141
metrics.add_dimension(name="service", value="booking")
142142

143143
# highlight-start
144-
your_metrics_object = metrics.serialize_metric_set()
144+
your_metrics_object = metrics.serialize_metric_set()
145145
metrics.clear_metrics()
146146
print(json.dumps(your_metrics_object))
147147
# highlight-end

0 commit comments

Comments
 (0)