mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-11-06 00:12:05 +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.
92 lines
2.9 KiB
Python
92 lines
2.9 KiB
Python
"""Pytest-specific utility functions and decorators for selenium unit tests."""
|
|
|
|
from collections.abc import Callable
|
|
from typing import (
|
|
TypeVar,
|
|
)
|
|
|
|
import pytest
|
|
from typing_extensions import ParamSpec
|
|
|
|
from galaxy.selenium.availability import (
|
|
check_playwright_cached,
|
|
check_selenium_cached,
|
|
is_playwright_browser_available,
|
|
is_selenium_browser_available,
|
|
PLAYWRIGHT_BROWSER_NOT_AVAILABLE_MESSAGE,
|
|
SELENIUM_BROWSER_NOT_AVAILABLE_MESSAGE,
|
|
)
|
|
|
|
P = ParamSpec("P")
|
|
T = TypeVar("T")
|
|
|
|
|
|
def _identity(func: Callable[P, T]) -> Callable[P, T]:
|
|
"""Identity function that returns the input function unchanged."""
|
|
return func
|
|
|
|
|
|
def skip_unless_selenium_browser() -> Callable[[Callable[P, T]], Callable[P, T]] | pytest.MarkDecorator:
|
|
"""
|
|
Skip test if Selenium Chrome browser is not available.
|
|
|
|
Returns:
|
|
Either identity function (if browser available) or pytest skip marker with instructions
|
|
"""
|
|
if is_selenium_browser_available():
|
|
return _identity
|
|
return pytest.mark.skip(SELENIUM_BROWSER_NOT_AVAILABLE_MESSAGE)
|
|
|
|
|
|
def skip_unless_playwright_browser() -> Callable[[Callable[P, T]], Callable[P, T]] | pytest.MarkDecorator:
|
|
"""
|
|
Skip test if Playwright Chromium browser is not available.
|
|
|
|
Returns:
|
|
Either identity function (if browser available) or pytest skip marker with instructions
|
|
"""
|
|
if is_playwright_browser_available():
|
|
return _identity
|
|
return pytest.mark.skip(PLAYWRIGHT_BROWSER_NOT_AVAILABLE_MESSAGE)
|
|
|
|
|
|
def skip_unless_selenium_browser_cached() -> Callable[[Callable[P, T]], Callable[P, T]] | pytest.MarkDecorator:
|
|
"""
|
|
Skip test if Selenium Chrome browser is not available (cached check).
|
|
|
|
This version caches the browser availability check to avoid repeatedly
|
|
launching browsers during test collection.
|
|
|
|
Returns:
|
|
Either identity function (if browser available) or pytest skip marker with instructions
|
|
"""
|
|
if check_selenium_cached():
|
|
return _identity
|
|
return pytest.mark.skip(SELENIUM_BROWSER_NOT_AVAILABLE_MESSAGE)
|
|
|
|
|
|
def skip_unless_playwright_browser_cached() -> Callable[[Callable[P, T]], Callable[P, T]] | pytest.MarkDecorator:
|
|
"""
|
|
Skip test if Playwright Chromium browser is not available (cached check).
|
|
|
|
This version caches the browser availability check to avoid repeatedly
|
|
launching browsers during test collection.
|
|
|
|
Returns:
|
|
Either identity function (if browser available) or pytest skip marker with instructions
|
|
"""
|
|
if check_playwright_cached():
|
|
return _identity
|
|
return pytest.mark.skip(PLAYWRIGHT_BROWSER_NOT_AVAILABLE_MESSAGE)
|
|
|
|
|
|
# Re-export the cached check functions for use in conftest.py and test files
|
|
__all__ = (
|
|
"skip_unless_selenium_browser",
|
|
"skip_unless_playwright_browser",
|
|
"skip_unless_selenium_browser_cached",
|
|
"skip_unless_playwright_browser_cached",
|
|
"check_selenium_cached",
|
|
"check_playwright_cached",
|
|
)
|