diff options
author | Frederick Muriuki Muriithi | 2022-04-20 13:26:20 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-04-20 13:26:20 +0300 |
commit | 5897b6ec7fbd1226cd68a292122cc494e46f6829 (patch) | |
tree | eb7cf72b8da2546aded142e684b9b84ac02a23d9 /quality_control | |
parent | 8954890bd7410d79ce151196f406b8e1b6985238 (diff) | |
download | gn-uploader-5897b6ec7fbd1226cd68a292122cc494e46f6829.tar.gz |
Fix linting issues
Diffstat (limited to 'quality_control')
-rw-r--r-- | quality_control/average.py | 3 | ||||
-rw-r--r-- | quality_control/errors.py | 5 | ||||
-rw-r--r-- | quality_control/parsing.py | 13 | ||||
-rw-r--r-- | quality_control/standard_error.py | 3 |
4 files changed, 17 insertions, 7 deletions
diff --git a/quality_control/average.py b/quality_control/average.py index c552ba3..3261e1c 100644 --- a/quality_control/average.py +++ b/quality_control/average.py @@ -4,7 +4,8 @@ import re from .errors import InvalidCellValue def valid_value(val): - if re.search("^[0-9]+\.[0-9]{3}$", val): + """Checks whether `val` is a valid value for averages""" + if re.search(r"^[0-9]+\.[0-9]{3}$", val): return float(val) raise InvalidCellValue( f"Invalid value '{val}'.\n" diff --git a/quality_control/errors.py b/quality_control/errors.py index 993748c..0802159 100644 --- a/quality_control/errors.py +++ b/quality_control/errors.py @@ -19,5 +19,6 @@ class DuplicateHeader(Exception): super().__init__(self, *args) class ParseError(Exception): - def __init(self, *args): - super().__init__(*args) + """Raised if any of the above exceptions are raised""" + def __init__(self, *args): + super().__init__(self, *args) diff --git a/quality_control/parsing.py b/quality_control/parsing.py index 8b2715a..6e5bb8f 100644 --- a/quality_control/parsing.py +++ b/quality_control/parsing.py @@ -1,3 +1,5 @@ +"""Module handling the high-level parsing of the files""" + import csv from enum import Enum from functools import reduce @@ -9,11 +11,13 @@ from quality_control.errors import ( ParseError, DuplicateHeader, InvalidCellValue, InvalidHeaderValue) class FileType(Enum): + """Enumerate the expected file types""" AVERAGE = 1 STANDARD_ERROR = 2 def parse_strains(filepath): - with open(filepath) as strains_file: + """Parse the strains file""" + with open(filepath, encoding="utf8") as strains_file: reader = csv.DictReader( strains_file, fieldnames=[ @@ -43,6 +47,7 @@ LINE_PARSERS = { } def strain_names(strains): + """Retrieve a complete list of the names of the strains""" def __extract_strain_names(acc, strain): return acc + tuple( item for item in (strain["Name"], strain["Name2"]) @@ -50,6 +55,7 @@ def strain_names(strains): return reduce(__extract_strain_names, strains, tuple()) def parse_file(filepath: str, filetype: FileType, strains: list): + """Parse the given file""" seek_pos = 0 try: with open(filepath, encoding="utf-8") as input_file: @@ -66,5 +72,6 @@ def parse_file(filepath: str, filetype: FileType, strains: list): "filepath": filepath, "filetype": filetype, "position": seek_pos, - "line_number": line_number - }) + "line_number": line_number, + "error": err + }) from err diff --git a/quality_control/standard_error.py b/quality_control/standard_error.py index 7b49913..805c30e 100644 --- a/quality_control/standard_error.py +++ b/quality_control/standard_error.py @@ -4,7 +4,8 @@ import re from .errors import InvalidCellValue def valid_value(val): - if re.search("^[0-9]+\.[0-9]{6,}$", val): + """Checks whether `val` is a valid value for standard errors""" + if re.search(r"^[0-9]+\.[0-9]{6,}$", val): return float(val) raise InvalidCellValue( f"Invalid value '{val}'.\n" |