Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coldfront/core/allocation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def send_eula_reminders():
logger.debug(f"Allocation(s) EULA reminder sent to users {email_receiver_list}.")


def send_expiry_emails():
def send_expiry_emails(): # noqa: C901 # FIXME: function is too complex
# Allocations expiring soon
for user in User.objects.all():
projectdict = {}
Expand Down
10 changes: 5 additions & 5 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def get(self, request, *args, **kwargs):
context["allocation"] = allocation_obj
return self.render_to_response(context)

def post(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex
pk = self.kwargs.get("pk")
allocation_obj = get_object_or_404(Allocation, pk=pk)
allocation_users = allocation_obj.allocationuser_set.exclude(status__name__in=["Removed"]).order_by(
Expand Down Expand Up @@ -434,7 +434,7 @@ class AllocationListView(LoginRequiredMixin, ListView):
context_object_name = "allocation_list"
paginate_by = 25

def get_queryset(self):
def get_queryset(self): # noqa: C901 # FIXME: method is too complex
order_by = self.request.GET.get("order_by")
if order_by:
direction = self.request.GET.get("direction")
Expand Down Expand Up @@ -659,7 +659,7 @@ def get_form(self, form_class=None):
form_class = self.get_form_class()
return form_class(self.request.user, self.kwargs.get("project_pk"), **self.get_form_kwargs())

def form_valid(self, form):
def form_valid(self, form): # noqa: C901 # FIXME: method is too complex
form_data = form.cleaned_data
project_obj = get_object_or_404(Project, pk=self.kwargs.get("project_pk"))
resource_obj = form_data.get("resource")
Expand Down Expand Up @@ -1762,7 +1762,7 @@ def get(self, request, *args, **kwargs):
context["note_form"] = note_form
return render(request, self.template_name, context)

def post(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex
pk = self.kwargs.get("pk")
if not self.request.user.is_superuser:
messages.error(request, "You do not have permission to update an allocation change request")
Expand Down Expand Up @@ -2028,7 +2028,7 @@ def get(self, request, *args, **kwargs):
context["attributes"] = allocation_attributes_to_change
return render(request, self.template_name, context)

def post(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex
change_requested = False
attribute_changes_to_make = set({})

Expand Down
4 changes: 2 additions & 2 deletions coldfront/core/attribute_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_attriblist_str(attribute_name, resources=[], allocations=[]):
return attriblist


def get_attribute_parameter_value(argument, attribute_parameter_dict, error_text, resources=[], allocations=[]):
def get_attribute_parameter_value(argument, attribute_parameter_dict, error_text, resources=[], allocations=[]): # noqa: C901 # FIXME: function is too complex
"""Evaluates the argument for a attribute parameter statement.

This is called by process_attribute_parameter_string and handles
Expand Down Expand Up @@ -178,7 +178,7 @@ def get_attribute_parameter_value(argument, attribute_parameter_dict, error_text
return None


def process_attribute_parameter_operation(opcode, oldvalue, argument, error_text):
def process_attribute_parameter_operation(opcode, oldvalue, argument, error_text): # noqa: C901 # FIXME: method is too complex
"""Process the specified operation for attribute_parameter_dict.

This is called by process_attribute_parameter_string and handles
Expand Down
4 changes: 2 additions & 2 deletions coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_func(self):
messages.error(self.request, "You do not have permission to view the previous page.")
return False

def get_context_data(self, **kwargs):
def get_context_data(self, **kwargs): # noqa: C901 # FIXME: method is too complex
context = super().get_context_data(**kwargs)
# Can the user update the project?
if self.request.user.is_superuser:
Expand Down Expand Up @@ -800,7 +800,7 @@ def dispatch(self, request, *args, **kwargs):
else:
return super().dispatch(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex
user_search_string = request.POST.get("q")
search_by = request.POST.get("search_by")
pk = self.kwargs.get("pk")
Expand Down
2 changes: 1 addition & 1 deletion coldfront/core/resource/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ResourceListView(LoginRequiredMixin, ListView):
context_object_name = "resource_list"
paginate_by = 25

def get_queryset(self):
def get_queryset(self): # noqa: C901 # FIXME: method is too complex
order_by = self.request.GET.get("order_by", "id")
direction = self.request.GET.get("direction", "asc")
if order_by != "name":
Expand Down
2 changes: 1 addition & 1 deletion coldfront/plugins/auto_compute_allocation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


# automatically create a compute allocation, called by project_new signal
def add_auto_compute_allocation(project_obj):
def add_auto_compute_allocation(project_obj): # noqa: C901 # FIXME: method is too complex
"""Method to add a compute allocation automatically upon project creation - uses signals for project creation"""

# if project_code not enabled or None or empty, print appropriate message and stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def check_user_freeipa(self, user, active_groups, removed_groups):
logger.info("User %s should be removed from freeipa group: %s", user.username, g)
self.remove_group(user, g, freeipa_status)

def process_user(self, user):
def process_user(self, user): # noqa: C901 # FIXME: method is too complex
if self.filter_user and self.filter_user != user.username:
return

Expand Down Expand Up @@ -241,7 +241,7 @@ def process_user(self, user):

self.check_user_freeipa(user, active_groups, removed_groups)

def handle(self, *args, **options):
def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex
os.environ["KRB5_CLIENT_KTNAME"] = CLIENT_KTNAME

verbosity = int(options["verbosity"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def writerow(self, row):
os.dup2(devnull, sys.stdout.fileno())
sys.exit(1)

def handle(self, *args, **options):
def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex
os.environ["KRB5_CLIENT_KTNAME"] = CLIENT_KTNAME

verbosity = int(options["verbosity"])
Expand Down
2 changes: 1 addition & 1 deletion coldfront/plugins/freeipa/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def add_user_group(allocation_user_pk):
logger.info("Added user %s to group %s successfully", allocation_user.user.username, g)


def remove_user_group(allocation_user_pk):
def remove_user_group(allocation_user_pk): # noqa: C901 # FIXME: function is too complex
allocation_user = AllocationUser.objects.get(pk=allocation_user_pk)
if allocation_user.allocation.status.name not in [
"Active",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def handle_project_removal_if_needed(self, project, project_ou_dn, sync=False):
f"Exception removing {project.project_code}, DN: {project_ou_dn} in OpenLDAP: {e}"
)

def handle_description_update(
def handle_description_update( # noqa: C901 # FIXME: method is too complex
self,
project,
project_dn="",
Expand Down Expand Up @@ -299,7 +299,7 @@ def local_get_openldap_members(self, dn):
members.extend(entry.memberUid.values)
return tuple(members)

def sync_members(
def sync_members( # noqa: C901 # FIXME: method is too complex
self,
project,
cf_members,
Expand Down Expand Up @@ -400,7 +400,7 @@ def sync_members(
)

# N.B. this is the main function to check projects...
def sync_check_project(
def sync_check_project( # noqa: C901 # FIXME: method is too complex
self,
project_group,
sync=False,
Expand Down Expand Up @@ -619,7 +619,7 @@ def loop_all_projects(

# --------------------------------

def handle(self, *args, **options):
def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex
verbosity = int(options["verbosity"])
root_logger = logging.getLogger("")
if verbosity == 0:
Expand Down
2 changes: 1 addition & 1 deletion coldfront/plugins/slurm/associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, name, specs=None):
self.accounts = {}

@staticmethod
def new_from_stream(stream):
def new_from_stream(stream): # noqa: C901 # FIXME: method is too complex
"""Create a new SlurmCluster by parsing the output from sacctmgr dump."""
cluster = None
parent = None
Expand Down
2 changes: 1 addition & 1 deletion coldfront/plugins/slurm/management/commands/slurm_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _cluster_from_dump(self, cluster):

return slurm_cluster

def handle(self, *args, **options):
def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex
verbosity = int(options["verbosity"])
root_logger = logging.getLogger("")
if verbosity == 0:
Expand Down
10 changes: 5 additions & 5 deletions coldfront/plugins/xdmod/management/commands/xdmod_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def write(self, data):
os.dup2(devnull, sys.stdout.fileno())
sys.exit(1)

def process_total_storage(self):
def process_total_storage(self): # noqa: C901 # FIXME: method is too complex
header = [
"allocation_id",
"pi",
Expand Down Expand Up @@ -156,7 +156,7 @@ def process_total_storage(self):
)
)

def process_total_gpu_hours(self):
def process_total_gpu_hours(self): # noqa: C901 # FIXME: method is too complex
header = [
"allocation_id",
"pi",
Expand Down Expand Up @@ -261,7 +261,7 @@ def process_total_gpu_hours(self):
)
)

def process_total_cpu_hours(self):
def process_total_cpu_hours(self): # noqa: C901 # FIXME: method is too complex
header = [
"allocation_id",
"pi",
Expand Down Expand Up @@ -359,7 +359,7 @@ def process_total_cpu_hours(self):
)
)

def process_cloud_core_time(self):
def process_cloud_core_time(self): # noqa: C901 # FIXME: method is too complex
header = [
"allocation_id",
"pi",
Expand Down Expand Up @@ -457,7 +457,7 @@ def process_cloud_core_time(self):
)
)

def handle(self, *args, **options):
def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex
verbosity = int(options["verbosity"])
root_logger = logging.getLogger("")
if verbosity == 0:
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ indent-width = 4
target-version = "py312"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "I"]
select = ["E4", "E7", "E9", "F", "I", "C90"]

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.format]
indent-style = "space"
Expand Down