mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Drop support for Python 3.8
Drop Python 3.8 support in 5 Pulsar-compatible packages (job_metrics, tool_util, tool_util_models, util, objectstore) and run pyupgrade --py310-plus on their source code. - Bump requires-python from >=3.8 to >=3.10 in all 5 packages - Remove Python 3.8 and 3.9 classifiers - Remove ruff per-file-ignores for UP rules on these paths - Remove backports.zoneinfo conditional dependency - Remove pydyf<0.11 pin from conditional-requirements.txt - Update Makefile pyupgrade target (remove PY38_PYUPGRADE_PATHS) - Update CI workflow to test with Python 3.10 instead of 3.8 Clean up unused deprecated typing imports after pyupgrade Remove now-unused typing imports (Dict, List, Optional, Set, Tuple, Type, Union) that became dead after pyupgrade --py310-plus converted annotations to use built-in types and | syntax. Also run ruff check --fix --select=UP007,UP045 across the entire codebase to convert remaining Optional[X] -> X | None and Union[X, Y] -> X | Y patterns. Enable ruff UP007/UP045 for Python 3.10 union syntax Remove UP007 (Union[X,Y] -> X | Y) and UP045 (Optional[X] -> X | None) from the ruff ignore list and convert all type aliases across the codebase. These rules were deferred while Python 3.9 was supported; requires-python is now >=3.10. A custom script was used because neither ruff --fix nor pyupgrade --py310-plus converts Optional[X]/Union[X,Y] in type alias positions (e.g. X = Union[A, B]) — they only handle annotation positions (e.g. def f(x: Optional[int])). All 167 violations were module-level type aliases. A few edge cases were fixed manually: single-element Union[X,], typing.Union qualified refs, runtime Optional[type] calls, and Annotated[Optional[...]] pydantic fields. Fix UP007 autofix regression with string forward reference type aliases Commit fa6bd955a0 enabled ruff UP007/UP045 and auto-fixed module-level type aliases using Union with string forward references, producing invalid 'str | str' expressions. This was a known ruff bug (charliermarsh/ruff#826) that has since been fixed in later ruff versions, but this codebase was converted before the fix was in place. Revert to Union syntax and restore TYPE_CHECKING imports that ruff's TCH rule cleaned up as a side effect when it thought the forward references were unused.
This commit is contained in:
@@ -12,7 +12,6 @@ import sys
|
||||
import tempfile
|
||||
from typing import (
|
||||
Any,
|
||||
Optional,
|
||||
)
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib")))
|
||||
@@ -104,8 +103,8 @@ class RemoteToolShedPopulator(ToolShedPopulator):
|
||||
for tests.
|
||||
"""
|
||||
|
||||
_categories_by_name: Optional[dict[str, Category]] = None
|
||||
_users_by_username: Optional[dict[str, dict[str, Any]]] = None
|
||||
_categories_by_name: dict[str, Category] | None = None
|
||||
_users_by_username: dict[str, dict[str, Any]] | None = None
|
||||
_populators_by_username: dict[str, "RemoteToolShedPopulator"] = {}
|
||||
|
||||
def __init__(self, admin_interactor: ShedApiInteractor, user_interactor: ShedApiInteractor):
|
||||
|
||||
@@ -28,7 +28,6 @@ from galaxy.model.orm.scripts import get_config
|
||||
from galaxy.objectstore import ObjectStore
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from galaxy.celery import tasks # noqa: F401
|
||||
|
||||
config = get_config(sys.argv)
|
||||
|
||||
@@ -3,8 +3,6 @@ If the current installed Python version is not supported, prints an error
|
||||
message to stderr and returns 1
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
MIN_VERSION_TUPLE = (3, 10)
|
||||
@@ -17,15 +15,12 @@ def check_python():
|
||||
else:
|
||||
version_string = ".".join(str(_) for _ in sys.version_info[:3])
|
||||
min_version_string = ".".join(str(_) for _ in MIN_VERSION_TUPLE)
|
||||
msg = """ERROR: Your Python version is: {}
|
||||
Galaxy is currently supported on Python >={} .
|
||||
msg = f"""ERROR: Your Python version is: {version_string}
|
||||
Galaxy is currently supported on Python >={min_version_string} .
|
||||
To run Galaxy, please install a supported Python version.
|
||||
If a supported version is already installed but is not your default,
|
||||
https://docs.galaxyproject.org/en/latest/admin/python.html contains instructions
|
||||
on how to force Galaxy to use a different version.""".format(
|
||||
version_string,
|
||||
min_version_string,
|
||||
)
|
||||
on how to force Galaxy to use a different version."""
|
||||
print(msg, file=sys.stderr)
|
||||
raise Exception(msg)
|
||||
|
||||
|
||||
@@ -296,8 +296,7 @@ def _get_tool_id_for_hda(app, hda_id):
|
||||
|
||||
job_query = select(Job.tool_id).join(JTODA).where(JTODA.dataset_id == hda_id)
|
||||
|
||||
tool_id = session.execute(job_query).scalars().first()
|
||||
if tool_id is not None:
|
||||
if (tool_id := session.execute(job_query).scalars().first()) is not None:
|
||||
return tool_id
|
||||
|
||||
hda = session.get(HistoryDatasetAssociation, hda_id)
|
||||
|
||||
@@ -16,7 +16,6 @@ import urllib.request
|
||||
from pathlib import Path
|
||||
from typing import (
|
||||
Any,
|
||||
Optional,
|
||||
)
|
||||
|
||||
import yaml
|
||||
@@ -82,7 +81,7 @@ def represent_quoted_string(dumper: yaml.Dumper, data: str) -> yaml.ScalarNode:
|
||||
QuotingDumper.add_representer(QuotedString, represent_quoted_string)
|
||||
|
||||
|
||||
def fetch_tools(api_url: Optional[str] = None, timeout: float = DEFAULT_TIMEOUT_SECONDS) -> list[dict[str, Any]]:
|
||||
def fetch_tools(api_url: str | None = None, timeout: float = DEFAULT_TIMEOUT_SECONDS) -> list[dict[str, Any]]:
|
||||
"""Fetch tools from a Galaxy `/api/tools` endpoint.
|
||||
|
||||
Raises ``RuntimeError`` on transport / HTTP / decoding failures so the caller
|
||||
@@ -274,7 +273,7 @@ def _build_arg_parser() -> argparse.ArgumentParser:
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: Optional[list[str]] = None) -> int:
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
args = _build_arg_parser().parse_args(argv)
|
||||
|
||||
global API_URL, OUTPUT_FILE
|
||||
|
||||
@@ -62,7 +62,7 @@ for guid in guid_mapping:
|
||||
tool_version = dm.find("./tool/version")
|
||||
tool_version = tool_version.text
|
||||
|
||||
new_guid = f"{guid[:guid.rfind('/')]}/{tool_version}"
|
||||
new_guid = f"{guid[: guid.rfind('/')]}/{tool_version}"
|
||||
dm.attrib["guid"] = new_guid
|
||||
print(f"changing guid: {guid} -> {new_guid}")
|
||||
if "version" in dm.attrib:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import configparser
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -29,7 +28,7 @@ def main():
|
||||
print(f"Warning section {entry.section_name} does not refer to existant files")
|
||||
|
||||
|
||||
def to_python_path(package_name: str) -> Optional[str]:
|
||||
def to_python_path(package_name: str) -> str | None:
|
||||
path = os.path.join("lib", package_name.replace(".", "/"))
|
||||
if os.path.exists(path + ".py"):
|
||||
path = f"{path}.py"
|
||||
|
||||
@@ -105,7 +105,9 @@ def report_diff(added, changed, removed, new_files):
|
||||
"Changed",
|
||||
"The following configuration options have been changed",
|
||||
changed,
|
||||
lambda x: f"- {x[0]} has changed from\n\n ::\n\n{_indent(x[1])}\n\n to\n\n ::\n\n{_indent(x[2])}\n\n",
|
||||
lambda x: (
|
||||
f"- {x[0]} has changed from\n\n ::\n\n{_indent(x[1])}\n\n to\n\n ::\n\n{_indent(x[2])}\n\n"
|
||||
),
|
||||
)
|
||||
|
||||
if removed:
|
||||
|
||||
Reference in New Issue
Block a user