Skip to content

Commit 23467a9

Browse files
committed
feat: add pre commit config and fix issues
1 parent e1eb507 commit 23467a9

9 files changed

Lines changed: 42 additions & 9 deletions

File tree

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
10+
args:
11+
- --unsafe
12+
- id: end-of-file-fixer
13+
files: tortoise/
14+
- id: trailing-whitespace
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: 'v0.15.9'
17+
hooks:
18+
- id: ruff
19+
args: [--fix, --exit-non-zero-on-fix, --show-fixes, tortoise/, examples/, tests/, conftest.py]
20+
pass_filenames: false
21+
- id: ruff-format
22+
args: [tortoise/, examples/, tests/, conftest.py]
23+
pass_filenames: false
24+
25+
- repo: https://github.com/codespell-project/codespell
26+
rev: v2.4.2
27+
hooks:
28+
- id: codespell # See pyproject.toml for args
29+
additional_dependencies:
30+
- tomli

CHANGELOG.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ Removals:
10491049

10501050
0.15.15
10511051
-------
1052-
- Add ability to suppply a ``to_field=`` parameter for FK/O2O to a non-PK but still uniquely indexed remote field. (#287)
1052+
- Add ability to supply a ``to_field=`` parameter for FK/O2O to a non-PK but still uniquely indexed remote field. (#287)
10531053

10541054
0.15.14
10551055
-------
@@ -1600,7 +1600,7 @@ Docs/examples:
16001600

16011601
0.10.9
16021602
------
1603-
- Uses macros on SQLite driver to minimise syncronisation. ``aiosqlite>=0.7.0``
1603+
- Uses macros on SQLite driver to minimise synchronisation. ``aiosqlite>=0.7.0``
16041604
- Uses prepared statements for insert, large insert performance increase.
16051605
- Pre-generate base pypika query object per model, providing general purpose speedup.
16061606

@@ -1720,7 +1720,7 @@ Docs/examples:
17201720
17211721
- Fixed ``DatetimeField`` and ``DateField`` to work as expected on SQLite.
17221722
- Added ``PyLint`` plugin.
1723-
- Added test class to mange DB state for testing isolation.
1723+
- Added test class to manage DB state for testing isolation.
17241724

17251725
0.8.0
17261726
-----

docs/query.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ You could do it using ``.prefetch_related()``:
122122
# This will fetch tournament with their events and teams for each event
123123
tournament_list = await Tournament.all().prefetch_related('events__participants')
124124
125-
# Fetched result for m2m and backward fk relations are stored in list-like containe#r
125+
# Fetched result for m2m and backward fk relations are stored in list-like container
126126
for tournament in tournament_list:
127127
print([e.name for e in tournament.events])
128128

examples/comprehensive_migrations_project/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Comprehensive Migrations Project
33
===================================
44

55
This example demonstrates Tortoise ORM's complete migration system through a realistic ERP schema that evolves
6-
through 14 migrations. It covers all field types, migration operations (CreateModel, AddField, AlterField,
6+
through 14 migrations. It covers all field types, migration operations (CreateModel, AddField, AlterField,
77
RemoveField, RenameField, RunPython, RunSQL, indexes, constraints), and fully reversible migrations.
88

99
Usage

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,6 @@ exclude_dirs = [
236236
"examples/postgres_full_text_search.py",
237237
"examples/postgres.py",
238238
]
239+
240+
[tool.codespell]
241+
ignore-words-list = "notin,NotIn,brin,BRIN,astroid"

tests/fields/type_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TypeTestModel(Model):
9292
char_enum_field_non_null = CharEnumField(enum_type=Color, max_length=10, null=False)
9393
char_enum_field_nullable = CharEnumField(enum_type=Color, max_length=10, null=True)
9494

95-
# inhereted fields
95+
# inherited fields
9696
inhereted_int_field_non_null = InheretedFromIntField(null=False)
9797
inhereted_int_field_nullable = InheretedFromIntField(null=True)
9898

tests/test_model_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ async def test_update_or_create_with_defaults(tournament_model):
266266
assert created is False
267267
assert defaults["desc"] == updated_mdl.desc
268268
assert mdl.desc != updated_mdl.desc
269-
# Hint query: use defauts to update without checking conflict
269+
# Hint query: use defaults to update without checking conflict
270270
mdl2, created = await Tournament.update_or_create(
271271
id=oldid, desc=desc, defaults=dict(mdl_dict, desc="new desc")
272272
)

tortoise/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ def __iter__(self) -> Iterable[tuple]:
873873
yield field, getattr(self, field)
874874

875875
def __eq__(self, other: object) -> bool:
876-
return type(other) is type(self) and self.pk == other.pk # type: ignore
876+
return type(other) is type(self) and self.pk == other.pk
877877

878878
def _get_pk_val(self) -> Any:
879879
return getattr(self, self._meta.pk_attr, None)

tortoise/queryset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ def _resolve_only(self, only_lookup_expressions: tuple[str, ...]) -> None:
11111111
fetch_to_fields = defaultdict(list)
11121112
# the order is important here, we need to process the shallowest fields first
11131113
# because we want to populate _select_related_idx with actual items that need to be
1114-
# selected, not "filler" items tha just tell the executor that an empty instance has
1114+
# selected, not "filler" items than just tell the executor that an empty instance has
11151115
# to be created
11161116
for expression in sorted(only_lookup_expressions, key=lambda x: x.count("__")):
11171117
fetch_fields_lookup, __, field_name = expression.rpartition("__")

0 commit comments

Comments
 (0)