Type annotation fix for mypy 1.16.0 during package testing

Fix the following traceback:

```
galaxy/selenium/context.py:25: error: Cannot override writeable attribute with
read-only property  [override]
        def driver(self):
        ^
```

This error didn't happen during the normal `tox -e mypy` because
the `selenium` package was not installed into the tox virtual environment.

To prevent this issue and improve the code type checking, this commit
defines a new `test` dependency group and corresponding
`lib/galaxy/dependencies/pinned-test-requirements.txt` requirements
file to be used by mypy and other tests that don't need packages
used purely for developing (like black, isort, Sphinx...).

Fix the 6 new mypy errors resulting from installing the test
dependencies into the tox virtual environment.
This commit is contained in:
Nicola Soranzo
2025-06-05 00:26:15 +01:00
parent 761747a916
commit 1984ad738c
8 changed files with 184 additions and 20 deletions
@@ -25,6 +25,6 @@ jobs:
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install Python dependencies
run: pip install -r requirements.txt -r lib/galaxy/dependencies/dev-requirements.txt
run: pip install -r requirements.txt -r lib/galaxy/dependencies/pinned-test-requirements.txt
- name: Run tests
run: .ci/check_test_class_names.sh
+2 -5
View File
@@ -34,7 +34,7 @@ from galaxy.util import (
try:
from ase import io as ase_io
except ImportError:
ase_io = None
ase_io = None # type: ignore[assignment, unused-ignore]
log = logging.getLogger(__name__)
@@ -245,10 +245,7 @@ class AtomicStructFile(GenericMolFile):
Find Atom IDs for metadata.
"""
self.meta_error = False
if ase_io is None:
# Don't have optional dependency, can't set advanced values
return
else:
if ase_io is not None:
# enhanced metadata
try:
ase_data = ase_io.read(dataset.get_file_name(), index=":", format=self.ase_format)
@@ -0,0 +1,156 @@
# This file was autogenerated by uv via the following command:
# uv export --frozen --no-annotate --no-hashes --only-group=test
aiohappyeyeballs==2.6.1
aiohttp==3.11.18
aiosignal==1.3.2
anyio==4.9.0
ase==3.25.0
async-timeout==5.0.1 ; python_full_version < '3.11'
attrs==25.3.0
axe-selenium-python==2.1.6
boto3==1.37.3
botocore==1.37.3
cachecontrol==0.14.3
cattrs==24.1.3
certifi==2025.4.26
cffi==1.17.1 ; implementation_name != 'pypy' and os_name == 'nt'
charset-normalizer==3.4.2
click==8.1.8 ; python_full_version < '3.10'
click==8.2.1 ; python_full_version >= '3.10'
colorama==0.4.6 ; sys_platform == 'win32'
colorlog==6.9.0
contourpy==1.3.0 ; python_full_version < '3.10'
contourpy==1.3.2 ; python_full_version >= '3.10'
coverage==7.8.2
cwltest==2.6.20250314152537
cycler==0.12.1
decorator==5.2.1
defusedxml==0.7.1
dogpile-cache==1.2.2
enum-tools==0.12.0 ; python_full_version >= '3.10'
exceptiongroup==1.3.0 ; python_full_version < '3.11'
filelock==3.18.0
fluent-logger==0.11.1
fonttools==4.58.0
frozenlist==1.6.0
greenlet==3.2.2
h11==0.16.0
html5lib==1.1
httpcore==1.0.9
httpx==0.28.1
idna==3.10
importlib-metadata==8.7.0 ; python_full_version < '3.12'
importlib-resources==6.5.2 ; python_full_version < '3.10'
iniconfig==2.1.0
inquirerpy==0.3.4
isodate==0.7.2 ; python_full_version < '3.11'
jinja2==3.1.6
jmespath==1.0.1
jsonschema==4.23.0
jsonschema-specifications==2025.4.1
junit-xml==1.9
kiwisolver==1.4.7 ; python_full_version < '3.10'
kiwisolver==1.4.8 ; python_full_version >= '3.10'
lxml==5.4.0
markdown-it-py==3.0.0
markupsafe==3.0.2
matplotlib==3.9.4 ; python_full_version < '3.10'
matplotlib==3.10.3 ; python_full_version >= '3.10'
mdurl==0.1.2
mirakuru==2.6.0
mistune==3.0.2
msgpack==1.1.0
multidict==6.4.4
mypy-extensions==1.1.0
numpy==2.0.2 ; python_full_version < '3.10'
numpy==2.2.6 ; python_full_version >= '3.10'
onedatafilerestclient==21.2.5.2
outcome==1.3.0.post0
owlrl==6.0.2
packaging==24.2 ; python_full_version < '3.10'
packaging==25.0 ; python_full_version >= '3.10'
pbr==6.1.1
pfzy==0.3.4
pillow==11.2.1
pkce==1.0.3
platformdirs==4.3.8
playwright==1.52.0
pluggy==1.6.0
port-for==0.7.4
prettytable==3.16.0
prompt-toolkit==3.0.51
propcache==0.3.1
psutil==7.0.0 ; sys_platform != 'cygwin'
psycopg==3.2.9
pycparser==2.22 ; implementation_name != 'pypy' and os_name == 'nt'
pyee==13.0.0
pygments==2.19.1
pyparsing==3.2.3
pyshacl==0.26.0
pysocks==1.7.1
pytest==7.4.4
pytest-asyncio==0.23.8
pytest-base-url==2.1.0
pytest-cov==6.1.1
pytest-html==4.1.1
pytest-httpserver==1.1.3
pytest-json-report==1.5.0
pytest-metadata==3.1.1
pytest-mock==3.14.0
pytest-playwright==0.7.0
pytest-postgresql==7.0.2
pytest-shard==0.1.2
python-dateutil==2.9.0.post0
python-irodsclient==3.1.0
python-slugify==8.0.4
pyyaml==6.0.2
rdflib==7.1.4
referencing==0.36.2
requests==2.32.4
requests-cache==1.2.1
responses==0.25.7
rich==13.9.4
rich-click==1.8.9
roc-validator==0.4.2 ; python_full_version < '3.9.20'
roc-validator==0.4.6 ; python_full_version >= '3.9.20' and python_full_version < '3.10'
roc-validator==0.7.0 ; python_full_version >= '3.10'
rpds-py==0.25.1
ruamel-yaml==0.18.10
ruamel-yaml-clib==0.2.12 ; python_full_version < '3.13' and platform_python_implementation == 'CPython'
rucio-clients==37.3.0
s3transfer==0.11.3
schema-salad==8.9.20250408123006
scipy==1.13.1 ; python_full_version < '3.10'
scipy==1.15.3 ; python_full_version >= '3.10'
selenium==4.32.0 ; python_full_version < '3.10'
selenium==4.33.0 ; python_full_version >= '3.10'
seletools==1.5.0
setuptools==80.8.0
six==1.17.0
sniffio==1.3.1
sortedcontainers==2.4.0
statsd==4.0.1
stevedore==5.4.1
tabulate==0.9.0
testfixtures==8.3.0
text-unidecode==1.3
tinydb==4.8.2
toml==0.10.2
tomli==2.2.1 ; python_full_version <= '3.11'
trio==0.30.0
trio-websocket==0.12.2
tuspy==1.1.0
twill==3.3
typing-extensions==4.13.2
tzdata==2025.2 ; sys_platform == 'win32'
url-normalize==2.2.1
urllib3==1.26.20 ; python_full_version < '3.10'
urllib3==2.4.0 ; python_full_version >= '3.10'
watchdog==6.0.0
wcwidth==0.2.13
webencodings==0.5.1
websocket-client==1.8.0
werkzeug==3.1.3
wsproto==1.2.0
yarl==1.20.0
zipp==3.21.0 ; python_full_version < '3.12'
+1
View File
@@ -44,5 +44,6 @@ fi
# Update pinned requirements files.
UV_EXPORT_OPTIONS='--frozen --no-annotate --no-hashes'
${uv} export ${UV_EXPORT_OPTIONS} --no-dev > "$this_directory/pinned-requirements.txt"
${uv} export ${UV_EXPORT_OPTIONS} --only-group=test > "$this_directory/pinned-test-requirements.txt"
${uv} export ${UV_EXPORT_OPTIONS} --only-group=dev > "$this_directory/dev-requirements.txt"
${uv} export ${UV_EXPORT_OPTIONS} --only-group=typecheck > "$this_directory/pinned-typecheck-requirements.txt"
+2 -2
View File
@@ -13,7 +13,7 @@ try:
OnedataRESTError,
)
except ImportError:
OnedataFileRESTClient = None
OnedataFileRESTClient = None # type: ignore[assignment, misc, unused-ignore]
from galaxy.util import (
mapped_chars,
@@ -303,6 +303,6 @@ def _is_not_found_onedata_rest_error(ex):
return True
if ex.http_code == 400 and ex.category == "posix":
return ex.details["errno"] == "enoent"
return isinstance(ex.details, dict) and ex.details["errno"] == "enoent"
return False
+8 -2
View File
@@ -1,6 +1,9 @@
import os
from abc import abstractmethod
from typing import Optional
from typing import (
Optional,
TYPE_CHECKING,
)
from urllib.parse import urljoin
import yaml
@@ -8,6 +11,9 @@ import yaml
from .driver_factory import ConfiguredDriver
from .navigates_galaxy import NavigatesGalaxy
if TYPE_CHECKING:
from selenium.webdriver.remote.webdriver import WebDriver
class GalaxySeleniumContext(NavigatesGalaxy):
url: str
@@ -22,7 +28,7 @@ class GalaxySeleniumContext(NavigatesGalaxy):
return urljoin(base, url)
@property
def driver(self):
def driver(self) -> "WebDriver": # type: ignore[override]
return self.configured_driver.driver
def screenshot(self, label: str):
+13 -10
View File
@@ -116,20 +116,13 @@ Repository = "https://github.com/galaxyproject/galaxy"
"Bug Tracker" = "https://github.com/galaxyproject/galaxy/issues"
[dependency-groups]
dev = [
test = [
"ase>=3.18.1",
"axe-selenium-python",
"black",
"boto3",
"codespell",
"cwltest>=2.5.20240906231108", # Python 3.13 support
"darker",
"fluent-logger",
"galaxy-release-util",
"isort",
"lxml!=4.2.2",
"markdown-it-reporter",
"myst-parser",
"onedatafilerestclient==21.2.5.2",
"pkce",
"playwright>=1.48.0", # Python 3.13 support
@@ -149,8 +142,6 @@ dev = [
"rucio-clients>=37.2.0", # https://github.com/rucio/rucio/pull/7665
"selenium",
"seletools",
"Sphinx>=4.0", # support docutils 0.17
"sphinx-rtd-theme",
"statsd",
"testfixtures",
"tuspy",
@@ -158,6 +149,18 @@ dev = [
"watchdog",
"Werkzeug",
]
dev = [
{include-group = "test"},
"black",
"codespell",
"darker",
"galaxy-release-util",
"isort",
"markdown-it-reporter",
"myst-parser",
"Sphinx>=4.0", # support docutils 0.17
"sphinx-rtd-theme",
]
typecheck = [
"boto3-stubs[s3]",
"lxml-stubs",
+1
View File
@@ -55,6 +55,7 @@ deps =
lint,lint_docstring,lint_docstring_include_list: -rlib/galaxy/dependencies/pinned-lint-requirements.txt
mypy: -rlib/galaxy/dependencies/pinned-typecheck-requirements.txt
mypy: -rlib/galaxy/dependencies/pinned-requirements.txt
mypy: -rlib/galaxy/dependencies/pinned-test-requirements.txt
test_galaxy_packages,test_galaxy_packages_for_pulsar: pyyaml
unit: mock-ssh-server