Skip to content

Commit

Permalink
chore: another ruff induces code cleanup
Browse files Browse the repository at this point in the history
We remove unused imports, fix a variable name, and remove a search
filter function that was not being used anymore
  • Loading branch information
b1rger committed Jan 17, 2024
1 parent b08bfb6 commit 2539f2b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 23 deletions.
4 changes: 2 additions & 2 deletions apis_core/apis_entities/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from django.core.validators import URLValidator
from django.urls import reverse

from apis_core.apis_metainfo.models import Uri, Collection
from apis_core.utils import DateParser, caching, settings as apis_settings
from apis_core.apis_metainfo.models import Uri
from apis_core.utils import caching, settings as apis_settings
from apis_core.utils.settings import get_entity_settings_by_modelname
from .fields import ListSelect2

Expand Down
5 changes: 0 additions & 5 deletions apis_core/apis_entities/models.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import re
import unicodedata

from django.contrib.contenttypes.models import ContentType
import reversion
from django.conf import settings
from django.contrib.auth.models import Group
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.urls import reverse
from model_utils.managers import InheritanceManager
from django.db.models.query import QuerySet

from apis_core.utils import caching
from apis_core.utils import DateParser
from apis_core.apis_metainfo.models import RootObject
from apis_core.apis_relations.models import TempTriple
from apis_core.apis_entities import signals
Expand Down
2 changes: 1 addition & 1 deletion apis_core/apis_metainfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def clean(self):
self.root_object = obj
else:
raise ImproperlyConfigured(
f"{uri}: found model <{model}> and attributes <{attributes}>"
f"{self.uri}: found model <{model}> and attributes <{attributes}>"
)
except Exception as e:
raise ValidationError(f"{e}: {self.uri}")
14 changes: 0 additions & 14 deletions apis_core/apis_relations/rel_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import operator
from functools import reduce

import django_filters
from dal import autocomplete
from django.conf import settings
Expand Down Expand Up @@ -93,8 +90,6 @@ def get_filters(model, exclude=False, include=False, include_parents=False):

def get_generic_relation_filter(entity):
class GenericListFilter(django_filters.FilterSet):
# search = django_filters.CharFilter(method='search_filter_method')

def name_label_filter(self, queryset, name, value):
"""
Filter for including the alternative names in the names search.\
Expand Down Expand Up @@ -156,15 +151,6 @@ def wildcard_filter(self, queryset, name, value):
f += "exact"
return queryset.filter(**{f: value})

def search_filter_method(self, queryset, name, value):
cls = queryset.model.__name__
sett_filters = getattr(settings, "APIS_RELATIONS", {})
if cls.lower() in sett_filters.keys():
filter_attr = sett_filters[cls.lower()].get("search", ["name"])
query = reduce(
operator.or_, [Q(**{attr: value}) for attr in filter_attr]
)

class Meta:
# model = AbstractRelation.get_relation_class_of_name(entity)
model = None
Expand Down
1 change: 0 additions & 1 deletion apis_core/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import inspect
import itertools
import logging
from typing import Type


from apis_core.apis_relations.models import Property, TempTriple
Expand Down

0 comments on commit 2539f2b

Please sign in to comment.