mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-11-29 04:17:00 +08:00
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.
64 lines
1.8 KiB
Python
64 lines
1.8 KiB
Python
import logging
|
|
from typing import (
|
|
Any,
|
|
)
|
|
|
|
import pytest
|
|
|
|
from galaxy.tool_util.verify.test_data import TestDataResolver
|
|
from galaxy.util.unittest import TestCase
|
|
from galaxy_test.base.env import (
|
|
GalaxyTarget,
|
|
setup_keep_outdir,
|
|
target_url_parts,
|
|
)
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def host_port_and_url(test_driver: Any | None) -> GalaxyTarget:
|
|
host, port, url = target_url_parts()
|
|
server_wrapper = test_driver and test_driver.server_wrappers and test_driver.server_wrappers[0]
|
|
if server_wrapper:
|
|
host = server_wrapper.host
|
|
port = server_wrapper.port
|
|
url = f"http://{host}:{port}{server_wrapper.prefix.rstrip('/')}/"
|
|
return host, port, url
|
|
|
|
|
|
@pytest.mark.usefixtures("embedded_driver")
|
|
class FunctionalTestCase(TestCase):
|
|
"""Base class for tests targetting actual Galaxy servers.
|
|
|
|
Subclass should override galaxy_driver_class if a Galaxy server
|
|
needs to be launched to run the test, this base class assumes a
|
|
server is already running.
|
|
"""
|
|
|
|
galaxy_driver_class: type | None = None
|
|
host: str
|
|
port: str | None
|
|
url: str
|
|
keepOutdir: str
|
|
test_data_resolver: TestDataResolver
|
|
_test_driver: Any | None
|
|
|
|
def setUp(self) -> None:
|
|
self.host, self.port, self.url = host_port_and_url(self._test_driver)
|
|
self.test_data_resolver = TestDataResolver()
|
|
self.keepOutdir = setup_keep_outdir()
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
"""Configure and start Galaxy for a test."""
|
|
pass
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
"""Shutdown Galaxy server and cleanup temp directory."""
|
|
pass
|
|
|
|
def get_filename(self, filename: str) -> str:
|
|
# No longer used by tool tests - drop if isn't used else where.
|
|
return self.test_data_resolver.get_filename(filename)
|