Skip to content

Commit

Permalink
upgrade to black==24.2.0, reformat (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Mar 1, 2024
1 parent ce2d114 commit 0cee45c
Show file tree
Hide file tree
Showing 24 changed files with 168 additions and 127 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Changed
- Upgrade minimum PostgreSQL version to v12 (#1074)
- Upgrade to PostgreSQL v16 in CI (#1074)
- Upgrade general Python dependencies (#1374)
- Reformat with ``black==24.2.0`` (#1374)

Removed
-------
Expand Down
6 changes: 3 additions & 3 deletions adminalerts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def __init__(self, current_user=None, *args, **kwargs):

# Creation
if not self.instance.pk:
self.fields[
'date_expire'
].initial = timezone.now() + timezone.timedelta(days=1)
self.fields['date_expire'].initial = (
timezone.now() + timezone.timedelta(days=1)
)
# Updating
else: # self.instance.pk
# Set description value as raw markdown
Expand Down
8 changes: 5 additions & 3 deletions adminalerts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ class AdminAlert(models.Model):
def __str__(self):
return '{}{}'.format(
self.message,
' [ACTIVE]'
if (self.active and self.date_expire > timezone.now())
else '',
(
' [ACTIVE]'
if (self.active and self.date_expire > timezone.now())
else ''
),
)

def __repr__(self):
Expand Down
1 change: 1 addition & 0 deletions adminalerts/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for UI views in the adminalerts app"""

from django.urls import reverse
from django.utils import timezone

Expand Down
1 change: 0 additions & 1 deletion appalerts/plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Plugins for the appalerts app"""


# Projectroles dependency
from projectroles.plugins import SiteAppPluginPoint, BackendPluginPoint

Expand Down
13 changes: 7 additions & 6 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

import environ
import os

Expand Down Expand Up @@ -365,9 +366,9 @@
AUTH_LDAP_CA_CERT_FILE = env.str('AUTH_LDAP_CA_CERT_FILE', None)
AUTH_LDAP_CONNECTION_OPTIONS = {**LDAP_DEFAULT_CONN_OPTIONS}
if AUTH_LDAP_CA_CERT_FILE:
AUTH_LDAP_CONNECTION_OPTIONS[
ldap.OPT_X_TLS_CACERTFILE
] = AUTH_LDAP_CA_CERT_FILE
AUTH_LDAP_CONNECTION_OPTIONS[ldap.OPT_X_TLS_CACERTFILE] = (
AUTH_LDAP_CA_CERT_FILE
)
AUTH_LDAP_CONNECTION_OPTIONS[ldap.OPT_X_TLS_NEWCTX] = 0
AUTH_LDAP_USER_FILTER = env.str(
'AUTH_LDAP_USER_FILTER', '(sAMAccountName=%(user)s)'
Expand Down Expand Up @@ -398,9 +399,9 @@
AUTH_LDAP2_CA_CERT_FILE = env.str('AUTH_LDAP2_CA_CERT_FILE', None)
AUTH_LDAP2_CONNECTION_OPTIONS = {**LDAP_DEFAULT_CONN_OPTIONS}
if AUTH_LDAP2_CA_CERT_FILE:
AUTH_LDAP2_CONNECTION_OPTIONS[
ldap.OPT_X_TLS_CACERTFILE
] = AUTH_LDAP2_CA_CERT_FILE
AUTH_LDAP2_CONNECTION_OPTIONS[ldap.OPT_X_TLS_CACERTFILE] = (
AUTH_LDAP2_CA_CERT_FILE
)
AUTH_LDAP2_CONNECTION_OPTIONS[ldap.OPT_X_TLS_NEWCTX] = 0
AUTH_LDAP2_USER_FILTER = env.str(
'AUTH_LDAP2_USER_FILTER', '(sAMAccountName=%(user)s)'
Expand Down
1 change: 1 addition & 0 deletions config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.
"""

import os
import sys

Expand Down
24 changes: 15 additions & 9 deletions filesfolders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ def get_success_url(self):
tl_event.add_object(
obj=self.object,
label=obj_type,
name=self.object.get_path()
if isinstance(self.object, Folder)
else self.object.name,
name=(
self.object.get_path()
if isinstance(self.object, Folder)
else self.object.name
),
)

messages.success(
Expand Down Expand Up @@ -843,12 +845,16 @@ def _finalize_edit(self, edit_count, target_folder, **kwargs):
self.batch_action,
edit_count,
edit_suffix,
'({} failed)'.format(len(self.failed))
if len(self.failed) > 0
else '',
'to {target_folder}'
if self.batch_action == 'move' and target_folder
else '',
(
'({} failed)'.format(len(self.failed))
if len(self.failed) > 0
else ''
),
(
'to {target_folder}'
if self.batch_action == 'move' and target_folder
else ''
),
),
extra_data=extra_data,
status_type='OK' if edit_count > 0 else 'FAILED',
Expand Down
8 changes: 5 additions & 3 deletions filesfolders/views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ def perform_destroy(self, instance):
tl_event.add_object(
obj=instance,
label=obj_type,
name=instance.get_path()
if isinstance(instance, Folder)
else instance.name,
name=(
instance.get_path()
if isinstance(instance, Folder)
else instance.name
),
)


Expand Down
30 changes: 15 additions & 15 deletions projectroles/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,26 +454,26 @@ def get_defaults(cls, scope, project=None, user=None, post_safe=False):
for plugin in app_plugins:
p_settings = cls.get_definitions(scope, plugin=plugin)
for s_key in p_settings:
ret[
'settings.{}.{}'.format(plugin.name, s_key)
] = cls.get_default(
plugin.name,
ret['settings.{}.{}'.format(plugin.name, s_key)] = (
cls.get_default(
plugin.name,
s_key,
project=project,
user=user,
post_safe=post_safe,
)
)

p_settings = cls.get_definitions(scope, app_name='projectroles')
for s_key in p_settings:
ret['settings.{}.{}'.format('projectroles', s_key)] = (
cls.get_default(
'projectroles',
s_key,
project=project,
user=user,
post_safe=post_safe,
)

p_settings = cls.get_definitions(scope, app_name='projectroles')
for s_key in p_settings:
ret[
'settings.{}.{}'.format('projectroles', s_key)
] = cls.get_default(
'projectroles',
s_key,
project=project,
user=user,
post_safe=post_safe,
)
return ret

Expand Down
1 change: 0 additions & 1 deletion projectroles/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""SODAR constants definition and helper functions"""


# Global SODAR constants
SODAR_CONSTANTS = {
# Project roles
Expand Down
30 changes: 18 additions & 12 deletions projectroles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,11 @@ def _set_app_setting_widget(self, app_name, s_field, s_key, s_val):
values = s_val['options'](project=self.instance)
self.fields[s_field] = forms.ChoiceField(
choices=[
(str(value[0]), str(value[1]))
if isinstance(value, tuple)
else (str(value), str(value))
(
(str(value[0]), str(value[1]))
if isinstance(value, tuple)
else (str(value), str(value))
)
for value in values
],
**setting_kwargs
Expand All @@ -418,19 +420,23 @@ def _set_app_setting_widget(self, app_name, s_field, s_key, s_val):
values = s_val['options'](project=None)
self.fields[s_field] = forms.ChoiceField(
choices=[
(str(value[0]), str(value[1]))
if isinstance(value, tuple)
else (str(value), str(value))
(
(str(value[0]), str(value[1]))
if isinstance(value, tuple)
else (str(value), str(value))
)
for value in values
],
**setting_kwargs
)
else:
self.fields[s_field] = forms.ChoiceField(
choices=[
(int(option), int(option))
if s_val['type'] == 'INTEGER'
else (option, option)
(
(int(option), int(option))
if s_val['type'] == 'INTEGER'
else (option, option)
)
for option in s_val['options']
],
**setting_kwargs
Expand Down Expand Up @@ -662,9 +668,9 @@ def __init__(self, project=None, current_user=None, *args, **kwargs):
self.initial['owner'] = parent_project.get_owner().user
else:
self.initial['owner'] = self.current_user
self.fields[
'owner'
].label_from_instance = lambda x: x.get_form_label(email=True)
self.fields['owner'].label_from_instance = (
lambda x: x.get_form_label(email=True)
)
# Hide owner select widget for regular users
if not self.current_user.is_superuser:
self.fields['owner'].widget = forms.HiddenInput()
Expand Down
8 changes: 5 additions & 3 deletions projectroles/management/commands/cleanappsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ def get_setting_str(db_setting):
return '.'.join(
[
'settings',
'projectroles'
if db_setting.app_plugin is None
else db_setting.app_plugin.name,
(
'projectroles'
if db_setting.app_plugin is None
else db_setting.app_plugin.name
),
db_setting.name,
]
)
Expand Down
8 changes: 5 additions & 3 deletions projectroles/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,11 @@ def get_active_plugins(plugin_type='project_app', custom_order=False):
]
return sorted(
ret,
key=lambda x: x.plugin_ordering
if custom_order and plugin_type == 'project_app'
else x.name,
key=lambda x: (
x.plugin_ordering
if custom_order and plugin_type == 'project_app'
else x.name
),
)
return None

Expand Down
42 changes: 24 additions & 18 deletions projectroles/remote_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def _add_parent_categories(cls, sync_data, category, project_level):
cat_data = {
'title': category.title,
'type': PROJECT_TYPE_CATEGORY,
'parent_uuid': str(category.parent.sodar_uuid)
if category.parent
else None,
'parent_uuid': (
str(category.parent.sodar_uuid) if category.parent else None
),
'description': category.description,
'readme': category.readme.raw,
}
Expand Down Expand Up @@ -192,15 +192,17 @@ def _add_app_setting(cls, sync_data, app_setting, all_defs, add_user_name):
'type': app_setting.type,
'value': app_setting.value,
'value_json': app_setting.value_json,
'app_plugin': app_setting.app_plugin.name
if app_setting.app_plugin
else None,
'project_uuid': str(app_setting.project.sodar_uuid)
if app_setting.project
else None,
'user_uuid': str(app_setting.user.sodar_uuid)
if app_setting.user
else None,
'app_plugin': (
app_setting.app_plugin.name if app_setting.app_plugin else None
),
'project_uuid': (
str(app_setting.project.sodar_uuid)
if app_setting.project
else None
),
'user_uuid': (
str(app_setting.user.sodar_uuid) if app_setting.user else None
),
'local': local,
}
if add_user_name:
Expand Down Expand Up @@ -260,9 +262,11 @@ def get_source_data(self, target_site, req_version=None):
logger.error(
'Failed to add app setting "{}.settings.{}" '
'(UUID={}): {} '.format(
a.app_plugin.name
if a.app_plugin
else 'projectroles',
(
a.app_plugin.name
if a.app_plugin
else 'projectroles'
),
a.name,
a.sodar_uuid,
ex,
Expand Down Expand Up @@ -1236,9 +1240,11 @@ def sync_remote_data(self, site, remote_data, request=None):
except Exception as ex:
logger.error(
'Failed to set app setting "{}.setting.{}" ({}): {}'.format(
a_data['app_plugin']
if a_data['app_plugin']
else 'projectroles',
(
a_data['app_plugin']
if a_data['app_plugin']
else 'projectroles'
),
a_data['name'],
a_uuid,
ex,
Expand Down
Loading

0 comments on commit 0cee45c

Please sign in to comment.