Skip to content

Commit a9868bc

Browse files
committed
using pre-commit
1 parent 67012ec commit a9868bc

File tree

5 files changed

+228
-7
lines changed

5 files changed

+228
-7
lines changed

Diff for: .pre-commit-config.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: local
5+
hooks:
6+
- id: black
7+
name: black
8+
description: "Black: The uncompromising Python code formatter"
9+
entry: black
10+
language: python
11+
require_serial: true
12+
types_or: [python, pyi]
13+
- id: flake8
14+
name: flake8
15+
description: '`flake8` is a command-line utility for enforcing style consistency across Python projects.'
16+
entry: flake8
17+
language: python
18+
types: [python]
19+
require_serial: true
20+
- id: mypy
21+
name: mypy
22+
description: 'Mypy is a static type checker for Python 3'
23+
entry: mypy
24+
language: python
25+
types: [python]
26+
require_serial: true

Diff for: poetry.lock

+183-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ mypy = "^0.910"
3737
tortoise-orm = "^0.17.4"
3838
pydantic = "^1.8.2"
3939
coverage = "^6.2"
40+
pre-commit = "^2.16.0"
4041

4142
[build-system]
4243
requires = ["poetry_core>=1.0.0"]

Diff for: tests/test_automapper.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def __init__(self, num: int, text: str, flag: bool) -> None:
2222

2323
@classmethod
2424
def fields(cls) -> Iterable[str]:
25-
return (field for field in cls.__init__.__annotations__.keys() if field != "return")
25+
return (
26+
field for field in cls.__init__.__annotations__.keys() if field != "return"
27+
)
2628

2729

2830
class AnotherClass:
@@ -68,12 +70,16 @@ def setUp(self):
6870
def test_add_spec__adds_to_internal_collection(self):
6971
self.mapper.add_spec(ParentClass, custom_spec_func)
7072
assert ParentClass in self.mapper._class_specs
71-
assert ["num", "text", "flag"] == self.mapper._class_specs[ParentClass](ChildClass)
73+
assert ["num", "text", "flag"] == self.mapper._class_specs[ParentClass](
74+
ChildClass
75+
)
7276

7377
def test_add_spec__error_on_adding_same_class_spec(self):
7478
self.mapper.add_spec(ParentClass, custom_spec_func)
7579
with pytest.raises(DuplicatedRegistrationError):
76-
self.mapper.add_spec(ParentClass, lambda concrete_type: ["field1", "field2"])
80+
self.mapper.add_spec(
81+
ParentClass, lambda concrete_type: ["field1", "field2"]
82+
)
7783

7884
def test_add_spec__adds_to_internal_collection_for_classifier(self):
7985
self.mapper.add_spec(classifier_func, spec_func)
@@ -85,7 +91,9 @@ def test_add_spec__adds_to_internal_collection_for_classifier(self):
8591
def test_add_spec__error_on_duplicated_registration(self):
8692
self.mapper.add_spec(classifier_func, spec_func)
8793
with pytest.raises(DuplicatedRegistrationError):
88-
self.mapper.add_spec(classifier_func, lambda concrete_type: ["field1", "field2"])
94+
self.mapper.add_spec(
95+
classifier_func, lambda concrete_type: ["field1", "field2"]
96+
)
8997

9098
def test_add__appends_class_to_class_mapping(self):
9199
with pytest.raises(MappingError):

0 commit comments

Comments
 (0)