remove reference to mypy.ini in github workflow, fix some code smells
This commit is contained in:
2
.github/workflows/test-package.yml
vendored
2
.github/workflows/test-package.yml
vendored
@ -66,7 +66,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DATABASE_URL: "sqlite:///testsuite"
|
DATABASE_URL: "sqlite:///testsuite"
|
||||||
run: bash scripts/test.sh
|
run: bash scripts/test.sh
|
||||||
- run: mypy --config-file mypy.ini ormar tests
|
- run: mypy ormar tests
|
||||||
- name: Upload coverage
|
- name: Upload coverage
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
- name: Test & publish code coverage
|
- name: Test & publish code coverage
|
||||||
|
|||||||
@ -30,11 +30,11 @@ def sort_models(models: List["Model"], orders_by: Dict) -> List["Model"]:
|
|||||||
]
|
]
|
||||||
sort_criteria = sort_criteria[::-1]
|
sort_criteria = sort_criteria[::-1]
|
||||||
for criteria in sort_criteria:
|
for criteria in sort_criteria:
|
||||||
key, value = criteria
|
key_name, value = criteria
|
||||||
if value == "desc":
|
if value == "desc":
|
||||||
models.sort(key=lambda x: getattr(x, key), reverse=True)
|
models.sort(key=lambda x: getattr(x, key_name), reverse=True)
|
||||||
else:
|
else:
|
||||||
models.sort(key=lambda x: getattr(x, key))
|
models.sort(key=lambda x: getattr(x, key_name))
|
||||||
return models
|
return models
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -214,7 +214,8 @@ def extract_nested_models( # noqa: CCR001
|
|||||||
follow = [rel for rel in model_type.extract_related_names() if rel in select_dict]
|
follow = [rel for rel in model_type.extract_related_names() if rel in select_dict]
|
||||||
for related in follow:
|
for related in follow:
|
||||||
child = getattr(model, related)
|
child = getattr(model, related)
|
||||||
if child:
|
if not child:
|
||||||
|
continue
|
||||||
target_model = model_type.Meta.model_fields[related].to
|
target_model = model_type.Meta.model_fields[related].to
|
||||||
if isinstance(child, list):
|
if isinstance(child, list):
|
||||||
extracted.setdefault(target_model.get_name(), []).extend(child)
|
extracted.setdefault(target_model.get_name(), []).extend(child)
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class QuerysetProxy(Generic[T]):
|
|||||||
type_: "RelationType",
|
type_: "RelationType",
|
||||||
qryset: "QuerySet[T]" = None,
|
qryset: "QuerySet[T]" = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.relation: Relation = relation
|
self.relation: "Relation" = relation
|
||||||
self._queryset: Optional["QuerySet[T]"] = qryset
|
self._queryset: Optional["QuerySet[T]"] = qryset
|
||||||
self.type_: "RelationType" = type_
|
self.type_: "RelationType" = type_
|
||||||
self._owner: Union[CallableProxyType, "Model"] = self.relation.manager.owner
|
self._owner: Union[CallableProxyType, "Model"] = self.relation.manager.owner
|
||||||
|
|||||||
Reference in New Issue
Block a user