From 67d43ca75eb0d08ee3885ff0d32e14cdfa8807d2 Mon Sep 17 00:00:00 2001 From: cocorocho Date: Tue, 9 Jan 2024 18:16:19 -0300 Subject: [PATCH] fix typos, annotations. cleanup --- import_export/forms.py | 7 ++----- import_export/mixins.py | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/import_export/forms.py b/import_export/forms.py index 7ff145a49..f1e0532cc 100644 --- a/import_export/forms.py +++ b/import_export/forms.py @@ -141,7 +141,7 @@ def _create_boolean_fields(self, resource: ModelResource) -> None: def create_boolean_field_name(resource: ModelResource, field_name: str) -> str: """ Create field name by combining `resource_name` + `field_name` to prevent - confliction between resource fields with same name + conflict between resource fields with same name Example: BookResource + name -> bookresource_name @@ -181,9 +181,6 @@ def _remove_unselected_resource_fields( self.cleaned_data = _cleaned_data def get_selected_resource(self): - """ - Get selected resource - """ if not getattr(self, "cleaned_data", None): raise forms.ValidationError( _("Form is not validated, call `is_valid` first") @@ -198,7 +195,7 @@ def get_selected_resource(self): pass return self.resources[resource_index] - def _normalize_resource_fields(self, selected_resource: ModelResource) -> dict: + def _normalize_resource_fields(self, selected_resource: ModelResource) -> None: """ Field names are combination of resource_name + field_name, normalize field names by removing resource name diff --git a/import_export/mixins.py b/import_export/mixins.py index 6356a278e..e417a6847 100644 --- a/import_export/mixins.py +++ b/import_export/mixins.py @@ -102,7 +102,7 @@ def choose_export_resource_class(self, form): def get_export_resource_kwargs(self, request, **kwargs): return self.get_resource_kwargs(request, **kwargs) - def get_export_resource_fields_from_from(self, form): + def get_export_resource_fields_from_form(self, form): if isinstance(form, SelectableFieldsExportForm): export_fields = form.get_selected_resource_export_fields() if export_fields: @@ -114,7 +114,7 @@ def get_data_for_export(self, request, queryset, **kwargs): export_form = kwargs.get("export_form") export_class = self.choose_export_resource_class(export_form) export_resource_kwargs = self.get_export_resource_kwargs(request, **kwargs) - export_fields = self.get_export_resource_fields_from_from(export_form) + export_fields = self.get_export_resource_fields_from_form(export_form) cls = export_class(**export_resource_kwargs) export_data = cls.export( queryset=queryset, export_fields=export_fields, **kwargs