Skip to content

Commit

Permalink
lint with black 23.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Feb 1, 2023
1 parent 443ee99 commit 3061545
Show file tree
Hide file tree
Showing 21 changed files with 14 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
language_version: python3.9
4 changes: 1 addition & 3 deletions backend/geonature/core/gn_commons/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def test_header_content_type(self, content_type):
return True

def test_url(self):

try:
if not self.data["media_url"]:
return
Expand Down Expand Up @@ -350,7 +349,6 @@ def delete(self):
initial_path = self.media.media_path

if self.media.media_path and not current_app.config["SQLALCHEMY_TRACK_MODIFICATIONS"]:

try:
self.media.__before_commit_delete__()

Expand Down Expand Up @@ -423,7 +421,7 @@ def sync_medias():
search_path = pathlib.Path(
current_app.config["BASE_DIR"], current_app.config["UPLOAD_FOLDER"]
)
for (repertoire, sous_repertoires, fichiers) in os.walk(search_path):
for repertoire, sous_repertoires, fichiers in os.walk(search_path):
for f in fichiers:
id_media = f.split("_")[0]
try:
Expand Down
2 changes: 0 additions & 2 deletions backend/geonature/core/gn_commons/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def get_additional_fields():
q = q.filter(TAdditionalFields.datasets.any(id_dataset=params["id_dataset"]))
if "module_code" in params:
if len(params["module_code"].split(",")) > 1:

