Skip to content

Commit d9c7e68

Browse files
committed
STY: Update flake8 requirements
Fixes #846
1 parent 32d6d8e commit d9c7e68

File tree

12 files changed

+79
-63
lines changed

12 files changed

+79
-63
lines changed

qiita_core/configuration_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
88

9+
from .exceptions import MissingConfigSection
10+
911
from functools import partial
1012
from os.path import join, dirname, abspath, isdir
1113
from os import environ
1214
from future import standard_library
1315
with standard_library.hooks():
1416
from configparser import ConfigParser
1517

16-
from .exceptions import MissingConfigSection
17-
1818

1919
class ConfigurationManager(object):
2020
"""Holds the QIITA configuration

qiita_core/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
#
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
8+
from qiita_core.qiita_settings import qiita_config
9+
from qiita_db.sql_connection import SQLConnectionHandler
10+
from qiita_db.environment_manager import reset_test_database
11+
812
from smtplib import SMTP, SMTP_SSL, SMTPException
913
from future import standard_library
1014
with standard_library.hooks():
1115
from email.mime.multipart import MIMEMultipart
1216
from email.mime.text import MIMEText
1317

14-
from qiita_core.qiita_settings import qiita_config
15-
from qiita_db.sql_connection import SQLConnectionHandler
16-
from qiita_db.environment_manager import reset_test_database
17-
1818

1919
def send_email(to, subject, body):
2020
# create email

qiita_db/commands.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
88

9+
from .study import Study, StudyPerson
10+
from .user import User
11+
from .util import (get_filetypes, get_filepath_types, compute_checksum,
12+
convert_to_id)
13+
from .data import RawData, PreprocessedData, ProcessedData
14+
from .metadata_template import (SampleTemplate, PrepTemplate,
15+
load_template_to_dataframe)
16+
from .parameters import (PreprocessedIlluminaParams, Preprocessed454Params,
17+
ProcessedSortmernaParams)
18+
from .sql_connection import SQLConnectionHandler
19+
920
from dateutil.parser import parse
1021
from os import listdir, remove
1122
from os.path import join, exists
@@ -17,16 +28,6 @@
1728
with standard_library.hooks():
1829
from configparser import ConfigParser
1930

20-
from .study import Study, StudyPerson
21-
from .user import User
22-
from .util import (get_filetypes, get_filepath_types, compute_checksum,
23-
convert_to_id)
24-
from .data import RawData, PreprocessedData, ProcessedData
25-
from .metadata_template import (SampleTemplate, PrepTemplate,
26-
load_template_to_dataframe)
27-
from .parameters import (PreprocessedIlluminaParams, Preprocessed454Params,
28-
ProcessedSortmernaParams)
29-
from .sql_connection import SQLConnectionHandler
3031

3132
SUPPORTED_PARAMS = ['preprocessed_sequence_illumina_params',
3233
'preprocessed_sequence_454_params',
@@ -51,7 +52,10 @@ def load_study_from_cmd(owner, title, info):
5152
config.readfp(info)
5253

5354
optional = dict(config.items('optional'))
54-
get_optional = lambda name: optional.get(name, None)
55+
56+
def get_optional(name):
57+
return optional.get(name, None)
58+
5559
get_required = partial(config.get, 'required')
5660
required_fields = ['timeseries_type_id', 'mixs_compliant',
5761
'portal_type_id', 'reprocess', 'study_alias',

qiita_db/environment_manager.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
#
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
8+
9+
from qiita_core.exceptions import QiitaEnvironmentError
10+
from qiita_core.qiita_settings import qiita_config
11+
from .sql_connection import SQLConnectionHandler
12+
from .reference import Reference
13+
from natsort import natsorted
14+
15+
from qiita_db.ontology import Ontology
16+
from qiita_db.util import convert_to_id
817
from os.path import abspath, dirname, join, exists, basename, splitext
918
from functools import partial
1019
from os import mkdir
@@ -15,14 +24,7 @@
1524
from future.utils import viewitems
1625
with standard_library.hooks():
1726
from urllib.request import urlretrieve
18-
from natsort import natsorted
1927

20-
from qiita_core.exceptions import QiitaEnvironmentError
21-
from qiita_core.qiita_settings import qiita_config
22-
from .sql_connection import SQLConnectionHandler
23-
from .reference import Reference
24-
from qiita_db.ontology import Ontology
25-
from qiita_db.util import convert_to_id
2628

2729
get_support_file = partial(join, join(dirname(abspath(__file__)),
2830
'support_files'))

qiita_db/metadata_template.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,13 @@ def __getitem__(self, key):
388388
if key in self._get_categories(conn_handler):
389389
# It's possible that the key is asking for one of the *_id columns
390390
# that we have to do the translation
391-
handler = lambda x: x
391+
def handler(x):
392+
return x
393+
394+
# prevent flake8 from complaining about the function not being
395+
# used and a redefinition happening in the next few lines
396+
handler(None)
397+
392398
if key in self._md_template.translate_cols_dict.values():
393399
handler = (
394400
lambda x: self._md_template.str_cols_handlers[key][x])

qiita_db/test/test_commands.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
88

9-
from os import remove, close, mkdir
10-
from os.path import exists, join, basename
11-
from tempfile import mkstemp, mkdtemp
12-
from shutil import rmtree
13-
from unittest import TestCase, main
14-
from future.utils.six import StringIO
15-
from future import standard_library
16-
from functools import partial
17-
with standard_library.hooks():
18-
import configparser
19-
209
from qiita_db.commands import (load_study_from_cmd, load_raw_data_cmd,
2110
load_sample_template_from_cmd,
2211
load_prep_template_from_cmd,
@@ -33,6 +22,17 @@
3322
from qiita_core.util import qiita_test_checker
3423
from qiita_ware.processing_pipeline import generate_demux_file
3524

25+
from os import remove, close, mkdir
26+
from os.path import exists, join, basename
27+
from tempfile import mkstemp, mkdtemp
28+
from shutil import rmtree
29+
from unittest import TestCase, main
30+
from future.utils.six import StringIO
31+
from future import standard_library
32+
from functools import partial
33+
with standard_library.hooks():
34+
import configparser
35+
3636

3737
@qiita_test_checker()
3838
class TestMakeStudyFromCmd(TestCase):

qiita_db/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,9 @@ def insert_filepaths(filepaths, obj_id, table, filepath_table, conn_handler,
661661
for old_fp, new_fp in zip(filepaths, new_filepaths):
662662
move(old_fp[0], new_fp[0])
663663

664-
str_to_id = lambda x: (x if isinstance(x, (int, long))
665-
else convert_to_id(x, "filepath_type",
666-
conn_handler))
664+
def str_to_id(x):
665+
return (x if isinstance(x, (int, long))
666+
else convert_to_id(x, "filepath_type", conn_handler))
667667
paths_w_checksum = [(relpath(path, base_fp), str_to_id(id),
668668
compute_checksum(path))
669669
for path, id in new_filepaths]

qiita_pet/handlers/compute.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def post(self):
5151
else:
5252
check_access(self.current_user, study, raise_error=True)
5353

54-
_split = lambda x: x.split(',') if x else []
54+
def _split(x):
55+
return x.split(',') if x else []
5556
filepaths, fps = [], []
5657
fps.append((_split(barcodes_str), 'raw_barcodes'))
5758
fps.append((_split(fasta_str), 'raw_fasta'))

qiita_pet/handlers/study_handlers/description_handlers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ def display_template(self, study, user, msg, msg_level, top_tab=None,
523523

524524
# set variable holding if we have all prep templates or not
525525
if available_prep_templates:
526-
_test = lambda item: not item
526+
def _test(item):
527+
return not item
527528
prep_templates = all(
528529
[_test(val) for val in viewvalues(available_prep_templates)])
529530
else:

qiita_ware/wrapper.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
from __future__ import division
22

3-
__author__ = "Jose Antonio Navas Molina"
4-
__copyright__ = "Copyright 2011, The QIIME project"
5-
__credits__ = ["Jose Antonio Navas Molina"]
6-
__license__ = "BSD"
7-
__version__ = "1.8.0-dev"
8-
__maintainer__ = "Jose Navas Antonio Molina"
9-
# Taken from pull request #1616 in qiime, with permission from Jose
10-
# Permission was also given to release this code under the BSD licence
3+
from qiita_db.job import Job
114

125
from shutil import rmtree
136
from os import remove
@@ -17,7 +10,15 @@
1710
import networkx as nx
1811
from moi.job import system_call, submit, ctxs, ctx_default
1912

20-
from qiita_db.job import Job
13+
14+
__author__ = "Jose Antonio Navas Molina"
15+
__copyright__ = "Copyright 2011, The QIIME project"
16+
__credits__ = ["Jose Antonio Navas Molina"]
17+
__license__ = "BSD"
18+
__version__ = "1.8.0-dev"
19+
__maintainer__ = "Jose Navas Antonio Molina"
20+
# Taken from pull request #1616 in qiime, with permission from Jose
21+
# Permission was also given to release this code under the BSD licence
2122

2223

2324
def system_call_from_job(job_id, **kwargs):

0 commit comments

Comments
 (0)