Skip to content

Commit

Permalink
Drop support for retired Python 3.5
Browse files Browse the repository at this point in the history
Upgrade syntax using `pyupgrade --py36-plus` .

Manually drop several `six` imports.

Also:
- Remove broken pr_cache in scripts/bootstrap_history.py
- Fix broken prefix removal in lib/galaxy/tool_util/deps/mulled/mulled_build.py
  • Loading branch information
nsoranzo committed Oct 7, 2020
1 parent 57d6a38 commit 9d74bba
Show file tree
Hide file tree
Showing 622 changed files with 1,918 additions and 2,175 deletions.
38 changes: 19 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variables:
jobs:
get_code:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
# Replace standard code checkout with shallow clone to speed things up.
Expand Down Expand Up @@ -83,45 +83,45 @@ jobs:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo
py35_docstring:
py36_docstring:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
- *restore_repo_cache
- *install_tox
- run: tox -e py35-lint_docstring_include_list
py35_lint:
- run: tox -e py36-lint_docstring_include_list
py36_lint:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
- *restore_repo_cache
- *install_tox
- run: tox -e py35-lint
py35_unit:
- run: tox -e py36-lint
py36_unit:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
- *restore_repo_cache
- *install_tox
- *install_ffprobe
- run: tox -e py35-unit
py35_first_startup:
- run: tox -e py36-unit
py36_first_startup:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
- *restore_repo_cache
# Use this job to test the latest migrations
- run: wget -q https://github.com/jmchilton/galaxy-downloads/raw/master/db_gx_rev_0141.sqlite
- run: mv db_gx_rev_0141.sqlite database/universe.sqlite
- *install_tox
- run: tox -e py35-first_startup
- run: tox -e py36-first_startup
validate_test_tools:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
- *restore_repo_cache
Expand All @@ -131,7 +131,7 @@ jobs:
- run: tox -e validate_test_tools
test_galaxy_packages:
docker:
- image: circleci/python:3.5
- image: circleci/python:3.6
<<: *set_workdir
steps:
- *restore_repo_cache
Expand Down Expand Up @@ -167,13 +167,13 @@ workflows:
get_code_and_test:
jobs:
- get_code
- py35_docstring:
- py36_docstring:
<<: *requires_get_code
- py35_lint:
- py36_lint:
<<: *requires_get_code
- py35_unit:
- py36_unit:
<<: *requires_get_code
- py35_first_startup:
- py36_first_startup:
<<: *requires_get_code
- test_galaxy_packages:
<<: *requires_get_code
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Community support is available at `Galaxy Help <https://help.galaxyproject.org/>
Galaxy Quickstart
=================

Galaxy requires Python 3.5 or 3.6 . To check your Python version, run:
Galaxy requires Python 3.6 . To check your Python version, run:

.. code:: console
Expand Down
1 change: 0 additions & 1 deletion client/src/assets/images/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
usage: %prog width height bg_color hatch_color [color alpha stop_pos] +
"""
from __future__ import division

import sys
from math import pi
Expand Down
8 changes: 4 additions & 4 deletions config/plugins/webhooks/demo/tour_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
log = logging.getLogger(__name__)


class TourGenerator(object):
class TourGenerator:
def __init__(self, trans, tool_id, tool_version):
self._trans = trans
self._tool = self._trans.app.toolbox.get_tool(tool_id, tool_version)
Expand Down Expand Up @@ -177,14 +177,14 @@ def _generate_tour(self):
if name in test_inputs:
hid = self._hids[name]
dataset = self._test.inputs[name][0]
step['content'] = 'Select dataset: <b>%s: %s</b>' % (
step['content'] = 'Select dataset: <b>{}: {}</b>'.format(
hid, dataset
)
else:
step['content'] = 'Select a dataset'

elif input.type == 'conditional':
param_id = '%s|%s' % (input.name, input.test_param.name)
param_id = f'{input.name}|{input.test_param.name}'
step['title'] = input.test_param.label
step['element'] = '[tour_id="%s"]' % param_id
params = []
Expand All @@ -203,7 +203,7 @@ def _generate_tour(self):
cases[key] = value.label

for case_id, case_title in cases.items():
tour_id = '%s|%s' % (input.name, case_id)
tour_id = f'{input.name}|{case_id}'
if tour_id in self._test.inputs.keys():
if case_id in self._data_inputs.keys():
hid = self._hids[case_id]
Expand Down
14 changes: 6 additions & 8 deletions contrib/galaxy_config_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
Script for merging specific local Galaxy config galaxy.ini.cri with default Galaxy galaxy.ini.sample
'''
from __future__ import print_function

import configparser
import logging
import optparse
import sys

from six.moves import configparser


def main():
# logging configuration
Expand All @@ -51,12 +49,12 @@ def main():

config_sample = configparser.RawConfigParser()
config_sample.read(options.sample)
config_sample_content = open(options.sample, 'r').read()
config_sample_content = open(options.sample).read()

config = configparser.RawConfigParser()
config.read(options.config)

logging.info("Merging your own config file %s into the sample one %s." % (options.config, options.sample))
logging.info(f"Merging your own config file {options.config} into the sample one {options.sample}.")
logging.info("---------- DIFFERENCE ANALYSIS BEGIN ----------")
for section in config.sections():
if not config_sample.has_section(section):
Expand All @@ -65,13 +63,13 @@ def main():
for (name, value) in config.items(section):
if not config_sample.has_option(section, name):
if not "#%s" % name in config_sample_content:
logging.warning("-MISSING- section [%s] option '%s' not found in sample file. It will be ignored." % (section, name))
logging.warning(f"-MISSING- section [{section}] option '{name}' not found in sample file. It will be ignored.")
else:
logging.info("-notset- section [%s] option '%s' not set in sample file. It will be added." % (section, name))
logging.info(f"-notset- section [{section}] option '{name}' not set in sample file. It will be added.")
config_sample.set(section, name, value)
else:
if not config_sample.get(section, name) == value:
logging.info("- diff - section [%s] option '%s' has different value ('%s':'%s'). It will be modified." % (section, name, config_sample.get(section, name), value))
logging.info("- diff - section [{}] option '{}' has different value ('{}':'{}'). It will be modified.".format(section, name, config_sample.get(section, name), value))
config_sample.set(section, name, value)
logging.info("---------- DIFFERENCE ANALYSIS END ----------")

Expand Down
20 changes: 9 additions & 11 deletions contrib/nagios/check_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
check_galaxy can be run by hand, although it is meant to run from cron
via the check_galaxy.sh script in Galaxy's cron/ directory.
"""
from __future__ import print_function

import formatter
import getopt
Expand All @@ -14,13 +13,12 @@
import sys
import time
import warnings
from user import home

from six.moves.urllib.request import (
from urllib.request import (
build_opener,
HTTPCookieProcessor,
Request
Request,
)
from user import home

with warnings.catch_warnings():
warnings.simplefilter('ignore')
Expand Down Expand Up @@ -52,7 +50,7 @@ def usage():
warntime = 240

new_history = False
for o, a in opts:
for o, _ in opts:
if o == "-n":
if debug:
print("Specified -n, will create a new history")
Expand All @@ -73,7 +71,7 @@ def usage():
tc.config('use_tidy', 0)


class Browser(object):
class Browser:
def __init__(self):
self.server = server
self.handler = handler
Expand All @@ -93,7 +91,7 @@ def __init__(self):
self.opener = build_opener(HTTPCookieProcessor(tc.get_browser().cj))

def get(self, path):
tc.go("%s%s" % (self.server, path))
tc.go(f"{self.server}{path}")
tc.code(200)

def req(self, path, data=None, method=None):
Expand All @@ -105,7 +103,7 @@ def req(self, path, data=None, method=None):
if method:
req.get_method = lambda: method
res = self.opener.open(req)
print('==> at %s (%s)' % (url, method or 'GET'))
print('==> at {} ({})'.format(url, method or 'GET'))
assert res.getcode() == 200, url
return res

Expand Down Expand Up @@ -226,7 +224,7 @@ def check_state(self):
if self.hda_state != "ok":
self.get("/datasets/%s/stderr" % self.hda_id)
print(tc.browser.get_html())
raise Exception("HDA %s NOT OK: %s" % (self.hda_id, self.hda_state))
raise Exception(f"HDA {self.hda_id} NOT OK: {self.hda_state}")

def check_hda_content(self):
self.get("/datasets/%s/display?to_ext=txt" % self.hda_id)
Expand All @@ -240,7 +238,7 @@ def check_hda_content(self):

def delete_datasets(self):
for hda in self.undeleted_hdas:
path = '/api/histories/%s/contents/%s' % (self.history_id, hda['id'])
path = '/api/histories/{}/contents/{}'.format(self.history_id, hda['id'])
self.req(path, method='DELETE')
hdas = [hda['id'] for hda in self.undeleted_hdas]
if hdas:
Expand Down
1 change: 0 additions & 1 deletion cron/add_manual_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Usage:
python add_manual_builds.py input_file builds.txt chrom_length_dir
"""
from __future__ import print_function

import os
import sys
Expand Down
5 changes: 2 additions & 3 deletions cron/build_chrom_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
Usage:
python build_chrom_db.py dbpath/ [builds_file]
"""
from __future__ import print_function

import fileinput
import os
import sys
from urllib.parse import urlencode

import requests
from six.moves.urllib.parse import urlencode

import parse_builds # noqa: I100,I202

Expand Down Expand Up @@ -78,5 +77,5 @@ def getchrominfo(url, db):
for chrominfo in getchrominfo("http://genome-test.gi.ucsc.edu/cgi-bin/hgTables?", build):
print("\t".join(chrominfo), file=outfile)
except Exception as e:
print("Failed to retrieve %s: %s" % (build, e))
print(f"Failed to retrieve {build}: {e}")
os.remove(outfile_name)
1 change: 0 additions & 1 deletion cron/parse_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
DSN in tabular format. UCSC Main gateway is used as default.
build description
"""
from __future__ import print_function

import sys
import xml.etree.ElementTree as ElementTree
Expand Down
1 change: 0 additions & 1 deletion cron/parse_builds_3_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Connects to sites and determines which builds are available at each.
"""
from __future__ import print_function

import xml.etree.ElementTree as ElementTree

Expand Down
16 changes: 7 additions & 9 deletions doc/parse_gx_xsd.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# coding: utf-8
# TODO: Add examples, tables and best practice links to command
# TODO: Examples of truevalue, falsevalue
# TODO: Test param extra_file
# Things dropped from schema_template.md (still documented inside schema).
# - request_parameter_translation
from __future__ import print_function

import sys
from io import StringIO

from lxml import etree
from six import StringIO

with open(sys.argv[2], "r") as f:
with open(sys.argv[2]) as f:
xmlschema_doc = etree.parse(f)

markdown_buffer = StringIO()
Expand All @@ -22,7 +20,7 @@ def main():
toc_list = []
content_list = []
found_tag = False
with open(sys.argv[1], "r") as markdown_template:
with open(sys.argv[1]) as markdown_template:
for line in markdown_template:
if line.startswith("$tag:"):
found_tag = True
Expand All @@ -41,7 +39,7 @@ def main():
print(el, end='')


class Tag(object):
class Tag:

def __init__(self, line):
assert line.startswith("$tag:")
Expand Down Expand Up @@ -71,7 +69,7 @@ def _pretty_title(self):
return " > ".join("``%s``" % p for p in self.title.split("|"))

def build_toc_entry(self):
return "* [%s](%s)" % (self._pretty_title, self._anchor)
return f"* [{self._pretty_title}]({self._anchor})"

def build_help(self):
tag = xmlschema_doc.find(self.xpath)
Expand Down Expand Up @@ -113,7 +111,7 @@ def _build_tag(tag, hide_attributes):
doc = _doc_or_none(_type_el(element))
assert doc is not None, "Documentation for %s is empty" % element.attrib["name"]
doc = doc.strip()
assertions_buffer.write("``%s`` | %s\n" % (element.attrib["name"], doc))
assertions_buffer.write("``{}`` | {}\n".format(element.attrib["name"], doc))
text = text.replace(line, assertions_buffer.getvalue())
tag_help.write(text)
best_practices = _get_bp_link(annotation_el)
Expand Down Expand Up @@ -165,7 +163,7 @@ def _build_attributes_table(tag, attributes, hide_attributes=False, attribute_na
if best_practices:
details += """ Find the Intergalactic Utilities Commision suggested best practices for this element [here](%s).""" % best_practices

attribute_table.write("``%s`` | %s | %s\n" % (name, details, use))
attribute_table.write(f"``{name}`` | {details} | {use}\n")
return attribute_table.getvalue()


Expand Down
Loading

0 comments on commit 9d74bba

Please sign in to comment.