mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #13002 from nsoranzo/unnecessary_lists
This commit is contained in:
@@ -265,7 +265,7 @@ class CustosAuthnz(IdentityProvider):
|
||||
|
||||
def _load_config_for_custos(self):
|
||||
self.config['well_known_oidc_config_uri'] = self._get_well_known_uri_from_url(self.config['provider'])
|
||||
self.config['credential_url'] = '/'.join([self.config['url'].rstrip('/'), 'credentials'])
|
||||
self.config['credential_url'] = f"{self.config['url'].rstrip('/')}/credentials"
|
||||
self._get_custos_credentials()
|
||||
# Set custos endpoints
|
||||
clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}"
|
||||
|
||||
@@ -2539,11 +2539,11 @@ class RDS(CompressedArchive):
|
||||
version = header_bytes[2:6]
|
||||
rversion = header_bytes[6:10]
|
||||
minrversion = header_bytes[10:14]
|
||||
version = int("".join([str(_) for _ in version]))
|
||||
version = int("".join(str(_) for _ in version))
|
||||
if version not in [2, 3]:
|
||||
raise Exception()
|
||||
rversion = int("".join([str(_) for _ in rversion]))
|
||||
minrversion = int("".join([str(_) for _ in minrversion]))
|
||||
rversion = int("".join(str(_) for _ in rversion))
|
||||
minrversion = int("".join(str(_) for _ in minrversion))
|
||||
version = ".".join(str(version))
|
||||
rversion = ".".join(str(rversion))
|
||||
minrversion = ".".join(str(minrversion))
|
||||
|
||||
@@ -121,7 +121,7 @@ class RegexLineDataProvider(FilteredLineDataProvider):
|
||||
return line
|
||||
|
||||
def filter_by_regex(self, line):
|
||||
matches = any([regex.match(line) for regex in self.compiled_regex_list])
|
||||
matches = any(regex.match(line) for regex in self.compiled_regex_list)
|
||||
if self.invert:
|
||||
return line if not matches else None
|
||||
return line if matches else None
|
||||
|
||||
@@ -921,7 +921,7 @@ class GenotypeMatrix(LinkageStudies):
|
||||
return False
|
||||
|
||||
try:
|
||||
return all([int(sid) > 0 for sid in header_elems[1:]])
|
||||
return all(int(sid) > 0 for sid in header_elems[1:])
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ class AGPFile:
|
||||
@property
|
||||
def num_lines(self):
|
||||
""" Calculate the number of lines in the current state of the AGP file. """
|
||||
return sum([len(self._comment_lines)] + [obj.num_lines for obj in self._objects])
|
||||
return len(self._comment_lines) + sum(obj.num_lines for obj in self._objects)
|
||||
|
||||
def iterate_objs(self):
|
||||
""" Iterate over the objects of the AGP file. """
|
||||
@@ -238,7 +238,7 @@ class AGPObject:
|
||||
self.add_line(in_agp_line)
|
||||
|
||||
def __str__(self):
|
||||
return "\n".join([str(i) for i in self._agp_lines])
|
||||
return "\n".join(str(i) for i in self._agp_lines)
|
||||
|
||||
def __repr__(self):
|
||||
return f"AGP Object: {self.obj}"
|
||||
|
||||
@@ -652,7 +652,7 @@ class PulsarJobRunner(AsynchronousJobRunner):
|
||||
# Following check is a hack for jobs started during 19.01 or earlier release
|
||||
# and finishing with a 19.05 code base. Eliminate the hack in 19.09 or later
|
||||
# along with hacks for legacy metadata compute strategy.
|
||||
if not os.path.exists(job_metrics_directory) or not any(["__instrument" in f for f in os.listdir(job_metrics_directory)]):
|
||||
if not os.path.exists(job_metrics_directory) or not any("__instrument" in f for f in os.listdir(job_metrics_directory)):
|
||||
job_metrics_directory = job_wrapper.working_directory
|
||||
job_wrapper.finish(
|
||||
stdout,
|
||||
|
||||
@@ -86,7 +86,7 @@ def job_script(template=DEFAULT_JOB_FILE_TEMPLATE, **kwds):
|
||||
>>> script.find('GALAXY_MEMORY_MB="32768"\\n') > 0
|
||||
True
|
||||
"""
|
||||
if any([param not in kwds for param in REQUIRED_TEMPLATE_PARAMS]):
|
||||
if any(param not in kwds for param in REQUIRED_TEMPLATE_PARAMS):
|
||||
raise Exception("Failed to create job_script, a required parameter is missing.")
|
||||
job_instrumenter = kwds.get("job_instrumenter", None)
|
||||
if job_instrumenter:
|
||||
|
||||
@@ -365,7 +365,7 @@ class NavigatesGalaxy(HasDriver):
|
||||
|
||||
def history_has_hid(driver):
|
||||
hids = get_hids()
|
||||
return any([h == hid for h in hids])
|
||||
return any(h == hid for h in hids)
|
||||
|
||||
timeout = self.timeout_for(wait_type=WAIT_TYPES.JOB_COMPLETION)
|
||||
try:
|
||||
@@ -1698,7 +1698,7 @@ class NavigatesGalaxy(HasDriver):
|
||||
if contains is not None:
|
||||
|
||||
if type(element) == list:
|
||||
assert any([contains in el.text for el in element]), \
|
||||
assert any(contains in el.text for el in element), \
|
||||
f"{contains} was not found in {[el.text for el in element]}"
|
||||
return
|
||||
|
||||
|
||||
@@ -133,9 +133,9 @@ def lint_inputs(tool_xml, lint_ctx):
|
||||
lint_ctx.error(f"Select parameter [{param_name}] contains multiple options elements")
|
||||
|
||||
# lint statically defined options
|
||||
if any(['value' not in option.attrib for option in select_options]):
|
||||
if any('value' not in option.attrib for option in select_options):
|
||||
lint_ctx.error(f"Select parameter [{param_name}] has option without value")
|
||||
if any([option.text is None for option in select_options]):
|
||||
if any(option.text is None for option in select_options):
|
||||
lint_ctx.warn(f"Select parameter [{param_name}] has option without text")
|
||||
if len(set(select_options_text)) != len(select_options_text):
|
||||
lint_ctx.error(f"Select parameter [{param_name}] has multiple options with the same text content")
|
||||
@@ -225,7 +225,7 @@ def lint_inputs(tool_xml, lint_ctx):
|
||||
|
||||
if datasource:
|
||||
for datasource_tag in ('display', 'uihints'):
|
||||
if not any([param.tag == datasource_tag for param in inputs]):
|
||||
if not any(param.tag == datasource_tag for param in inputs):
|
||||
lint_ctx.info(f"{datasource_tag} tag usually present in data sources")
|
||||
|
||||
if num_inputs:
|
||||
|
||||
@@ -567,7 +567,7 @@ class DatasetListWrapper(
|
||||
if not self._dataset_elements_cache.get(group):
|
||||
wrappers = []
|
||||
for element in self:
|
||||
if any([t for t in element.tags if t.user_tname.lower() == 'group' and t.value.lower() == group]):
|
||||
if any(t for t in element.tags if t.user_tname.lower() == 'group' and t.value.lower() == group):
|
||||
wrappers.append(element)
|
||||
self._dataset_elements_cache[group] = wrappers
|
||||
return self._dataset_elements_cache[group]
|
||||
@@ -652,7 +652,7 @@ class DatasetCollectionWrapper(ToolParameterValueWrapper, HasDatasets):
|
||||
if not self._dataset_elements_cache.get(group):
|
||||
wrappers = []
|
||||
for element in self.collection.dataset_elements:
|
||||
if any([t for t in element.dataset_instance.tags if t.user_tname.lower() == 'group' and t.value.lower() == group]):
|
||||
if any(t for t in element.dataset_instance.tags if t.user_tname.lower() == 'group' and t.value.lower() == group):
|
||||
wrappers.append(self._dataset_wrapper(element.element_object, identifier=element.element_identifier, **self.kwargs))
|
||||
self._dataset_elements_cache[group] = wrappers
|
||||
return self._dataset_elements_cache[group]
|
||||
|
||||
@@ -172,10 +172,10 @@ class RemoteUser:
|
||||
# requests.
|
||||
pass
|
||||
elif environ[self.remote_user_header] in self.admin_users and \
|
||||
any([path_info.startswith(prefix) for prefix in admin_accessible_paths]):
|
||||
any(path_info.startswith(prefix) for prefix in admin_accessible_paths):
|
||||
# If the user is an admin user, and any of the admin accessible paths match..., allow them to execute that action.
|
||||
pass
|
||||
elif any([path_info.startswith(prefix) for prefix in user_accessible_paths]):
|
||||
elif any(path_info.startswith(prefix) for prefix in user_accessible_paths):
|
||||
# If the user is allowed to access the path, pass
|
||||
pass
|
||||
elif path_info == '/user' or path_info == '/user/':
|
||||
|
||||
@@ -180,7 +180,7 @@ class ApplicationStack:
|
||||
return {}
|
||||
|
||||
def has_base_pool(self, pool_name):
|
||||
return self.has_pool(pool_name) or any([pool.startswith(f"{pool_name}.") for pool in self.configured_pools])
|
||||
return self.has_pool(pool_name) or any(pool.startswith(f"{pool_name}.") for pool in self.configured_pools)
|
||||
|
||||
def has_pool(self, pool_name):
|
||||
return pool_name in self.configured_pools
|
||||
|
||||
@@ -124,7 +124,7 @@ class ConfiguresHandlers:
|
||||
method = method.lower()
|
||||
assert HANDLER_ASSIGNMENT_METHODS.has_value(method), \
|
||||
"Invalid job handler assignment method '{}', must be one of: {}".format(
|
||||
method, ', '.join([h.value for h in HANDLER_ASSIGNMENT_METHODS]))
|
||||
method, ', '.join(h.value for h in HANDLER_ASSIGNMENT_METHODS))
|
||||
try:
|
||||
self.handler_assignment_methods.append(method)
|
||||
except AttributeError:
|
||||
|
||||
@@ -443,7 +443,7 @@ class DatasetCollectionApiTestCase(ApiTestCase):
|
||||
actual: List[str] = []
|
||||
for converter in converters.json():
|
||||
actual.append(converter["tool_id"])
|
||||
assert sorted(actual) == sorted([])
|
||||
assert actual == []
|
||||
|
||||
def test_collection_tools_tag_propagation(self):
|
||||
elements = [{"src": "files", "tags": ["name:element_tag"]}]
|
||||
|
||||
@@ -739,19 +739,19 @@ class BaseDatasetPopulator(BasePopulator):
|
||||
def get_history_dataset_source_transform_actions(self, history_id: str, **kwd) -> Set[str]:
|
||||
details = self.get_history_dataset_details(history_id, **kwd)
|
||||
if "sources" not in details:
|
||||
return set([])
|
||||
return set()
|
||||
sources = details["sources"]
|
||||
assert len(sources) <= 1 # We don't handle this use case yet.
|
||||
if len(sources) == 0:
|
||||
return set([])
|
||||
return set()
|
||||
|
||||
source_0 = sources[0]
|
||||
assert "transform" in source_0
|
||||
transform = source_0["transform"]
|
||||
if transform is None:
|
||||
return set([])
|
||||
return set()
|
||||
assert isinstance(transform, list)
|
||||
return set([t["action"] for t in transform])
|
||||
return {t["action"] for t in transform}
|
||||
|
||||
def get_history_dataset_details(self, history_id: str, **kwds) -> dict:
|
||||
dataset_id = self.__history_content_id(history_id, **kwds)
|
||||
|
||||
@@ -163,7 +163,7 @@ class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions):
|
||||
tbody_element = tool_parameters_table.find_element_by_css_selector("tbody")
|
||||
tds = tbody_element.find_elements_by_css_selector("td")
|
||||
assert tds
|
||||
assert any([expected_value in td.text for td in tds])
|
||||
assert any(expected_value in td.text for td in tds)
|
||||
|
||||
def _run_environment_test_tool(self, inttest_value="42"):
|
||||
self.home()
|
||||
|
||||
@@ -360,7 +360,7 @@ def main():
|
||||
raise Exception(f"No doc in test [{test_with_doc}]")
|
||||
del test_with_doc["doc"]
|
||||
cwl_test_def = yaml.dump(test_with_doc, default_flow_style=False)
|
||||
cwl_test_def = "\n".join([f" {line}" for line in cwl_test_def.splitlines()])
|
||||
cwl_test_def = "\n".join(f" {line}" for line in cwl_test_def.splitlines())
|
||||
label = conformance_test.get("label", str(i))
|
||||
tags = conformance_test.get("tags", [])
|
||||
is_red = label in red_tests_list
|
||||
|
||||
@@ -257,7 +257,7 @@ def get_irods_resource(conn, objectid, object_store_id, irods_info):
|
||||
irods_tape_resc_cuttoff_dt = datetime.strptime(irods_tape_resc_cuttoff, "%m/%d/%Y")
|
||||
|
||||
read_cursor = conn.cursor()
|
||||
args = ('ok', objectid, objectid, tuple([object_store_id]), 'ok', objectid, objectid, tuple([object_store_id]))
|
||||
args = ('ok', objectid, objectid, (object_store_id, ), 'ok', objectid, objectid, (object_store_id, ))
|
||||
read_cursor.execute(last_accessed_sql_statement, args)
|
||||
row = read_cursor.fetchone()
|
||||
if row is None:
|
||||
|
||||
@@ -93,7 +93,7 @@ class CondaResolutionIntegrationTestCase(integration_util.IntegrationTestCase):
|
||||
create_response = self._post(endpoint, data=data, admin=True)
|
||||
self._assert_status_code_is(create_response, 200)
|
||||
response = create_response.json()
|
||||
assert any([True for d in response if d['dependency_type'] == 'conda'])
|
||||
assert any(True for d in response if d['dependency_type'] == 'conda')
|
||||
endpoint = "tools/%s/build_dependency_cache" % tool_id
|
||||
create_response = self._post(endpoint, data=data, admin=True)
|
||||
self._assert_status_code_is(create_response, 200)
|
||||
@@ -105,7 +105,7 @@ class CondaResolutionIntegrationTestCase(integration_util.IntegrationTestCase):
|
||||
create_response = self._post(endpoint, data=data, admin=True)
|
||||
self._assert_status_code_is(create_response, 200)
|
||||
response = create_response.json()
|
||||
assert any([True for d in response if d['dependency_type'] == 'conda'])
|
||||
assert any(True for d in response if d['dependency_type'] == 'conda')
|
||||
endpoint = "tools/%s/dependencies" % tool_id
|
||||
create_response = self._delete(endpoint, data=data, admin=True)
|
||||
self._assert_status_code_is(create_response, 200)
|
||||
@@ -131,7 +131,7 @@ class CondaResolutionIntegrationTestCase(integration_util.IntegrationTestCase):
|
||||
create_response = self._post(endpoint, data=data, admin=True)
|
||||
self._assert_status_code_is(create_response, 200)
|
||||
response = create_response.json()
|
||||
assert any([True for d in response if d['dependency_type'] == 'conda'])
|
||||
assert any(True for d in response if d['dependency_type'] == 'conda')
|
||||
# Now that we know install was successfullt we can also doube check that the uninstall works
|
||||
self._uninstall_mulled_example_multi_1(resolver_type='conda')
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ def main(argv=None):
|
||||
uuid = str(uuid4())
|
||||
workflow_struct = _workflow_struct(args, uuid)
|
||||
|
||||
has_input = any([s.get("type", "tool") == "input_collection" for s in workflow_struct])
|
||||
has_input = any(s.get("type", "tool") == "input_collection" for s in workflow_struct)
|
||||
if not has_input:
|
||||
uuid = None
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ class CustosAuthnzTestCase(unittest.TestCase):
|
||||
return 'https://iam.scigap.org/auth'
|
||||
|
||||
def _get_credential_url(self):
|
||||
return '/'.join([self._get_idp_url(), 'credentials'])
|
||||
return f"{self._get_idp_url()}/credentials"
|
||||
|
||||
def _get_well_known_url(self):
|
||||
return '/'.join([self._get_idp_url(), '.well-known/openid-configuration'])
|
||||
return f"{self._get_idp_url()}/.well-known/openid-configuration"
|
||||
|
||||
def setUp(self):
|
||||
self.orig_requests_get = requests.get
|
||||
|
||||
@@ -66,7 +66,7 @@ def test_get_env_shell_file_paths_from_setup_environment_elem():
|
||||
# Verify new ones added.
|
||||
assert r_env_sh in all_env_paths
|
||||
# env_shell_file_paths includes everything
|
||||
assert all([env in action_dict['env_shell_file_paths'] for env in all_env_paths])
|
||||
assert all(env in action_dict['env_shell_file_paths'] for env in all_env_paths)
|
||||
# for every given repository there should be one env
|
||||
# file + the required_for_install_env_sh file
|
||||
assert len(action_dict['env_shell_file_paths']) == 3
|
||||
|
||||
Reference in New Issue
Block a user