diff --git a/lib/galaxy/actions/admin.py b/lib/galaxy/actions/admin.py index 6a54762b98e..1eb65a6b778 100644 --- a/lib/galaxy/actions/admin.py +++ b/lib/galaxy/actions/admin.py @@ -152,7 +152,7 @@ class AdminActions: if len(names) == 1: raise ActionInputError(f"Quota '{names[0]}' is a default, please unset it as a default before deleting it.") elif len(names) > 1: - raise ActionInputError("Quotas are defaults, please unset them as defaults before deleting them: " + ', '.join(names)) + raise ActionInputError(f"Quotas are defaults, please unset them as defaults before deleting them: {', '.join(names)}") message = "Deleted %d quotas: " % len(quotas) for q in quotas: q.deleted = True @@ -171,7 +171,7 @@ class AdminActions: if len(names) == 1: raise ActionInputError(f"Quota '{names[0]}' has not been deleted, so it cannot be undeleted.") elif len(names) > 1: - raise ActionInputError("Quotas have not been deleted so they cannot be undeleted: " + ', '.join(names)) + raise ActionInputError(f"Quotas have not been deleted so they cannot be undeleted: {', '.join(names)}") message = "Undeleted %d quotas: " % len(quotas) for q in quotas: q.deleted = False @@ -196,7 +196,7 @@ class AdminActions: if len(names) == 1: raise ActionInputError(f"Quota '{names[0]}' has not been deleted, so it cannot be purged.") elif len(names) > 1: - raise ActionInputError("Quotas have not been deleted so they cannot be undeleted: " + ', '.join(names)) + raise ActionInputError(f"Quotas have not been deleted so they cannot be undeleted: {', '.join(names)}") message = "Purged %d quotas: " % len(quotas) for q in quotas: # Delete UserQuotaAssociations diff --git a/lib/galaxy/authnz/custos_authnz.py b/lib/galaxy/authnz/custos_authnz.py index 4fa2fc5c4ea..33b035bbf50 100644 --- a/lib/galaxy/authnz/custos_authnz.py +++ b/lib/galaxy/authnz/custos_authnz.py @@ -114,7 +114,7 @@ class CustosAuthnz(IdentityProvider): log.exception(message) raise exceptions.AuthenticationFailed(message) else: - login_redirect_url = login_redirect_url + 'root/login?confirm=true&custos_token=' + json.dumps(token) + login_redirect_url = f"{login_redirect_url}root/login?confirm=true&custos_token={json.dumps(token)}" return login_redirect_url, None custos_authnz_token = CustosAuthnzToken(user=user, @@ -224,7 +224,7 @@ class CustosAuthnz(IdentityProvider): else: client_secret = self.config['client_secret'] token_endpoint = self.config['token_endpoint'] - clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] # for custos + clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}" # for custos return oauth2_session.fetch_token( token_endpoint, client_secret=client_secret, @@ -263,7 +263,7 @@ class CustosAuthnz(IdentityProvider): self.config['credential_url'] = '/'.join([self.config['url'].rstrip('/'), 'credentials']) self._get_custos_credentials() # Set custos endpoints - clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] + clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}" eps = requests.get(self.config['well_known_oidc_config_uri'], headers={"Authorization": f"Basic {util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}"}, verify=False, params={'client_id': self.config['client_id']}) @@ -276,7 +276,7 @@ class CustosAuthnz(IdentityProvider): self._load_well_known_oidc_config(well_known_oidc_config) def _get_custos_credentials(self): - clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] + clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}" creds = requests.get(self.config['credential_url'], headers={"Authorization": f"Basic {util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}"}, verify=False, params={'client_id': self.config['client_id']}) diff --git a/lib/galaxy/authnz/psa_authnz.py b/lib/galaxy/authnz/psa_authnz.py index f42dbe2b6cf..a8827168e1c 100644 --- a/lib/galaxy/authnz/psa_authnz.py +++ b/lib/galaxy/authnz/psa_authnz.py @@ -165,7 +165,7 @@ class PSAAuthnz(IdentityProvider): on_the_fly_config(trans.sa_session) self.config[setting_name('LOGIN_REDIRECT_URL')] = login_redirect_url strategy = Strategy(trans.request, trans.session, Storage, self.config) - strategy.session_set(BACKENDS_NAME[self.config['provider']] + '_state', state_token) + strategy.session_set(f"{BACKENDS_NAME[self.config['provider']]}_state", state_token) backend = self._load_backend(strategy, self.config['redirect_uri']) redirect_url = do_complete( backend, diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index 8d0dd87117f..25e714ff7d6 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -815,7 +815,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin): self.amqp_internal_connection = kwargs.get('amqp_internal_connection') # TODO Get extra amqp args as necessary for ssl elif 'database_connection' in kwargs: - self.amqp_internal_connection = "sqlalchemy+" + self.database_connection + self.amqp_internal_connection = f"sqlalchemy+{self.database_connection}" else: self.amqp_internal_connection = f"sqlalchemy+sqlite:///{self._in_data_dir('control.sqlite')}?isolation_level=IMMEDIATE" self.pretty_datetime_format = expand_pretty_datetime_format(self.pretty_datetime_format) diff --git a/lib/galaxy/containers/__init__.py b/lib/galaxy/containers/__init__.py index 97cf6e6cec1..5bf9a3c1a35 100644 --- a/lib/galaxy/containers/__init__.py +++ b/lib/galaxy/containers/__init__.py @@ -219,7 +219,7 @@ class ContainerInterface(metaclass=ABCMeta): } log.warning("option '%s' not in %s.option_map, guessing flag '%s' type '%s'", opt, self.__class__.__name__, optdef['flag'], optdef['type']) - opts.append(getattr(self, '_stringify_kwopt_' + optdef['type'])(optdef['flag'], val)) + opts.append(getattr(self, f"_stringify_kwopt_{optdef['type']}")(optdef['flag'], val)) return ' '.join(opts) def _stringify_kwopt_boolean(self, flag, val): @@ -272,7 +272,7 @@ class ContainerInterface(metaclass=ABCMeta): return stdout.strip() else: msg = f"Command '{command}' returned non-zero exit status {p.returncode}" - log.error(msg + ': ' + stderr.strip()) + log.error(f"{msg}: {stderr.strip()}") raise ContainerCLIError( msg, stdout=stdout.strip(), diff --git a/lib/galaxy/containers/docker.py b/lib/galaxy/containers/docker.py index aaf2c9cde4d..9a41889bcec 100644 --- a/lib/galaxy/containers/docker.py +++ b/lib/galaxy/containers/docker.py @@ -168,7 +168,7 @@ class DockerCLIInterface(DockerInterface): kwopt_list.append('{vol}:{bind}{mode}'.format( vol=hostvol, bind=guestopts['bind'], - mode=':' + mode if mode else '' + mode=f":{mode}" if mode else '' )) return self._stringify_kwopt_list(flag, kwopt_list) @@ -234,7 +234,7 @@ class DockerAPIClient: if isinstance(f, partial): f = f.func try: - return getattr(f, '__qualname__', f.im_class.__name__ + '.' + f.__name__) + return getattr(f, '__qualname__', f"{f.im_class.__name__}.{f.__name__}") except AttributeError: return f.__name__ @@ -489,7 +489,7 @@ class DockerAPIInterface(DockerInterface): # keyword arguments spec_kwopts = {} # retrieve the option map for the docker-py object we're creating - option_map = getattr(self, option_map_name + '_option_map') + option_map = getattr(self, f"{option_map_name}_option_map") # set defaults for key in filter(lambda k: option_map[k].get('default'), option_map.keys()): map_spec = option_map[key] diff --git a/lib/galaxy/containers/docker_model.py b/lib/galaxy/containers/docker_model.py index ebb62a016b9..7d368688f0f 100644 --- a/lib/galaxy/containers/docker_model.py +++ b/lib/galaxy/containers/docker_model.py @@ -24,8 +24,8 @@ from galaxy.util import ( CPUS_LABEL = '_galaxy_cpus' IMAGE_LABEL = '_galaxy_image' -CPUS_CONSTRAINT = 'node.labels.' + CPUS_LABEL -IMAGE_CONSTRAINT = 'node.labels.' + IMAGE_LABEL +CPUS_CONSTRAINT = f"node.labels.{CPUS_LABEL}" +IMAGE_CONSTRAINT = f"node.labels.{IMAGE_LABEL}" log = logging.getLogger(__name__) @@ -676,7 +676,7 @@ class DockerTask: service = service or interface.service(id=t.get('ServiceID')) node = node or interface.node(id=t.get('NodeID')) if service: - name = service.name + '.' + str(t['Slot']) + name = f"{service.name}.{str(t['Slot'])}" else: name = t['ID'] image = t['Spec']['ContainerSpec']['Image'].split('@', 1)[0], # remove pin diff --git a/lib/galaxy/containers/docker_swarm.py b/lib/galaxy/containers/docker_swarm.py index 8cc14768b0a..6ac26c547df 100644 --- a/lib/galaxy/containers/docker_swarm.py +++ b/lib/galaxy/containers/docker_swarm.py @@ -426,10 +426,10 @@ class DockerSwarmAPIInterface(DockerSwarmInterface, DockerAPIInterface): # service constraints kwopts['constraint'] = kwopts.get('constraint', []) if self._conf.service_create_image_constraint: - kwopts['constraint'].append(IMAGE_CONSTRAINT + '==' + image) + kwopts['constraint'].append(f"{IMAGE_CONSTRAINT}=={image}") if self._conf.service_create_cpus_constraint: cpus = kwopts.get('reserve_cpus', kwopts.get('limit_cpus', '1')) - kwopts['constraint'].append(CPUS_CONSTRAINT + '==' + cpus) + kwopts['constraint'].append(f"{CPUS_CONSTRAINT}=={cpus}") # ports if 'publish_port_random' in kwopts: kwopts['ports'] = [DockerSwarmAPIInterface.create_random_port_spec(kwopts.pop('publish_port_random'))] diff --git a/lib/galaxy/datatypes/assembly.py b/lib/galaxy/datatypes/assembly.py index d975251f5d4..b3be0ff1f9b 100644 --- a/lib/galaxy/datatypes/assembly.py +++ b/lib/galaxy/datatypes/assembly.py @@ -182,11 +182,11 @@ class Velvet(Html): dataset.metadata.short2_reads = short2_reads dataset.info = re.sub(r'.*velveth \S+', 'hash_length', re.sub(r'\n', ' ', log_msg)) if paired_end_reads: - gen_msg = gen_msg + ' Paired-End Reads' + gen_msg = f"{gen_msg} Paired-End Reads" if long_reads: - gen_msg = gen_msg + ' Long Reads' + gen_msg = f"{gen_msg} Long Reads" if len(gen_msg) > 0: - gen_msg = 'Uses: ' + gen_msg + gen_msg = f"Uses: {gen_msg}" except Exception: log.debug(f"Velveth could not read Log file in {efp}") log.debug(f"Velveth log info {gen_msg}") diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index 21329f8cdef..be2afb495ea 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -708,7 +708,7 @@ class CRAM(Binary): def set_meta(self, dataset, overwrite=True, **kwd): major_version, minor_version = self.get_cram_version(dataset.file_name) if major_version != -1: - dataset.metadata.cram_version = str(major_version) + "." + str(minor_version) + dataset.metadata.cram_version = f"{str(major_version)}.{str(minor_version)}" if not dataset.metadata.cram_index: index_file = dataset.metadata.spec['cram_index'].param.new_file(dataset=dataset) @@ -788,7 +788,7 @@ class Bcf(BaseBcf): try: cmd = ['python', '-c', f"import pysam.bcftools; pysam.bcftools.index('{dataset_symlink}')"] subprocess.check_call(cmd) - shutil.move(dataset_symlink + '.csi', index_file.file_name) + shutil.move(f"{dataset_symlink}.csi", index_file.file_name) except Exception as e: raise Exception(f'Error setting BCF metadata: {util.unicodify(e)}') finally: diff --git a/lib/galaxy/datatypes/converters/interval_to_fli.py b/lib/galaxy/datatypes/converters/interval_to_fli.py index 201a7d507d5..16dcf4f88d3 100644 --- a/lib/galaxy/datatypes/converters/interval_to_fli.py +++ b/lib/galaxy/datatypes/converters/interval_to_fli.py @@ -97,9 +97,9 @@ def main(): # Write padded entries. with open(out_fname, 'w') as out: - out.write(str(max_len + 1).ljust(max_len) + '\n') + out.write(f"{str(max_len + 1).ljust(max_len)}\n") for entry in entries: - out.write(entry.ljust(max_len) + '\n') + out.write(f"{entry.ljust(max_len)}\n") if __name__ == '__main__': diff --git a/lib/galaxy/datatypes/dataproviders/dataset.py b/lib/galaxy/datatypes/dataproviders/dataset.py index ccded5a6575..7d856ad847a 100644 --- a/lib/galaxy/datatypes/dataproviders/dataset.py +++ b/lib/galaxy/datatypes/dataproviders/dataset.py @@ -664,11 +664,11 @@ class SamtoolsDataProvider(line.RegexLineDataProvider): validated_flag_list.append('S') if validated_flag_list: - opt_list.append('-' + ''.join(validated_flag_list)) + opt_list.append(f"-{''.join(validated_flag_list)}") for flag, arg in options_dict.items(): if flag in self.FLAGS_W_ARGS: - opt_list.extend(['-' + flag, str(arg)]) + opt_list.extend([f"-{flag}", str(arg)]) return opt_list diff --git a/lib/galaxy/datatypes/dataproviders/external.py b/lib/galaxy/datatypes/dataproviders/external.py index 58790a5041d..7a3f9fb34f2 100644 --- a/lib/galaxy/datatypes/dataproviders/external.py +++ b/lib/galaxy/datatypes/dataproviders/external.py @@ -172,4 +172,4 @@ class TempfileDataProvider(base.DataProvider): parent_gen = super().__iter__() with open(self.tmp_file, 'w') as open_file: for datum in parent_gen: - open_file.write(datum + '\n') + open_file.write(f"{datum}\n") diff --git a/lib/galaxy/datatypes/genetics.py b/lib/galaxy/datatypes/genetics.py index 79742505f71..75c5281783b 100644 --- a/lib/galaxy/datatypes/genetics.py +++ b/lib/galaxy/datatypes/genetics.py @@ -102,7 +102,7 @@ class GenomeGraphs(Tabular): internal_url = "%s" % app.url_for(controller='dataset', dataset_id=dataset.id, action='display_at', - filename='ucsc_' + site_name) + filename=f"ucsc_{site_name}") display_url = "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" % (base_url, app.url_for(controller='root'), dataset.id, type) display_url = quote_plus(display_url) # was display_url = quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) ) diff --git a/lib/galaxy/datatypes/isa.py b/lib/galaxy/datatypes/isa.py index 1511023ca84..4afb5b14e99 100644 --- a/lib/galaxy/datatypes/isa.py +++ b/lib/galaxy/datatypes/isa.py @@ -288,7 +288,7 @@ class _Isa(data.Data): html += '