Skip to content

Commit

Permalink
fix some smells
Browse files Browse the repository at this point in the history
  • Loading branch information
collerek committed Sep 14, 2020
1 parent ccca6ec commit 5a8fd74
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Binary file modified .coverage
Binary file not shown.
3 changes: 1 addition & 2 deletions ormar/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def default_value(cls) -> Optional[Field]:
default = cls.default if cls.default is not None else cls.server_default
if callable(default):
return Field(default_factory=default)
else:
return Field(default=default)
return Field(default=default)
return None

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions ormar/models/newbasemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def __setattr__(self, name: str, value: Any) -> None: # noqa CCR001
def __getattribute__(self, item: str) -> Any:
if item in ("_orm_id", "_orm_saved", "_orm", "__fields__"):
return object.__getattribute__(self, item)
elif item != "_extract_related_names" and item in self._extract_related_names():
if item != "_extract_related_names" and item in self._extract_related_names():
return self._extract_related_model_instead_of_field(item)
elif item == "pk":
if item == "pk":
return self.__dict__.get(self.Meta.pkname, None)
elif item != "__fields__" and item in self.__fields__:
if item != "__fields__" and item in self.__fields__:
value = self.__dict__.get(item, None)
value = self._convert_json(item, value, "loads")
return value
Expand Down
8 changes: 4 additions & 4 deletions ormar/queryset/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ async def first(self, **kwargs: Any) -> "Model":
async def get(self, **kwargs: Any) -> "Model":
if kwargs:
return await self.filter(**kwargs).get()

if not self.filter_clauses:
expr = self.build_select_expression().limit(2)
else:
if not self.filter_clauses:
expr = self.build_select_expression().limit(2)
else:
expr = self.build_select_expression()
expr = self.build_select_expression()

rows = await self.database.fetch_all(expr)

Expand Down

0 comments on commit 5a8fd74

Please sign in to comment.