Skip to content

Commit c98937b

Browse files
authored
feat: add pre-commit hooks (#64)
* chore: pre-commit dep Signed-off-by: heitorlessa <[email protected]> * feat: add initial pre-commit config Signed-off-by: heitorlessa <[email protected]> * feat: additional type annotation, toml, merge, etc Signed-off-by: heitorlessa <[email protected]> * improv: speed up formatting Signed-off-by: heitorlessa <[email protected]> * fix: python version range Signed-off-by: heitorlessa <[email protected]> * chore: pre-commit checks * chore: update dev deps * feat: install pre-commit hooks during dev Signed-off-by: heitorlessa <[email protected]>
1 parent 993e8e5 commit c98937b

File tree

26 files changed

+180
-144
lines changed

26 files changed

+180
-144
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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# We use poetry to run formatting and linting before commit/push
2+
# Longers checks such as tests, security and complexity baseline
3+
# are run as part of CI to prevent slower feedback loop
4+
# All checks can be run locally via `make pr`
5+
6+
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
18+
- repo: local
19+
hooks:
20+
- id: black
21+
name: formatting::black
22+
entry: poetry run black
23+
language: system
24+
types: [python]
25+
- id: isort
26+
name: formatting::isort
27+
entry: poetry run isort -rc
28+
language: system
29+
types: [python]
30+
- repo: local
31+
hooks:
32+
- id: flake8
33+
name: linting::flake8
34+
entry: poetry run flake8
35+
language: system
36+
types: [python]
37+
exclude: example
38+
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-

Makefile

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

55
dev:
6-
pip install --upgrade pip poetry
6+
pip install --upgrade pip poetry pre-commit
77
poetry install
8+
pre-commit install
89

910
dev-docs:
1011
cd docs && npm install
1112

1213
format:
13-
poetry run isort -rc .
14-
poetry run black aws_lambda_powertools
15-
poetry run black tests
14+
poetry run isort -rc aws_lambda_powertools tests example
15+
poetry run black aws_lambda_powertools tests
1616

1717
lint: format
1818
poetry run flake8

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>

0 commit comments

Comments
 (0)