diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 4ffe0c5..df50003 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -69,5 +69,6 @@ jobs: uses: codecov/codecov-action@v1 - name: Test & publish code coverage uses: paambaati/codeclimate-action@v2.7.5 + if: github.event.pull_request.head.repo.full_name == 'collerek/ormar' env: CC_TEST_REPORTER_ID: ${{ secrets.CC_COVERAGE_TOKEN }} diff --git a/docs/releases.md b/docs/releases.md index ae63e5e..192c932 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -1,3 +1,11 @@ +# 0.10.5 + +## 🐛 Fixes + +* Fix bug in `fastapi-pagination` [#73](https://github.com/uriyyo/fastapi-pagination/issues/73) +* Remove unnecessary `Optional` in `List[Optional[T]]` in return value for `QuerySet.all()` and `Querysetproxy.all()` return values [#174](https://github.com/collerek/ormar/issues/174) +* Run tests coverage publish only on internal prs instead of all in github action. + # 0.10.4 ## ✨ Features diff --git a/ormar/__init__.py b/ormar/__init__.py index a57b83f..8b4f371 100644 --- a/ormar/__init__.py +++ b/ormar/__init__.py @@ -75,7 +75,7 @@ class UndefinedType: # pragma no cover Undefined = UndefinedType() -__version__ = "0.10.4" +__version__ = "0.10.5" __all__ = [ "Integer", "BigInteger", diff --git a/ormar/models/newbasemodel.py b/ormar/models/newbasemodel.py index 4e16fd0..772fd4b 100644 --- a/ormar/models/newbasemodel.py +++ b/ormar/models/newbasemodel.py @@ -697,7 +697,7 @@ class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass if relation_map is not None else translate_list_to_dict(self._iterate_related_models()) ) - pk_only = object.__getattribute__(self, "__pk_only__") + pk_only = getattr(self, "__pk_only__", False) if relation_map and not pk_only: dict_instance = self._extract_nested_models( relation_map=relation_map, diff --git a/ormar/models/quick_access_views.py b/ormar/models/quick_access_views.py index 0dfc835..89cbf08 100644 --- a/ormar/models/quick_access_views.py +++ b/ormar/models/quick_access_views.py @@ -12,6 +12,7 @@ quick_access_set = { "__fields__", "__fields_set__", "__json_encoder__", + "__pk_only__", "__post_root_validators__", "__pre_root_validators__", "__private_attributes__", diff --git a/ormar/queryset/queryset.py b/ormar/queryset/queryset.py index 3cf4211..68ac84c 100644 --- a/ormar/queryset/queryset.py +++ b/ormar/queryset/queryset.py @@ -137,8 +137,8 @@ class QuerySet(Generic[T]): ) async def _prefetch_related_models( - self, models: List[Optional["T"]], rows: List - ) -> List[Optional["T"]]: + self, models: List["T"], rows: List + ) -> List["T"]: """ Performs prefetch query for selected models names. @@ -158,7 +158,7 @@ class QuerySet(Generic[T]): ) return await query.prefetch_related(models=models, rows=rows) # type: ignore - def _process_query_result_rows(self, rows: List) -> List[Optional["T"]]: + def _process_query_result_rows(self, rows: List) -> List["T"]: """ Process database rows and initialize ormar Model from each of the rows. @@ -179,7 +179,7 @@ class QuerySet(Generic[T]): ] if result_rows: return self.model.merge_instances_list(result_rows) # type: ignore - return cast(List[Optional["T"]], result_rows) + return cast(List["T"], result_rows) def _resolve_filter_groups( self, groups: Any @@ -884,7 +884,7 @@ class QuerySet(Generic[T]): model = await self.get(pk=kwargs[pk_name]) return await model.update(**kwargs) - async def all(self, *args: Any, **kwargs: Any) -> List[Optional["T"]]: # noqa: A003 + async def all(self, *args: Any, **kwargs: Any) -> List["T"]: # noqa: A003 """ Returns all rows from a database for given model for set filter options. diff --git a/ormar/relations/querysetproxy.py b/ormar/relations/querysetproxy.py index c6ae52d..f9a0806 100644 --- a/ormar/relations/querysetproxy.py +++ b/ormar/relations/querysetproxy.py @@ -342,7 +342,7 @@ class QuerysetProxy(Generic[T]): self._register_related(get) return get - async def all(self, *args: Any, **kwargs: Any) -> List[Optional["T"]]: # noqa: A003 + async def all(self, *args: Any, **kwargs: Any) -> List["T"]: # noqa: A003 """ Returns all rows from a database for given model for set filter options.