Skip to content

Commit 6bc5388

Browse files
authored
Add pre-commit hooks (#27)
* pre-commit hooks * Add precommit hooks
1 parent beee230 commit 6bc5388

File tree

13 files changed

+168
-5
lines changed

13 files changed

+168
-5
lines changed

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.11.13
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [--fix]
9+
- id: ruff-format
10+
11+
- repo: https://github.com/pre-commit/mirrors-mypy
12+
rev: v1.16.0
13+
hooks:
14+
- id: mypy
15+
args:
16+
[
17+
--config-file=mypy.ini,
18+
--ignore-missing-imports,
19+
--show-traceback,
20+
--disable-error-code=import-untyped,
21+
--disable-error-code=no-untyped-call,
22+
]
23+
additional_dependencies: [
24+
"pydantic>=2.0",
25+
"pydantic-core>=2.16.3",
26+
"typing-extensions>=4.9.0",
27+
] # Needed for pre-commit's isolated environment
28+
files: ^packages/(?!.*tests/).+\.py$
29+
30+
- repo: https://github.com/Lucas-C/pre-commit-hooks
31+
rev: v1.5.5
32+
hooks:
33+
- id: insert-license
34+
name: "Insert license header in python source files"
35+
args: [--license-filepath=PAGE_HEADER.txt,
36+
'--comment-style=',
37+
--detect-license-in-X-top-lines=4]
38+
types: [python]

PAGE_HEADER.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
1515
- Windows: `.venv\Scripts\Activate`
1616

1717
> **Note:** After the initial setup, you need to activate the virtual environment each time you start a new terminal session
18+
19+
3. Install pre-commit hooks: `pre-commit install`

mypy.ini

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@ no_implicit_optional = true
99
check_untyped_defs = true
1010
warn_return_any = true
1111
show_error_codes = true
12-
warn_unused_ignores = false
13-
14-
disallow_incomplete_defs = true
15-
disallow_untyped_decorators = true
16-
disallow_any_unimported = true
12+
warn_unused_ignores = false
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""
5+
6+
17
def hello() -> str:
28
return "Hello from cards!"

packages/common/src/common/http/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""
5+
16
from .client import Client, ClientOptions
27
from .client_token import Token, TokenFactory
38
from .interceptor import Interceptor, InterceptorRequestContext, InterceptorResponseContext

packages/common/src/common/http/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""
5+
16
import inspect
27
import logging
38
from dataclasses import dataclass, field

packages/common/src/common/http/client_token.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""
5+
16
import inspect
27
from typing import Awaitable, Callable, Optional, Protocol, Union, runtime_checkable
38

packages/common/src/common/http/interceptor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""
5+
16
import logging
27
from typing import Any, Awaitable, Callable, TypeVar, Union
38

packages/common/tests/test_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
"""
5+
16
import httpx
27
import pytest
38
from common.http.client import Client, ClientOptions

0 commit comments

Comments
 (0)