ors = [
TAdditionalFields.modules.any(module_code=module_code)
for module_code in params["module_code"].split(",")
Expand Down Expand Up @@ -216,7 +215,6 @@ def get_t_mobile_apps():
@json_resp
# schema_dot_table gn_commons.t_modules
def api_get_id_table_location(schema_dot_table):

schema_name = schema_dot_table.split(".")[0]
table_name = schema_dot_table.split(".")[1]
return get_table_location_id(schema_name, table_name)
Expand Down
1 change: 0 additions & 1 deletion backend/geonature/core/gn_meta/mtd/xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def parse_acquisition_framwork_xml(xml):


def parse_acquisition_framework(ca):

# We extract all the required informations from the different tags of the XML file
ca_uuid = get_tag_content(ca, "identifiantCadre")
ca_name_max_length = TAcquisitionFramework.acquisition_framework_name.property.columns[
Expand Down
2 changes: 0 additions & 2 deletions backend/geonature/core/gn_meta/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ def sensi_report():


def my_csv_resp(filename, data, columns, _header, separator=";"):

headers = Headers()
headers.add("Content-Type", "text/plain")
headers.add("Content-Disposition", "attachment", filename="export_%s.csv" % filename)
Expand Down Expand Up @@ -748,7 +747,6 @@ def delete_acquisition_framework(scope, af_id):


def acquisitionFrameworkHandler(request, *, acquisition_framework):

# Test des droits d'édition du acquisition framework si modification
if acquisition_framework.id_acquisition_framework is not None:
user_cruved = get_scopes_by_action(module_code="META_DATA")
Expand Down
2 changes: 0 additions & 2 deletions backend/geonature/core/gn_permissions/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class UserCruved:
def __init__(
self, id_role, code_filter_type, module_code=None, object_code=None, append_to_select=None
):

self._id_role = id_role
self._code_filter_type = code_filter_type
if module_code:
Expand All @@ -103,7 +102,6 @@ def __init__(
self._permission_select = self._build_permission_select_list(append_to_select)

def _build_permission_select_list(self, append_to_select):

# Construction de la liste des couples module_code, object_code
# a récupérer pour générer le cruved
# append_to_select => Ajout de selection pour complexifié l'héritage
Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_observations_for_web(scope):

# Build final GeoJson
geojson_features = []
for (geom_as_geojson, properties) in results:
for geom_as_geojson, properties in results:
geojson_features.append(
Feature(
geometry=json.loads(geom_as_geojson),
Expand Down
2 changes: 0 additions & 2 deletions backend/geonature/core/gn_synthese/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def import_from_table(schema_name, table_name, field_name, value, limit=50):
for all rows satisfying the condition : <field_name> = <value>
"""
try:

# TODO get nb
txt = """SELECT COUNT(*) FROM {}.{} WHERE {}::varchar = '{}'""".format(
schema_name, table_name, field_name, value
Expand All @@ -26,7 +25,6 @@ def import_from_table(schema_name, table_name, field_name, value, limit=50):

# on procède ici par boucle pour traiter un nombre raisonnable de donnée à la fois
while limit * i < nb_data:

txt = """SELECT gn_synthese.import_row_from_table(
'{}',
'{}',
Expand Down
4 changes: 1 addition & 3 deletions backend/geonature/core/notifications/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
routes = Blueprint("notifications", __name__)
log = logging.getLogger()


# Get all database notification for current user
@routes.route("/notifications", methods=["GET"])
@permissions.login_required
def list_database_notification():

notifications = Notification.query.filter(Notification.id_role == g.current_user.id_role)
notifications = notifications.order_by(
Notification.code_status.desc(), Notification.creation_date.desc()
Expand All @@ -56,7 +56,6 @@ def list_database_notification():
@routes.route("/count", methods=["GET"])
@permissions.login_required
def count_notification():

notificationNumber = Notification.query.filter(
Notification.id_role == g.current_user.id_role, Notification.code_status == "UNREAD"
).count()
Expand All @@ -67,7 +66,6 @@ def count_notification():
@routes.route("/notifications/<int:id_notification>", methods=["POST"])
@permissions.login_required
def update_notification(id_notification):

notification = Notification.query.get_or_404(id_notification)
if notification.id_role != g.current_user.id_role:
raise Forbidden
Expand Down
1 change: 0 additions & 1 deletion backend/geonature/core/notifications/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

@celery_app.task(bind=True)
def send_notification_mail(self, subject, content, recipient):

logger.info(f"Launch mail.")
mail.send_mail(recipient, subject, content)
7 changes: 6 additions & 1 deletion backend/geonature/core/ref_geo/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

routes = Blueprint("ref_geo", __name__)

altitude_stmt = sa.select([sa.column("altitude_min"), sa.column("altitude_max"),]).select_from(
altitude_stmt = sa.select(
[
sa.column("altitude_min"),
sa.column("altitude_max"),
]
).select_from(
func.ref_geo.fct_get_altitude_intersection(
func.ST_SetSRID(
func.ST_GeomFromGeoJSON(sa.bindparam("geojson")),
Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/core/users/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def get_roles_by_menu_code(code_liste):
@routes.route("/listes", methods=["GET"])
@json_resp
def get_listes():

q = DB.session.query(UserList)
lists = q.all()
return [l.as_dict() for l in lists]
Expand Down Expand Up @@ -213,6 +212,7 @@ def get_organismes_jdd():
### ACCOUNT_MANAGEMENT ROUTES #####
#########################


# TODO: let frontend call UsersHub directly?
@routes.route("/inscription", methods=["POST"])
def inscription():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


def upgrade():

# Create new schema
logger.info("Create schema " + SCHEMA_NAME)
op.execute("CREATE SCHEMA " + SCHEMA_NAME)
Expand Down Expand Up @@ -163,6 +162,5 @@ def upgrade():


def downgrade():

logger.info("DROP SCHEMA " + SCHEMA_NAME + " CASCADE")
op.execute("DROP SCHEMA " + SCHEMA_NAME + " CASCADE")
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@


def upgrade():

op.create_index(INDEX_NAME, schema=SCHEMA_NAME, table_name=TABLE_NAME, columns=[COLUMN_NAME])


def downgrade():

op.drop_index(INDEX_NAME, schema=SCHEMA_NAME, table_name=TABLE_NAME)
4 changes: 2 additions & 2 deletions backend/geonature/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def synthese_data(app, users, datasets, source):
point3 = Point(-3.486786, 48.832182)
data = {}
with db.session.begin_nested():
for (name, cd_nom, point, ds) in [
for name, cd_nom, point, ds in [
("obs1", 713776, point1, datasets["own_dataset"]),
("obs2", 212, point2, datasets["own_dataset"]),
("obs3", 2497, point3, datasets["own_dataset"]),
Expand All @@ -308,7 +308,6 @@ def synthese_data(app, users, datasets, source):
("p2_af1", 2497, point2, datasets["belong_af_1"]),
("p3_af3", 2497, point3, datasets["belong_af_3"]),
]:

unique_id_sinp = (
"f4428222-d038-40bc-bc5c-6e977bbbc92b" if not data else func.uuid_generate_v4()
)
Expand Down Expand Up @@ -379,6 +378,7 @@ def medium(app):
@pytest.fixture()
def reports_data(users, synthese_data):
data = []

# do not commit directly on current transaction, as we want to rollback all changes at the end of tests
def create_report(id_synthese, id_role, content, id_type, deleted):
new_report = TReport(
Expand Down
1 change: 0 additions & 1 deletion backend/geonature/tests/test_gn_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,6 @@ def test_get_af_from_id_none(self):
get_af_from_id(id_af=id_af, af_list=af_list)

def test__get_create_scope(self, app, users):

modcode = "METADATA"

with app.test_request_context(headers=logged_user_headers(users["user"])):
Expand Down
3 changes: 0 additions & 3 deletions backend/geonature/tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ def test_delete_all_rules(self, users, notification_rule):
).scalar()

def test_list_methods(self, users, rule_method):

# Init data for test
url = "notifications.list_notification_methods"
log.debug("Url d'appel %s", url_for(url))
Expand All @@ -347,7 +346,6 @@ def test_list_methods(self, users, rule_method):
assert len(data) > 0

def test_list_notification_categories(self, users):

# Init data for test
url = "notifications.list_notification_categories"
log.debug("Url d'appel %s", url_for(url))
Expand All @@ -365,7 +363,6 @@ def test_list_notification_categories(self, users):

# test only notification insertion in database whitout dispatch
def test_send_db_notification(self, users):

result = utils.send_db_notification(
users["admin_user"], "test creation", "no templating", "https://geonature.fr"
)
Expand Down
1 change: 0 additions & 1 deletion backend/geonature/utils/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def rename_file(old_chemin, old_title, new_title):


def upload_file(file, id_media, cd_ref, titre):

filename = ("{cd_ref}_{id_media}_{title}.{ext}").format(
cd_ref=str(cd_ref),
id_media=str(id_media),
Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/utils/utilssqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def serializefn(self, recursif=False, columns=(), relationships=()):
if recursif is False:
return out

for (rel, uselist) in selected_relationship:
for rel, uselist in selected_relationship:
if getattr(self, rel):
if uselist is True:
out[rel] = [
Expand Down
1 change: 0 additions & 1 deletion contrib/gn_module_occhab/backend/gn_module_occhab/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def filter_query_with_cruved(
)
)
if user.value_filter in ("1", "2"):

sub_query_id_role = (
DB.session.query(CorStationObserverOccHab)
.filter(CorStationObserverOccHab.id_role == user.id_role)
Expand Down
1 change: 0 additions & 1 deletion contrib/occtax/backend/occtax/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ def updateReleve(id_releve, info_role):


def occurrenceHandler(request, *, occurrence, info_role):

releve = TRelevesOccurrence.query.get_or_404(occurrence.id_releve_occtax)

# Test des droits d'édition du relevé si modification
Expand Down

0 comments on commit 3061545

Please sign in to comment.