diff options
author | Frederick Muriuki Muriithi | 2024-10-07 15:54:33 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-10-07 16:01:18 -0500 |
commit | f461e4f29a8f32ec954cf858fb21de936f3b325b (patch) | |
tree | 89bbfdab37fce018f36e38b3ed930646d85051e2 | |
parent | 4c0186d281ff77b28fa1abe1f84da0e8cb72dea1 (diff) | |
download | gn-uploader-f461e4f29a8f32ec954cf858fb21de936f3b325b.tar.gz |
linting: Fix minor linting issues.
-rw-r--r-- | uploader/input_validation.py | 2 | ||||
-rw-r--r-- | uploader/phenotypes/views.py | 4 | ||||
-rw-r--r-- | uploader/population/views.py | 1 | ||||
-rw-r--r-- | uploader/samples/views.py | 17 |
4 files changed, 8 insertions, 16 deletions
diff --git a/uploader/input_validation.py b/uploader/input_validation.py index b84fca6..3b5d4dd 100644 --- a/uploader/input_validation.py +++ b/uploader/input_validation.py @@ -4,8 +4,6 @@ import json import base64 from typing import Any -from flask import request - def is_empty_string(value: str) -> bool: """Check whether as string is empty""" return (isinstance(value, str) and value.strip() == "") diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index c7bc965..312179e 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -236,7 +236,7 @@ def view_phenotype(# pylint: disable=[unused-argument] @with_population( species_redirect_uri="species.populations.phenotypes.index", redirect_uri="species.populations.phenotypes.select_population") -def create_dataset(species: dict, population: dict, **kwargs): +def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable=[unused-argument] """Create a new phenotype dataset.""" with (database_connection(app.config["SQL_URI"]) as conn, conn.cursor(cursorclass=DictCursor) as cursor): @@ -267,7 +267,7 @@ def create_dataset(species: dict, population: dict, **kwargs): dataset_shortname = ( form["dataset-shortname"] or form["dataset-name"]).strip() - pheno_dataset = save_new_dataset( + _pheno_dataset = save_new_dataset( cursor, population["Id"], form["dataset-name"].strip(), diff --git a/uploader/population/views.py b/uploader/population/views.py index b101d94..36201ba 100644 --- a/uploader/population/views.py +++ b/uploader/population/views.py @@ -1,5 +1,4 @@ """Views dealing with populations/inbredsets""" -import re import json import base64 diff --git a/uploader/samples/views.py b/uploader/samples/views.py index 9ba1df8..b8ec4d4 100644 --- a/uploader/samples/views.py +++ b/uploader/samples/views.py @@ -3,11 +3,8 @@ import os import sys import uuid from pathlib import Path -from typing import Iterator -import MySQLdb as mdb from redis import Redis -from MySQLdb.cursors import DictCursor from flask import (flash, request, url_for, @@ -20,11 +17,11 @@ from uploader.files import save_file from uploader.ui import make_template_renderer from uploader.authorisation import require_login from uploader.input_validation import is_integer_input -from uploader.datautils import order_by_family, enumerate_sequence -from uploader.db_utils import ( - with_db_connection, - database_connection, - with_redis_connection) +from uploader.datautils import safe_int, order_by_family, enumerate_sequence +from uploader.population.models import population_by_id, populations_by_species +from uploader.db_utils import (with_db_connection, + database_connection, + with_redis_connection) from uploader.species.models import (all_species, species_by_id, order_species_by_family) @@ -110,9 +107,7 @@ def list_samples(species_id: int, population_id: int): all_samples = enumerate_sequence(samples_by_species_and_population( conn, species_id, population_id)) total_samples = len(all_samples) - offset = int(request.args.get("from") or 0) - if offset < 0: - offset = 0 + offset = max(safe_int(request.args.get("from") or 0), 0) count = int(request.args.get("count") or 20) return render_template("samples/list-samples.html", species=species, |