Skip to content

Commit

Permalink
added None as default argument for exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
PrasanthChettri committed May 18, 2021
1 parent c911c81 commit c8f6057
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions sqlalchemy_mixins/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SerializeMixin(InspectionMixin):

__abstract__ = True

def to_dict(self,nested =False, hybrid_attributes=False, exclude = []):
def to_dict(self,nested = False, hybrid_attributes = False, exclude = None):
"""Return dict object with model's data.
:param nested: flag to return nested relationships' data if true
Expand All @@ -18,10 +18,10 @@ def to_dict(self,nested =False, hybrid_attributes=False, exclude = []):
"""
result = dict()

if len(exclude) != 0 :
view_cols = filter(lambda e: e not in exclude, self.columns)
else :
if exclude is None:
view_cols = self.columns
else :
view_cols = filter(lambda e: e not in exclude, self.columns)

for key in view_cols :
result[key] = getattr(self, key)
Expand Down
4 changes: 2 additions & 2 deletions sqlalchemy_mixins/serialize.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sqlalchemy_mixins.inspection import InspectionMixin

from typing import Optional , List

class SerializeMixin(InspectionMixin):

def to_dict(self, nested: bool = False, hybrid_attributes: bool = False) -> dict: ...
def to_dict(self, nested: bool = False, hybrid_attributes: bool = False, exclude: Optional[List[str]] = None) -> dict: ...

0 comments on commit c8f6057

Please sign in to comment.