From b63a0e889bd8bf3ffab17accbc1a6a31ff7e1fc2 Mon Sep 17 00:00:00 2001 From: Pierre Narcisi Date: Fri, 26 Jan 2024 13:36:17 +0100 Subject: [PATCH] bump black --- backend/gn_module_import/checks/sql/__init__.py | 2 +- .../0e4f9da0e33f_remove_in_error_column.py | 1 + .../migrations/0ff8fc0b4233_remove_archive_schema.py | 1 + .../migrations/2896cf965dd6_unique_import_error.py | 1 + .../migrations/2ed6a7ee5250_add_two_columns.py | 1 + .../migrations/3a65de65b697_refactoring.py | 1 + .../485a659efdcd_add_import_done_notification.py | 1 + .../migrations/4b137deaf201_create_import_schema.py | 1 + .../migrations/5158afe602d2_default_notification.py | 1 + .../migrations/5c31e356cedc_add_loaded_column.py | 1 + .../61e11414f177_add_detected_separator.py | 1 + .../migrations/627b7968a55b_date_min_max_too_low.py | 1 + .../migrations/6470a2141c83_mappings.py | 1 + .../65defbe5027b_set_id_module_on_import_sources.py | 1 + .../migrations/681062ef2939_add_date_error.py | 1 + .../migrations/699c25251384_update_dict_fields.py | 1 + .../migrations/6f60b0b934b1_erroneous_rows.py | 1 + .../74058f69828a_remove_t_imports_is_finished.py | 1 + .../migrations/75f0f9906bf1_add_columns.py | 1 + .../8611f7aab8dc_allow_multi_select_mapping.py | 1 + .../906231e8f8e0_remove_temporary_tables.py | 1 + .../a11c9a2db7bb_set_import_module_type.py | 1 + .../a89a99f68203_declare_available_permissions.py | 1 + .../migrations/bf80cb5679be_remove_step_field.py | 1 + .../migrations/cadfdaa42430_add_task_id.py | 1 + .../migrations/d6bf8eaf088c_add_update_permission.py | 1 + .../migrations/ea67bf7b6888_remove_cd_fk.py | 1 + .../eb217f32d7d7_add_id_area_attachment.py | 1 + .../f394a5edcb56_on_delete_source_set_null.py | 1 + backend/gn_module_import/models.py | 8 +++++--- backend/gn_module_import/routes/imports.py | 3 ++- backend/gn_module_import/send_mail.py | 9 ++++++--- backend/gn_module_import/tests/conftest.py | 2 +- backend/gn_module_import/tests/test_imports.py | 12 +++++++----- backend/gn_module_import/tests/test_mappings.py | 10 ++++++---- backend/gn_module_import/utils.py | 4 +--- 36 files changed, 57 insertions(+), 21 deletions(-) diff --git a/backend/gn_module_import/checks/sql/__init__.py b/backend/gn_module_import/checks/sql/__init__.py index 1a822058..e883d8d9 100644 --- a/backend/gn_module_import/checks/sql/__init__.py +++ b/backend/gn_module_import/checks/sql/__init__.py @@ -54,7 +54,7 @@ def do_nomenclatures_mapping(imprt, fields): .where(TNomenclatures.id_type == BibNomenclaturesTypes.id_type) .values({field.synthese_field: TNomenclatures.id_nomenclature}) ) - db.session.execute(stmt, execution_options=dict({"synchronize_session": 'fetch'})) + db.session.execute(stmt, execution_options=dict({"synchronize_session": "fetch"})) for field in BibFields.query.filter(BibFields.mnemonique != None).all(): if ( diff --git a/backend/gn_module_import/migrations/0e4f9da0e33f_remove_in_error_column.py b/backend/gn_module_import/migrations/0e4f9da0e33f_remove_in_error_column.py index 3ae3ed36..9c2884a1 100644 --- a/backend/gn_module_import/migrations/0e4f9da0e33f_remove_in_error_column.py +++ b/backend/gn_module_import/migrations/0e4f9da0e33f_remove_in_error_column.py @@ -5,6 +5,7 @@ Create Date: 2022-04-25 10:51:14.746232 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/0ff8fc0b4233_remove_archive_schema.py b/backend/gn_module_import/migrations/0ff8fc0b4233_remove_archive_schema.py index e118b6ac..d065e54e 100644 --- a/backend/gn_module_import/migrations/0ff8fc0b4233_remove_archive_schema.py +++ b/backend/gn_module_import/migrations/0ff8fc0b4233_remove_archive_schema.py @@ -5,6 +5,7 @@ Create Date: 2022-05-12 09:39:45.951064 """ + import sqlalchemy as sa from sqlalchemy.schema import Table, MetaData from sqlalchemy.exc import NoReferenceError diff --git a/backend/gn_module_import/migrations/2896cf965dd6_unique_import_error.py b/backend/gn_module_import/migrations/2896cf965dd6_unique_import_error.py index cecc2ed8..a0b68686 100644 --- a/backend/gn_module_import/migrations/2896cf965dd6_unique_import_error.py +++ b/backend/gn_module_import/migrations/2896cf965dd6_unique_import_error.py @@ -5,6 +5,7 @@ Create Date: 2023-09-28 10:19:10.133530 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/2ed6a7ee5250_add_two_columns.py b/backend/gn_module_import/migrations/2ed6a7ee5250_add_two_columns.py index f9c85065..23174e7b 100644 --- a/backend/gn_module_import/migrations/2ed6a7ee5250_add_two_columns.py +++ b/backend/gn_module_import/migrations/2ed6a7ee5250_add_two_columns.py @@ -5,6 +5,7 @@ Create Date: 2021-03-30 11:06:40.502478 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/3a65de65b697_refactoring.py b/backend/gn_module_import/migrations/3a65de65b697_refactoring.py index dfbdf028..17ed1d00 100644 --- a/backend/gn_module_import/migrations/3a65de65b697_refactoring.py +++ b/backend/gn_module_import/migrations/3a65de65b697_refactoring.py @@ -5,6 +5,7 @@ Create Date: 2021-03-29 23:02:14.880716 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/485a659efdcd_add_import_done_notification.py b/backend/gn_module_import/migrations/485a659efdcd_add_import_done_notification.py index 7a30bf98..f46061f5 100644 --- a/backend/gn_module_import/migrations/485a659efdcd_add_import_done_notification.py +++ b/backend/gn_module_import/migrations/485a659efdcd_add_import_done_notification.py @@ -5,6 +5,7 @@ Create Date: 2023-01-12 12:01:34.177079 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/4b137deaf201_create_import_schema.py b/backend/gn_module_import/migrations/4b137deaf201_create_import_schema.py index f609b9ff..1dbc9d83 100644 --- a/backend/gn_module_import/migrations/4b137deaf201_create_import_schema.py +++ b/backend/gn_module_import/migrations/4b137deaf201_create_import_schema.py @@ -5,6 +5,7 @@ Create Date: 2021-03-29 18:38:24.512562 """ + from alembic import op, context import sqlalchemy as sa import pkg_resources diff --git a/backend/gn_module_import/migrations/5158afe602d2_default_notification.py b/backend/gn_module_import/migrations/5158afe602d2_default_notification.py index 71691451..6fd4c5aa 100644 --- a/backend/gn_module_import/migrations/5158afe602d2_default_notification.py +++ b/backend/gn_module_import/migrations/5158afe602d2_default_notification.py @@ -5,6 +5,7 @@ Create Date: 2023-03-22 16:17:51.354279 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/5c31e356cedc_add_loaded_column.py b/backend/gn_module_import/migrations/5c31e356cedc_add_loaded_column.py index 19d19f9b..ef301d83 100644 --- a/backend/gn_module_import/migrations/5c31e356cedc_add_loaded_column.py +++ b/backend/gn_module_import/migrations/5c31e356cedc_add_loaded_column.py @@ -5,6 +5,7 @@ Create Date: 2022-06-22 12:58:31.609964 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.sql import expression diff --git a/backend/gn_module_import/migrations/61e11414f177_add_detected_separator.py b/backend/gn_module_import/migrations/61e11414f177_add_detected_separator.py index ec5c917e..2b80837b 100644 --- a/backend/gn_module_import/migrations/61e11414f177_add_detected_separator.py +++ b/backend/gn_module_import/migrations/61e11414f177_add_detected_separator.py @@ -5,6 +5,7 @@ Create Date: 2022-04-14 14:03:41.842620 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/627b7968a55b_date_min_max_too_low.py b/backend/gn_module_import/migrations/627b7968a55b_date_min_max_too_low.py index 23ef28b4..02121ad6 100644 --- a/backend/gn_module_import/migrations/627b7968a55b_date_min_max_too_low.py +++ b/backend/gn_module_import/migrations/627b7968a55b_date_min_max_too_low.py @@ -5,6 +5,7 @@ Create Date: 2022-05-20 14:43:24.306971 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/6470a2141c83_mappings.py b/backend/gn_module_import/migrations/6470a2141c83_mappings.py index 3e5f8294..54aca7ab 100644 --- a/backend/gn_module_import/migrations/6470a2141c83_mappings.py +++ b/backend/gn_module_import/migrations/6470a2141c83_mappings.py @@ -5,6 +5,7 @@ Create Date: 2022-02-09 10:35:27.895766 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects.postgresql import JSON diff --git a/backend/gn_module_import/migrations/65defbe5027b_set_id_module_on_import_sources.py b/backend/gn_module_import/migrations/65defbe5027b_set_id_module_on_import_sources.py index 325ccbce..62e4628f 100644 --- a/backend/gn_module_import/migrations/65defbe5027b_set_id_module_on_import_sources.py +++ b/backend/gn_module_import/migrations/65defbe5027b_set_id_module_on_import_sources.py @@ -5,6 +5,7 @@ Create Date: 2022-07-05 18:09:53.133560 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/681062ef2939_add_date_error.py b/backend/gn_module_import/migrations/681062ef2939_add_date_error.py index 7b118c4a..8c72edd8 100644 --- a/backend/gn_module_import/migrations/681062ef2939_add_date_error.py +++ b/backend/gn_module_import/migrations/681062ef2939_add_date_error.py @@ -5,6 +5,7 @@ Create Date: 2022-05-10 12:42:31.793379 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/699c25251384_update_dict_fields.py b/backend/gn_module_import/migrations/699c25251384_update_dict_fields.py index db1d7517..f76f1bf9 100644 --- a/backend/gn_module_import/migrations/699c25251384_update_dict_fields.py +++ b/backend/gn_module_import/migrations/699c25251384_update_dict_fields.py @@ -5,6 +5,7 @@ Create Date: 2022-05-10 20:18:37.214323 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/6f60b0b934b1_erroneous_rows.py b/backend/gn_module_import/migrations/6f60b0b934b1_erroneous_rows.py index 96a97b72..0ce18e26 100644 --- a/backend/gn_module_import/migrations/6f60b0b934b1_erroneous_rows.py +++ b/backend/gn_module_import/migrations/6f60b0b934b1_erroneous_rows.py @@ -5,6 +5,7 @@ Create Date: 2022-06-20 17:48:33.848166 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.types import ARRAY diff --git a/backend/gn_module_import/migrations/74058f69828a_remove_t_imports_is_finished.py b/backend/gn_module_import/migrations/74058f69828a_remove_t_imports_is_finished.py index 7d55dfeb..0cb7f3b1 100644 --- a/backend/gn_module_import/migrations/74058f69828a_remove_t_imports_is_finished.py +++ b/backend/gn_module_import/migrations/74058f69828a_remove_t_imports_is_finished.py @@ -5,6 +5,7 @@ Create Date: 2022-04-27 13:51:46.622094 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/75f0f9906bf1_add_columns.py b/backend/gn_module_import/migrations/75f0f9906bf1_add_columns.py index bd6f8cae..1ad87389 100644 --- a/backend/gn_module_import/migrations/75f0f9906bf1_add_columns.py +++ b/backend/gn_module_import/migrations/75f0f9906bf1_add_columns.py @@ -5,6 +5,7 @@ Create Date: 2021-04-27 10:02:53.798753 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.types import ARRAY diff --git a/backend/gn_module_import/migrations/8611f7aab8dc_allow_multi_select_mapping.py b/backend/gn_module_import/migrations/8611f7aab8dc_allow_multi_select_mapping.py index 7688f733..fdac3500 100644 --- a/backend/gn_module_import/migrations/8611f7aab8dc_allow_multi_select_mapping.py +++ b/backend/gn_module_import/migrations/8611f7aab8dc_allow_multi_select_mapping.py @@ -5,6 +5,7 @@ Create Date: 2023-07-27 11:18:00.424394 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/906231e8f8e0_remove_temporary_tables.py b/backend/gn_module_import/migrations/906231e8f8e0_remove_temporary_tables.py index 4642ab4e..09088d6c 100644 --- a/backend/gn_module_import/migrations/906231e8f8e0_remove_temporary_tables.py +++ b/backend/gn_module_import/migrations/906231e8f8e0_remove_temporary_tables.py @@ -5,6 +5,7 @@ Create Date: 2022-03-31 12:38:11.170056 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.types import ARRAY diff --git a/backend/gn_module_import/migrations/a11c9a2db7bb_set_import_module_type.py b/backend/gn_module_import/migrations/a11c9a2db7bb_set_import_module_type.py index 5133e9fb..11c13c20 100644 --- a/backend/gn_module_import/migrations/a11c9a2db7bb_set_import_module_type.py +++ b/backend/gn_module_import/migrations/a11c9a2db7bb_set_import_module_type.py @@ -5,6 +5,7 @@ Create Date: 2022-07-05 18:15:09.885031 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/a89a99f68203_declare_available_permissions.py b/backend/gn_module_import/migrations/a89a99f68203_declare_available_permissions.py index 640048fd..4cabd732 100644 --- a/backend/gn_module_import/migrations/a89a99f68203_declare_available_permissions.py +++ b/backend/gn_module_import/migrations/a89a99f68203_declare_available_permissions.py @@ -5,6 +5,7 @@ Create Date: 2023-06-14 11:40:29.580680 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/bf80cb5679be_remove_step_field.py b/backend/gn_module_import/migrations/bf80cb5679be_remove_step_field.py index 8dade9bb..069649f7 100644 --- a/backend/gn_module_import/migrations/bf80cb5679be_remove_step_field.py +++ b/backend/gn_module_import/migrations/bf80cb5679be_remove_step_field.py @@ -5,6 +5,7 @@ Create Date: 2022-02-01 16:28:34.090996 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/cadfdaa42430_add_task_id.py b/backend/gn_module_import/migrations/cadfdaa42430_add_task_id.py index 68348dec..6816943c 100644 --- a/backend/gn_module_import/migrations/cadfdaa42430_add_task_id.py +++ b/backend/gn_module_import/migrations/cadfdaa42430_add_task_id.py @@ -5,6 +5,7 @@ Create Date: 2022-05-16 14:34:03.746276 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/d6bf8eaf088c_add_update_permission.py b/backend/gn_module_import/migrations/d6bf8eaf088c_add_update_permission.py index 4783467f..db85b646 100644 --- a/backend/gn_module_import/migrations/d6bf8eaf088c_add_update_permission.py +++ b/backend/gn_module_import/migrations/d6bf8eaf088c_add_update_permission.py @@ -5,6 +5,7 @@ Create Date: 2023-09-18 11:29:42.145359 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/ea67bf7b6888_remove_cd_fk.py b/backend/gn_module_import/migrations/ea67bf7b6888_remove_cd_fk.py index 9a95c6f9..5be4e91c 100644 --- a/backend/gn_module_import/migrations/ea67bf7b6888_remove_cd_fk.py +++ b/backend/gn_module_import/migrations/ea67bf7b6888_remove_cd_fk.py @@ -5,6 +5,7 @@ Create Date: 2023-09-27 15:37:19.286693 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/eb217f32d7d7_add_id_area_attachment.py b/backend/gn_module_import/migrations/eb217f32d7d7_add_id_area_attachment.py index ba9696df..8593c19a 100644 --- a/backend/gn_module_import/migrations/eb217f32d7d7_add_id_area_attachment.py +++ b/backend/gn_module_import/migrations/eb217f32d7d7_add_id_area_attachment.py @@ -5,6 +5,7 @@ Create Date: 2022-04-28 16:48:46.664645 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/migrations/f394a5edcb56_on_delete_source_set_null.py b/backend/gn_module_import/migrations/f394a5edcb56_on_delete_source_set_null.py index ddb84363..02cd836e 100644 --- a/backend/gn_module_import/migrations/f394a5edcb56_on_delete_source_set_null.py +++ b/backend/gn_module_import/migrations/f394a5edcb56_on_delete_source_set_null.py @@ -5,6 +5,7 @@ Create Date: 2022-06-22 11:40:05.678227 """ + from alembic import op import sqlalchemy as sa diff --git a/backend/gn_module_import/models.py b/backend/gn_module_import/models.py index 39505a25..ac9f3572 100644 --- a/backend/gn_module_import/models.py +++ b/backend/gn_module_import/models.py @@ -668,9 +668,11 @@ def validate_values(values): "type": "object", "properties": { field.name_field: { - "type": "boolean" - if field.autogenerated - else ("array" if field.multi else "string"), + "type": ( + "boolean" + if field.autogenerated + else ("array" if field.multi else "string") + ), } for field in fields }, diff --git a/backend/gn_module_import/routes/imports.py b/backend/gn_module_import/routes/imports.py index ea569c6e..70e8f499 100644 --- a/backend/gn_module_import/routes/imports.py +++ b/backend/gn_module_import/routes/imports.py @@ -5,10 +5,11 @@ from flask import request, current_app, jsonify, g, stream_with_context, send_file from werkzeug.exceptions import Conflict, BadRequest, Forbidden, Gone + # url_quote was deprecated in werkzeug 3.0 https://stackoverflow.com/a/77222063/5807438 from urllib.parse import ( quote as url_quote, -) +) from sqlalchemy import or_, func, desc from sqlalchemy.inspection import inspect from sqlalchemy.orm import joinedload, Load, load_only, undefer, contains_eager, class_mapper diff --git a/backend/gn_module_import/send_mail.py b/backend/gn_module_import/send_mail.py index ecf7e1ab..7b0e95d1 100644 --- a/backend/gn_module_import/send_mail.py +++ b/backend/gn_module_import/send_mail.py @@ -1,6 +1,7 @@ """ Fonctions permettant l'envoi d'email """ + from flask import url_for, current_app from geonature.utils.utilsmails import send_mail @@ -37,9 +38,11 @@ def import_send_mail(mail_to, file_name, step, id_import): send_mail( recipients=mail_to, - subject="[GeoNature] Import réalisé" - if (step == "import") - else "[GeoNature] Import - Contrôles terminés", + subject=( + "[GeoNature] Import réalisé" + if (step == "import") + else "[GeoNature] Import - Contrôles terminés" + ), msg_html=msg, ) diff --git a/backend/gn_module_import/tests/conftest.py b/backend/gn_module_import/tests/conftest.py index f3606998..1b5ded60 100644 --- a/backend/gn_module_import/tests/conftest.py +++ b/backend/gn_module_import/tests/conftest.py @@ -1,3 +1,3 @@ from geonature.tests.fixtures import * from geonature.tests.fixtures import app, _session, users -from pypnusershub.tests.fixtures import teardown_logout_user \ No newline at end of file +from pypnusershub.tests.fixtures import teardown_logout_user diff --git a/backend/gn_module_import/tests/test_imports.py b/backend/gn_module_import/tests/test_imports.py index a2bd3db2..763c1746 100644 --- a/backend/gn_module_import/tests/test_imports.py +++ b/backend/gn_module_import/tests/test_imports.py @@ -28,8 +28,8 @@ from pypnusershub.db.models import User, Organisme from pypnusershub.tests.utils import ( set_logged_user, - set_logged_user_cookie, - unset_logged_user_cookie + set_logged_user_cookie, + unset_logged_user_cookie, ) from pypnnomenclature.models import TNomenclatures, BibNomenclaturesTypes from ref_geo.tests.test_ref_geo import has_french_dem @@ -218,9 +218,11 @@ def fieldmapping(import_file_name, autogenerate): return FieldMapping.query.filter_by(label="Synthese GeoNature").one().values else: return { - f.name_field: autogenerate - if f.autogenerated - else ([f.name_field, "cd_nom"] if f.multi else f.name_field) + f.name_field: ( + autogenerate + if f.autogenerated + else ([f.name_field, "cd_nom"] if f.multi else f.name_field) + ) for f in BibFields.query.filter_by(display=True) } diff --git a/backend/gn_module_import/tests/test_mappings.py b/backend/gn_module_import/tests/test_mappings.py index 010a42ab..b724c0ff 100644 --- a/backend/gn_module_import/tests/test_mappings.py +++ b/backend/gn_module_import/tests/test_mappings.py @@ -28,7 +28,7 @@ Profils as Profil, UserApplicationRight, ) -from pypnusershub.tests.utils import (set_logged_user_cookie) +from pypnusershub.tests.utils import set_logged_user_cookie from gn_module_import.models import ( MappingTemplate, @@ -50,9 +50,11 @@ def mappings(users): mappings = {} fieldmapping_values = { - field.name_field: True - if field.autogenerated - else ([field.name_field] if field.multi else field.name_field) + field.name_field: ( + True + if field.autogenerated + else ([field.name_field] if field.multi else field.name_field) + ) for field in ( BibFields.query.filter_by(display=True).with_entities( BibFields.name_field, BibFields.autogenerated, BibFields.multi diff --git a/backend/gn_module_import/utils.py b/backend/gn_module_import/utils.py index d714746c..3c5af635 100644 --- a/backend/gn_module_import/utils.py +++ b/backend/gn_module_import/utils.py @@ -114,9 +114,7 @@ def detect_separator(f, encoding): def get_valid_bbox(imprt): - stmt = db.select( - func.ST_AsGeojson(func.ST_Extent(ImportSyntheseData.the_geom_4326)) - ).filter( + stmt = db.select(func.ST_AsGeojson(func.ST_Extent(ImportSyntheseData.the_geom_4326))).filter( ImportSyntheseData.imprt == imprt, ImportSyntheseData.valid == True, )