Skip to content

Commit

Permalink
Merge pull request #22 from hexfrost/feat/fix-linter
Browse files Browse the repository at this point in the history
Update max-length settings and reformat code
  • Loading branch information
kaziamov authored Mar 3, 2024
2 parents 06fe87f + e7577ea commit e2d8ba3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
extend-ignore = F401
max-line-length = 95
max-line-length = 120
exclude =
.git,
*/tests/*,
Expand Down
9 changes: 7 additions & 2 deletions simplecrud/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# READ / GET


async def get_object(model, filters: dict, conn: AsyncSession = None) -> object:
"""Get object from db"""
query = select(model).filter_by(**filters)
Expand Down Expand Up @@ -34,7 +35,9 @@ async def get_all_with_filter(model, filters: dict, conn: AsyncSession = None) -
return objects


async def get_objects(model, filters: Dict, limit: int = 10, offset: int = 10, conn: AsyncSession = None) -> List[object]:
async def get_objects(
model, filters: Dict, limit: int = 10, offset: int = 10, conn: AsyncSession = None
) -> List[object]:
"""Get objects from db"""
query = select(model).filter_by(**filters).limit(limit).offset(offset)
async with conn:
Expand All @@ -53,6 +56,7 @@ async def get_or_create_object(model, params: dict, conn: AsyncSession = None) -

# CREATE


async def create_object(model, params, conn: AsyncSession = None) -> object:
"""Create object in db"""
new_obj = model(**params)
Expand All @@ -69,6 +73,7 @@ async def bulk_create(model, data: List[Dict], conn: AsyncSession = None) -> Lis

# UPDATE


async def update_object(obj, params, conn: AsyncSession = None) -> object:
"""
Soft Update object in db.
Expand Down Expand Up @@ -104,7 +109,6 @@ async def update_object_by_id(model, id: int, params, conn: AsyncSession = None)
return updated_obj


#
# async def bulk_update(objects, params, conn: AsyncSession = None) -> List[object]:
# """Bulk update objects in db"""
# updated_objects = []
Expand All @@ -121,6 +125,7 @@ async def update_or_create_object(model, filters, params, conn: AsyncSession = N

# DELETE


async def delete_object(obj, conn: AsyncSession = None) -> bool:
model = obj.__class__
id_ = obj.id
Expand Down
1 change: 0 additions & 1 deletion simplecrud/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from functools import wraps



def async_to_sync(func):
"""Decorator to convert async function to sync"""

Expand Down

0 comments on commit e2d8ba3

Please sign in to comment.