Merge pull request #17991 from nsoranzo/warn_unused_ignores

Enable ``warn_unused_ignores`` mypy option
This commit is contained in:
Marius van den Beek
2024-04-16 10:26:11 +02:00
committed by GitHub
97 changed files with 344 additions and 335 deletions
+1 -1
View File
@@ -4,4 +4,4 @@ Galaxy root package -- this is a namespace package.
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__) # type: ignore[has-type]
__path__ = extend_path(__path__, __name__)
+1 -1
View File
@@ -687,7 +687,7 @@ class UniverseApplication(StructuredApp, GalaxyManagerApplication):
self.watchers = self._register_singleton(ConfigWatchers)
self._configure_toolbox()
# Load Data Manager
self.data_managers = self._register_singleton(DataManagers) # type: ignore[type-abstract]
self.data_managers = self._register_singleton(DataManagers)
# Load the update repository manager.
self.update_repository_manager = self._register_singleton(
UpdateRepositoryManager, UpdateRepositoryManager(self)
@@ -81,7 +81,7 @@ class BaseToolBoxTestCase(TestCase, UsesTools):
install_model = mapping.init("sqlite:///:memory:", create_tables=True)
self.app.tool_cache = ToolCache()
self.app.install_model = install_model
self.app.reindex_tool_search = self.__reindex # type: ignore[assignment]
self.app.reindex_tool_search = self.__reindex # type: ignore[method-assign]
itp_config = os.path.join(self.test_directory, "integrated_tool_panel.xml")
self.app.config.integrated_tool_panel_config = itp_config
self.app.watchers = ConfigWatchers(self.app)
+1 -1
View File
@@ -35,7 +35,7 @@ from . import IdentityProvider
try:
import pkce
except ImportError:
pkce = None # type: ignore[assignment]
pkce = None # type: ignore[assignment, unused-ignore]
log = logging.getLogger(__name__)
STATE_COOKIE_NAME = "galaxy-oidc-state"
+7 -3
View File
@@ -22,7 +22,10 @@ from galaxy.util import (
string_as_bool,
unicodify,
)
from galaxy.util.resources import files
from galaxy.util.resources import (
as_file,
resource_path,
)
from .custos_authnz import (
CustosAuthFactory,
KEYCLOAK_BACKENDS,
@@ -35,7 +38,7 @@ from .psa_authnz import (
Strategy,
)
OIDC_BACKEND_SCHEMA = files("galaxy.authnz.xsd") / "oidc_backends_config.xsd"
OIDC_BACKEND_SCHEMA = resource_path(__package__, "xsd/oidc_backends_config.xsd")
log = logging.getLogger(__name__)
@@ -108,7 +111,8 @@ class AuthnzManager:
self.oidc_backends_config = {}
self.oidc_backends_implementation = {}
try:
tree = parse_xml(config_file, schemafname=OIDC_BACKEND_SCHEMA)
with as_file(OIDC_BACKEND_SCHEMA) as oidc_backend_schema_path:
tree = parse_xml(config_file, schemafname=oidc_backend_schema_path)
root = tree.getroot()
if root.tag != "OIDC":
raise etree.ParseError(
+9 -8
View File
@@ -51,6 +51,10 @@ from galaxy.util.properties import (
read_properties_from_file,
running_from_source,
)
from galaxy.util.resources import (
as_file,
resource_path,
)
from galaxy.util.themes import flatten_theme
from ..version import (
VERSION_MAJOR,
@@ -60,18 +64,13 @@ from ..version import (
if TYPE_CHECKING:
from galaxy.model import User
if sys.version_info >= (3, 9):
from importlib.resources import files
else:
from importlib_resources import files
log = logging.getLogger(__name__)
DEFAULT_LOCALE_FORMAT = "%a %b %e %H:%M:%S %Y"
ISO_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
GALAXY_APP_NAME = "galaxy"
GALAXY_SCHEMAS_PATH = files("galaxy.config") / "schemas"
GALAXY_SCHEMAS_PATH = resource_path(__package__, "schemas")
GALAXY_CONFIG_SCHEMA_PATH = GALAXY_SCHEMAS_PATH / "config_schema.yml"
REPORTS_CONFIG_SCHEMA_PATH = GALAXY_SCHEMAS_PATH / "reports_config_schema.yml"
TOOL_SHED_CONFIG_SCHEMA_PATH = GALAXY_SCHEMAS_PATH / "tool_shed_config_schema.yml"
@@ -193,7 +192,7 @@ def configure_logging(config, facts=None):
logging.config.dictConfig(logging_conf)
def find_root(kwargs):
def find_root(kwargs) -> str:
return os.path.abspath(kwargs.get("root_dir", "."))
@@ -238,6 +237,7 @@ class BaseAppConfiguration(HasDynamicProperties):
add_sample_file_to_defaults: Set[str] = set() # for these options, add sample config files to their defaults
listify_options: Set[str] = set() # values for these options are processed as lists of values
object_store_store_by: str
shed_tools_dir: str
def __init__(self, **kwargs):
self._preprocess_kwargs(kwargs)
@@ -835,7 +835,8 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
self.cookie_path = kwargs.get("cookie_path")
if not running_from_source and kwargs.get("tool_path") is None:
try:
self.tool_path = str(files("galaxy.tools") / "bundled")
with as_file(resource_path("galaxy.tools", "bundled")) as path:
self.tool_path = os.fspath(path)
except ModuleNotFoundError:
# Might not be a full galaxy installation
self.tool_path = self._in_root_dir(self.tool_path)
+5 -4
View File
@@ -46,6 +46,7 @@ from galaxy.util.properties import (
nice_config_parser,
NicerConfigParser,
)
from galaxy.util.resources import Traversable
from galaxy.util.yaml_util import (
ordered_dump,
ordered_load,
@@ -72,7 +73,7 @@ class App(NamedTuple):
default_port: str
expected_app_factories: List[str]
destination: str
schema_path: str
schema_path: Traversable
@property
def app_name(self) -> str:
@@ -219,21 +220,21 @@ GALAXY_APP = App(
"8080",
["galaxy.web.buildapp:app_factory"],
"config/galaxy.yml",
str(GALAXY_CONFIG_SCHEMA_PATH),
GALAXY_CONFIG_SCHEMA_PATH,
)
SHED_APP = App(
["tool_shed_wsgi.ini", "config/tool_shed.ini"],
"9009",
["tool_shed.webapp.buildapp:app_factory"],
"config/tool_shed.yml",
str(TOOL_SHED_CONFIG_SCHEMA_PATH),
TOOL_SHED_CONFIG_SCHEMA_PATH,
)
REPORTS_APP = App(
["reports_wsgi.ini", "config/reports.ini"],
"9001",
["galaxy.webapps.reports.buildapp:app_factory"],
"config/reports.yml",
str(REPORTS_CONFIG_SCHEMA_PATH),
REPORTS_CONFIG_SCHEMA_PATH,
)
APPS = {"galaxy": GALAXY_APP, "tool_shed": SHED_APP, "reports": REPORTS_APP}
+4 -3
View File
@@ -1,6 +1,7 @@
import logging
from galaxy.exceptions import ConfigurationError
from galaxy.util.resources import Traversable
from galaxy.util.yaml_util import ordered_load
log = logging.getLogger(__name__)
@@ -35,15 +36,15 @@ class Schema:
class AppSchema(Schema):
def __init__(self, schema_path, app_name):
def __init__(self, schema_path: Traversable, app_name: str):
self.raw_schema = self._read_schema(schema_path)
self.description = self.raw_schema.get("desc", None)
app_schema = self.raw_schema["mapping"][app_name]["mapping"]
self._preprocess(app_schema)
super().__init__(app_schema)
def _read_schema(self, path):
with open(path) as f:
def _read_schema(self, path: Traversable):
with path.open() as f:
return ordered_load(f)
def _preprocess(self, app_schema):
+1 -1
View File
@@ -4367,7 +4367,7 @@ class HexrdImagesNpz(Npz):
>>> fname = get_test_fname('hexrd.images.npz')
>>> HexrdImagesNpz().sniff(fname)
True
>>> fname = get_test_fname('eta_ome.npz')
>>> fname = get_test_fname('hexrd.eta_ome.npz')
>>> HexrdImagesNpz().sniff(fname)
False
"""
@@ -142,7 +142,7 @@ class Ply:
return f"Ply file ({nice_size(dataset.get_size())})"
class PlyAscii(Ply, data.Text): # type: ignore[misc]
class PlyAscii(Ply, data.Text):
"""
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname('test.plyascii')
@@ -160,7 +160,7 @@ class PlyAscii(Ply, data.Text): # type: ignore[misc]
data.Text.__init__(self, **kwd)
class PlyBinary(Ply, Binary): # type: ignore[misc]
class PlyBinary(Ply, Binary):
file_ext = "plybinary"
subtype = "binary"
@@ -477,7 +477,7 @@ class Vtk:
return f"Vtk file ({nice_size(dataset.get_size())})"
class VtkAscii(Vtk, data.Text): # type: ignore[misc]
class VtkAscii(Vtk, data.Text):
"""
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname('test.vtkascii')
@@ -495,7 +495,7 @@ class VtkAscii(Vtk, data.Text): # type: ignore[misc]
data.Text.__init__(self, **kwd)
class VtkBinary(Vtk, Binary): # type: ignore[misc]
class VtkBinary(Vtk, Binary):
"""
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname('test.vtkbinary')
-2
View File
@@ -193,8 +193,6 @@ class Mp4(Video):
>>> from galaxy.datatypes.sniff import sniff_with_cls
>>> sniff_with_cls(Mp4, 'video_1.mp4')
True
>>> sniff_with_cls(Mp4, 'audio_1.mp4')
False
"""
file_ext = "mp4"
+2 -1
View File
@@ -49,8 +49,9 @@ BINARY_MIMETYPES = {"application/pdf", "application/vnd.openxmlformats-officedoc
def get_test_fname(fname):
"""Returns test data filename"""
path, name = os.path.split(__file__)
path = os.path.dirname(__file__)
full_path = os.path.join(path, "test", fname)
assert os.path.isfile(full_path), f"{full_path} is not a file"
return full_path
+3 -3
View File
@@ -521,10 +521,10 @@ class AWSBatchJobRunner(AsynchronousJobRunner):
check_required = []
parsed_params = {}
for k, spec in self.DESTINATION_PARAMS_SPEC.items():
value = params.get(k, spec.get("default")) # type: ignore[attr-defined]
if spec.get("required") and not value: # type: ignore[attr-defined]
value = params.get(k, spec.get("default"))
if spec.get("required") and not value:
check_required.append(k)
mapper = spec.get("map") # type: ignore[attr-defined]
mapper = spec.get("map")
parsed_params[k] = mapper(value) # type: ignore[operator]
if check_required:
raise AWSBatchRunnerException(
+1 -1
View File
@@ -11,7 +11,7 @@ try:
)
except ImportError:
"""Don't make psutil a strict requirement, but use if available."""
Process = None # type: ignore
Process = None
def kill_pid(pid: int, use_psutil: bool = True):
+1 -1
View File
@@ -413,7 +413,7 @@ class HistoryContentsManager(base.SortableManager):
component_class = self.contained_class
stmt = (
select(component_class)
.where(component_class.id.in_(id_list)) # type: ignore[attr-defined]
.where(component_class.id.in_(id_list))
.options(undefer(component_class._metadata))
.options(joinedload(component_class.dataset).joinedload(model.Dataset.actions))
.options(joinedload(component_class.tags)) # type: ignore[attr-defined]
+1 -1
View File
@@ -313,7 +313,7 @@ class UserManager(base.ModelManager, deletable.PurgableManagerMixin):
def by_oidc_access_token(self, access_token: str):
if hasattr(self.app, "authnz_manager") and self.app.authnz_manager:
user = self.app.authnz_manager.match_access_token_to_user(self.app.model.session, access_token) # type: ignore[attr-defined]
user = self.app.authnz_manager.match_access_token_to_user(self.app.model.session, access_token)
return user
else:
return None
+1 -1
View File
@@ -538,7 +538,7 @@ class WorkflowsManager(sharable.SharableModelManager, deletable.DeletableManager
for inv in trans.sa_session.scalars(stmt)
if self.check_security(trans, inv, check_ownership=True, check_accessible=False)
]
return invocations, total_matches # type:ignore[return-value]
return invocations, total_matches
MissingToolsT = List[Tuple[str, str, Optional[str], str]]
+46 -52
View File
@@ -759,12 +759,12 @@ class User(Base, Dictifiable, RepresentById):
back_populates="user", order_by=lambda: desc(History.update_time), cascade_backrefs=False # type: ignore[has-type]
)
active_histories: Mapped[List["History"]] = relationship(
primaryjoin=(lambda: (History.user_id == User.id) & (not_(History.deleted)) & (not_(History.archived))), # type: ignore[has-type]
primaryjoin=(lambda: (History.user_id == User.id) & (not_(History.deleted)) & (not_(History.archived))),
viewonly=True,
order_by=lambda: desc(History.update_time), # type: ignore[has-type]
)
galaxy_sessions: Mapped[List["GalaxySession"]] = relationship(
back_populates="user", order_by=lambda: desc(GalaxySession.update_time), cascade_backrefs=False # type: ignore[has-type]
back_populates="user", order_by=lambda: desc(GalaxySession.update_time), cascade_backrefs=False
)
quotas: Mapped[List["UserQuotaAssociation"]] = relationship(back_populates="user")
quota_source_usages: Mapped[List["UserQuotaSourceUsage"]] = relationship(back_populates="user")
@@ -772,25 +772,23 @@ class User(Base, Dictifiable, RepresentById):
stored_workflow_menu_entries: Mapped[List["StoredWorkflowMenuEntry"]] = relationship(
primaryjoin=(
lambda: (StoredWorkflowMenuEntry.user_id == User.id)
& (StoredWorkflowMenuEntry.stored_workflow_id == StoredWorkflow.id) # type: ignore[has-type]
& not_(StoredWorkflow.deleted) # type: ignore[has-type]
& (StoredWorkflowMenuEntry.stored_workflow_id == StoredWorkflow.id)
& not_(StoredWorkflow.deleted)
),
back_populates="user",
cascade="all, delete-orphan",
collection_class=ordering_list("order_index"),
)
_preferences: Mapped[Dict[str, "UserPreference"]] = relationship(collection_class=attribute_keyed_dict("name"))
values: Mapped[List["FormValues"]] = relationship(
primaryjoin=(lambda: User.form_values_id == FormValues.id) # type: ignore[has-type]
)
values: Mapped[List["FormValues"]] = relationship(primaryjoin=(lambda: User.form_values_id == FormValues.id))
# Add type hint (will this work w/SA?)
api_keys: Mapped[List["APIKeys"]] = relationship(
back_populates="user",
order_by=lambda: desc(APIKeys.create_time),
primaryjoin=(
lambda: and_(
User.id == APIKeys.user_id, # type: ignore[attr-defined]
not_(APIKeys.deleted == true()), # type: ignore[has-type]
User.id == APIKeys.user_id,
not_(APIKeys.deleted == true()),
)
),
)
@@ -798,7 +796,7 @@ class User(Base, Dictifiable, RepresentById):
roles: Mapped[List["UserRoleAssociation"]] = relationship(back_populates="user")
stored_workflows: Mapped[List["StoredWorkflow"]] = relationship(
back_populates="user",
primaryjoin=(lambda: User.id == StoredWorkflow.user_id), # type: ignore[has-type]
primaryjoin=(lambda: User.id == StoredWorkflow.user_id),
cascade_backrefs=False,
)
all_notifications: Mapped[List["UserNotificationAssociation"]] = relationship(
@@ -807,9 +805,9 @@ class User(Base, Dictifiable, RepresentById):
non_private_roles: Mapped[List["UserRoleAssociation"]] = relationship(
viewonly=True,
primaryjoin=(
lambda: (User.id == UserRoleAssociation.user_id) # type: ignore[has-type]
& (UserRoleAssociation.role_id == Role.id) # type: ignore[has-type]
& not_(Role.name == User.email) # type: ignore[has-type]
lambda: (User.id == UserRoleAssociation.user_id)
& (UserRoleAssociation.role_id == Role.id)
& not_(Role.name == User.email)
),
)
@@ -2512,9 +2510,9 @@ class ImplicitlyCreatedDatasetCollectionInput(Base, RepresentById):
input_dataset_collection: Mapped[Optional["HistoryDatasetCollectionAssociation"]] = relationship(
primaryjoin=(
lambda: HistoryDatasetCollectionAssociation.id # type: ignore[has-type]
lambda: HistoryDatasetCollectionAssociation.id
== ImplicitlyCreatedDatasetCollectionInput.input_dataset_collection_id
), # type: ignore[has-type]
),
)
def __init__(self, name, input_dataset_collection):
@@ -2578,7 +2576,7 @@ class PostJobAction(Base, RepresentById):
action_arguments: Mapped[Optional[bytes]] = mapped_column(MutableJSONType)
workflow_step: Mapped[Optional["WorkflowStep"]] = relationship(
back_populates="post_job_actions",
primaryjoin=(lambda: WorkflowStep.id == PostJobAction.workflow_step_id), # type: ignore[has-type]
primaryjoin=(lambda: WorkflowStep.id == PostJobAction.workflow_step_id),
)
def __init__(self, action_type, workflow_step=None, output_name=None, action_arguments=None):
@@ -3073,12 +3071,12 @@ class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable
primaryjoin=(
lambda: (
and_(
HistoryDatasetCollectionAssociation.history_id == History.id, # type: ignore[has-type]
not_(HistoryDatasetCollectionAssociation.deleted), # type: ignore[has-type, arg-type]
HistoryDatasetCollectionAssociation.history_id == History.id,
not_(HistoryDatasetCollectionAssociation.deleted), # type: ignore[arg-type]
)
)
),
order_by=lambda: asc(HistoryDatasetCollectionAssociation.hid), # type: ignore[has-type]
order_by=lambda: asc(HistoryDatasetCollectionAssociation.hid),
viewonly=True,
)
visible_datasets: Mapped[List["HistoryDatasetAssociation"]] = relationship(
@@ -3095,12 +3093,12 @@ class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable
visible_dataset_collections: Mapped[List["HistoryDatasetCollectionAssociation"]] = relationship(
primaryjoin=(
lambda: and_(
HistoryDatasetCollectionAssociation.history_id == History.id, # type: ignore[has-type]
not_(HistoryDatasetCollectionAssociation.deleted), # type: ignore[has-type, arg-type]
HistoryDatasetCollectionAssociation.visible, # type: ignore[has-type, arg-type]
HistoryDatasetCollectionAssociation.history_id == History.id,
not_(HistoryDatasetCollectionAssociation.deleted), # type: ignore[arg-type]
HistoryDatasetCollectionAssociation.visible, # type: ignore[arg-type]
)
),
order_by=lambda: asc(HistoryDatasetCollectionAssociation.hid), # type: ignore[has-type]
order_by=lambda: asc(HistoryDatasetCollectionAssociation.hid),
viewonly=True,
)
tags: Mapped[List["HistoryTagAssociation"]] = relationship(
@@ -3110,7 +3108,7 @@ class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable
order_by=lambda: HistoryAnnotationAssociation.id, back_populates="history"
)
ratings: Mapped[List["HistoryRatingAssociation"]] = relationship(
order_by=lambda: HistoryRatingAssociation.id, # type: ignore[has-type]
order_by=lambda: HistoryRatingAssociation.id,
back_populates="history",
)
default_permissions: Mapped[List["DefaultHistoryPermissions"]] = relationship(back_populates="history")
@@ -4005,7 +4003,7 @@ class Dataset(Base, StorableObject, Serializable):
lambda: and_(
Dataset.id == HistoryDatasetAssociation.dataset_id, # type: ignore[attr-defined]
HistoryDatasetAssociation.deleted == false(), # type: ignore[has-type]
HistoryDatasetAssociation.purged == false(), # type: ignore[attr-defined, arg-type]
HistoryDatasetAssociation.purged == false(), # type: ignore[arg-type]
)
),
viewonly=True,
@@ -4014,7 +4012,7 @@ class Dataset(Base, StorableObject, Serializable):
primaryjoin=(
lambda: and_(
Dataset.id == HistoryDatasetAssociation.dataset_id, # type: ignore[attr-defined]
HistoryDatasetAssociation.purged == true(), # type: ignore[attr-defined, arg-type]
HistoryDatasetAssociation.purged == true(), # type: ignore[arg-type]
)
),
viewonly=True,
@@ -6113,7 +6111,7 @@ class LibraryInfoAssociation(Base, RepresentById):
primaryjoin=lambda: LibraryInfoAssociation.form_definition_id == FormDefinition.id
)
info: Mapped[Optional["FormValues"]] = relationship(
primaryjoin=lambda: LibraryInfoAssociation.form_values_id == FormValues.id # type: ignore[has-type]
primaryjoin=lambda: LibraryInfoAssociation.form_values_id == FormValues.id
)
def __init__(self, library, form_definition, info, inheritable=False):
@@ -6143,7 +6141,7 @@ class LibraryFolderInfoAssociation(Base, RepresentById):
primaryjoin=(lambda: LibraryFolderInfoAssociation.form_definition_id == FormDefinition.id)
)
info: Mapped[Optional["FormValues"]] = relationship(
primaryjoin=(lambda: LibraryFolderInfoAssociation.form_values_id == FormValues.id) # type: ignore[has-type]
primaryjoin=(lambda: LibraryFolderInfoAssociation.form_values_id == FormValues.id)
)
def __init__(self, folder, form_definition, info, inheritable=False):
@@ -6177,7 +6175,7 @@ class LibraryDatasetDatasetInfoAssociation(Base, RepresentById):
primaryjoin=(lambda: LibraryDatasetDatasetInfoAssociation.form_definition_id == FormDefinition.id),
)
info: Mapped[Optional["FormValues"]] = relationship(
primaryjoin=(lambda: LibraryDatasetDatasetInfoAssociation.form_values_id == FormValues.id) # type: ignore[has-type]
primaryjoin=(lambda: LibraryDatasetDatasetInfoAssociation.form_values_id == FormValues.id)
)
def __init__(self, library_dataset_dataset_association, form_definition, info):
@@ -6311,9 +6309,9 @@ class DatasetCollection(Base, Dictifiable, UsesAnnotations, Serializable):
update_time: Mapped[datetime] = mapped_column(default=now, onupdate=now, nullable=True)
elements: Mapped[List["DatasetCollectionElement"]] = relationship(
primaryjoin=(lambda: DatasetCollection.id == DatasetCollectionElement.dataset_collection_id), # type: ignore[has-type]
primaryjoin=(lambda: DatasetCollection.id == DatasetCollectionElement.dataset_collection_id),
back_populates="collection",
order_by=lambda: DatasetCollectionElement.element_index, # type: ignore[has-type]
order_by=lambda: DatasetCollectionElement.element_index,
)
dict_collection_visible_keys = ["id", "collection_type"]
@@ -6811,7 +6809,7 @@ class HistoryDatasetCollectionAssociation(
back_populates="history_dataset_collection",
)
ratings: Mapped[List["HistoryDatasetCollectionRatingAssociation"]] = relationship(
order_by=lambda: HistoryDatasetCollectionRatingAssociation.id, # type: ignore[has-type]
order_by=lambda: HistoryDatasetCollectionRatingAssociation.id,
back_populates="dataset_collection",
)
creating_job_associations: Mapped[List["JobToOutputDatasetCollectionAssociation"]] = relationship(viewonly=True)
@@ -7166,7 +7164,7 @@ class LibraryDatasetCollectionAssociation(Base, DatasetCollectionInstance, Repre
back_populates="dataset_collection",
)
ratings: Mapped[List["LibraryDatasetCollectionRatingAssociation"]] = relationship(
order_by=lambda: LibraryDatasetCollectionRatingAssociation.id, # type: ignore[has-type]
order_by=lambda: LibraryDatasetCollectionRatingAssociation.id,
back_populates="dataset_collection",
)
@@ -7489,14 +7487,14 @@ class StoredWorkflow(Base, HasTags, Dictifiable, RepresentById):
workflows: Mapped[List["Workflow"]] = relationship(
back_populates="stored_workflow",
cascade="all, delete-orphan",
primaryjoin=(lambda: StoredWorkflow.id == Workflow.stored_workflow_id), # type: ignore[has-type]
order_by=lambda: -Workflow.id, # type: ignore[has-type]
primaryjoin=(lambda: StoredWorkflow.id == Workflow.stored_workflow_id),
order_by=lambda: -Workflow.id,
cascade_backrefs=False,
)
latest_workflow = relationship(
"Workflow",
post_update=True,
primaryjoin=(lambda: StoredWorkflow.latest_workflow_id == Workflow.id), # type: ignore[has-type]
primaryjoin=(lambda: StoredWorkflow.latest_workflow_id == Workflow.id),
lazy=False,
)
tags: Mapped[List["StoredWorkflowTagAssociation"]] = relationship(
@@ -7518,7 +7516,7 @@ class StoredWorkflow(Base, HasTags, Dictifiable, RepresentById):
back_populates="stored_workflow",
)
ratings: Mapped[List["StoredWorkflowRatingAssociation"]] = relationship(
order_by=lambda: StoredWorkflowRatingAssociation.id, # type: ignore[has-type]
order_by=lambda: StoredWorkflowRatingAssociation.id,
back_populates="stored_workflow",
)
users_shared_with: Mapped[List["StoredWorkflowUserShareAssociation"]] = relationship(
@@ -7657,20 +7655,20 @@ class Workflow(Base, Dictifiable, RepresentById):
steps = relationship(
"WorkflowStep",
back_populates="workflow",
primaryjoin=(lambda: Workflow.id == WorkflowStep.workflow_id), # type: ignore[has-type]
order_by=lambda: asc(WorkflowStep.order_index), # type: ignore[has-type]
primaryjoin=(lambda: Workflow.id == WorkflowStep.workflow_id),
order_by=lambda: asc(WorkflowStep.order_index),
cascade="all, delete-orphan",
lazy=False,
)
comments: Mapped[List["WorkflowComment"]] = relationship(
back_populates="workflow",
primaryjoin=(lambda: Workflow.id == WorkflowComment.workflow_id), # type: ignore[has-type]
primaryjoin=(lambda: Workflow.id == WorkflowComment.workflow_id),
cascade="all, delete-orphan",
lazy=False,
)
parent_workflow_steps = relationship(
"WorkflowStep",
primaryjoin=(lambda: Workflow.id == WorkflowStep.subworkflow_id), # type: ignore[has-type]
primaryjoin=(lambda: Workflow.id == WorkflowStep.subworkflow_id),
back_populates="subworkflow",
cascade_backrefs=False,
)
@@ -9064,8 +9062,6 @@ class WorkflowInvocationStep(Base, Dictifiable, Serializable):
select(WorkflowStep.order_index).where(WorkflowStep.id == workflow_step_id).scalar_subquery()
)
subworkflow_invocation_id = None
dict_collection_visible_keys = [
"id",
"update_time",
@@ -9607,7 +9603,7 @@ class FormDefinition(Base, Dictifiable, RepresentById):
layout: Mapped[Optional[bytes]] = mapped_column(MutableJSONType)
form_definition_current: Mapped["FormDefinitionCurrent"] = relationship(
back_populates="forms",
primaryjoin=(lambda: FormDefinitionCurrent.id == FormDefinition.form_definition_current_id), # type: ignore[has-type]
primaryjoin=(lambda: FormDefinitionCurrent.id == FormDefinition.form_definition_current_id),
)
# The following form_builder classes are supported by the FormDefinition class.
@@ -10145,12 +10141,12 @@ class Page(Base, HasTags, Dictifiable, RepresentById):
user: Mapped["User"] = relationship()
revisions: Mapped[List["PageRevision"]] = relationship(
cascade="all, delete-orphan",
primaryjoin=(lambda: Page.id == PageRevision.page_id), # type: ignore[has-type]
primaryjoin=(lambda: Page.id == PageRevision.page_id),
back_populates="page",
)
latest_revision: Mapped[Optional["PageRevision"]] = relationship(
post_update=True,
primaryjoin=(lambda: Page.latest_revision_id == PageRevision.id), # type: ignore[has-type]
primaryjoin=(lambda: Page.latest_revision_id == PageRevision.id),
lazy=False,
)
tags: Mapped[List["PageTagAssociation"]] = relationship(
@@ -10160,13 +10156,11 @@ class Page(Base, HasTags, Dictifiable, RepresentById):
order_by=lambda: PageAnnotationAssociation.id, back_populates="page"
)
ratings: Mapped[List["PageRatingAssociation"]] = relationship(
order_by=lambda: PageRatingAssociation.id, # type: ignore[has-type]
order_by=lambda: PageRatingAssociation.id,
back_populates="page",
)
users_shared_with: Mapped[List["PageUserShareAssociation"]] = relationship(back_populates="page")
average_rating = None
# Set up proxy so that
# Page.users_shared_with
# returns a list of users that page is shared with.
@@ -10282,7 +10276,7 @@ class Visualization(Base, HasTags, Dictifiable, RepresentById):
back_populates="visualization",
)
ratings: Mapped[List["VisualizationRatingAssociation"]] = relationship(
order_by=lambda: VisualizationRatingAssociation.id, # type: ignore[has-type]
order_by=lambda: VisualizationRatingAssociation.id,
back_populates="visualization",
)
users_shared_with: Mapped[List["VisualizationUserShareAssociation"]] = relationship(back_populates="visualization")
@@ -11317,7 +11311,7 @@ History.users_shared_with_count = column_property( # type:ignore[assignment]
deferred=True,
)
Page.average_rating = column_property( # type:ignore[assignment]
Page.average_rating = column_property(
select(func.avg(PageRatingAssociation.rating)).where(PageRatingAssociation.page_id == Page.id).scalar_subquery(),
deferred=True,
)
@@ -11340,7 +11334,7 @@ Workflow.step_count = column_property( # type:ignore[assignment]
select(func.count(WorkflowStep.id)).where(Workflow.id == WorkflowStep.workflow_id).scalar_subquery(), deferred=True
)
WorkflowInvocationStep.subworkflow_invocation_id = column_property( # type:ignore[assignment]
WorkflowInvocationStep.subworkflow_invocation_id = column_property(
select(WorkflowInvocationToSubworkflowInvocationAssociation.subworkflow_invocation_id)
.where(
and_(
+1 -1
View File
@@ -58,7 +58,7 @@ def _run_migrations_invoked_via_script(run_migrations: Callable[[str], None]) ->
if revision_str:
if len(revision_str) > 1:
log.error("Please run the commmand for one revision at a time")
revision_str = revision_str[0] # type: ignore[union-attr]
revision_str = revision_str[0]
if revision_str.startswith(f"{GXY}@"):
url = urls[GXY]
+2 -2
View File
@@ -2175,7 +2175,7 @@ class DirectoryModelExportStore(ModelExportStore):
# Write collections' attributes (including datasets list) to file.
stmt_hdca = (
select(model.HistoryDatasetCollectionAssociation)
.where(model.HistoryDatasetCollectionAssociation.history == history) # type:ignore[arg-type]
.where(model.HistoryDatasetCollectionAssociation.history == history)
.where(model.HistoryDatasetCollectionAssociation.deleted == expression.false())
)
collections = sa_session.scalars(stmt_hdca)
@@ -2190,7 +2190,7 @@ class DirectoryModelExportStore(ModelExportStore):
self.export_collection(collection, include_deleted=include_deleted)
# Write datasets' attributes to file.
actions_backref = model.Dataset.actions # type: ignore[attr-defined]
actions_backref = model.Dataset.actions
stmt_hda = (
select(model.HistoryDatasetAssociation)
+13 -15
View File
@@ -1,21 +1,8 @@
import hashlib
from typing import Optional
from .caching import (
CacheTarget,
enable_cache_monitor,
InProcessCacheMonitor,
parse_caching_config_dict_from_xml,
)
try:
from ..authnz.util import provider_name_to_backend
except ImportError:
provider_name_to_backend = None # type: ignore[misc,assignment]
import logging
import os
import shutil
from typing import Optional
try:
import rucio.common
@@ -30,6 +17,11 @@ try:
except ImportError:
Client = None
try:
from galaxy.authnz.util import provider_name_to_backend
except ImportError:
provider_name_to_backend = None # type: ignore[assignment, unused-ignore]
from galaxy.exceptions import (
ObjectInvalid,
ObjectNotFound,
@@ -41,7 +33,13 @@ from galaxy.util import (
unlink,
)
from galaxy.util.path import safe_relpath
from ..objectstore import ConcreteObjectStore
from . import ConcreteObjectStore
from .caching import (
CacheTarget,
enable_cache_monitor,
InProcessCacheMonitor,
parse_caching_config_dict_from_xml,
)
log = logging.getLogger(__name__)
@@ -1,11 +1,10 @@
import copy
import logging
import time
from abc import ABC
try:
from rucio.client.uploadclient import UploadClient
from rucio.common.exception import ( # type: ignore
from rucio.common.exception import (
InputValidationError,
NoFilesUploaded,
NotAllFilesUploaded,
@@ -14,7 +13,7 @@ try:
from rucio.common.utils import generate_uuid
from rucio.rse import rsemanager as rsemgr
except ImportError:
UploadClient = ABC
UploadClient = object
class DeleteClient(UploadClient):
+1 -1
View File
@@ -269,4 +269,4 @@ class FetchDataPayload(BaseDataPayload):
class FetchDataFormPayload(BaseDataPayload):
targets: Union[Json[Targets], Targets] # type: ignore[type-arg] # https://github.com/samuelcolvin/pydantic/issues/2990
targets: Union[Json[Targets], Targets]
@@ -101,7 +101,7 @@ class BaseMetadataGenerator:
repo_path = self.repository.repo_path(self.app)
if hasattr(self.repository, "repo_files_directory"):
# Galaxy Side.
repo_files_directory = self.repository.repo_files_directory(self.app) # type: ignore[attr-defined]
repo_files_directory = self.repository.repo_files_directory(self.app)
repo_dir = repo_files_directory
else:
# Tool Shed side.
@@ -9,7 +9,7 @@ from typing import (
from galaxy.tool_util.biotools import BiotoolsMetadataSource
from galaxy.tool_util.parser import ToolSource
from galaxy.util.resources import files
from galaxy.util.resources import resource_string
def _multi_dict_mapping(content: str) -> Dict[str, List[str]]:
@@ -23,10 +23,9 @@ def _multi_dict_mapping(content: str) -> Dict[str, List[str]]:
def _read_ontology_data_text(filename: str) -> str:
return files(PACKAGE).joinpath(filename).read_text()
return resource_string(__package__, filename)
PACKAGE = "galaxy.tool_util.ontologies"
BIOTOOLS_MAPPING_FILENAME = "biotools_mappings.tsv"
EDAM_OPERATION_MAPPING_FILENAME = "edam_operation_mappings.tsv"
EDAM_TOPIC_MAPPING_FILENAME = "edam_topic_mappings.tsv"
@@ -11,7 +11,7 @@ from galaxy import util
try:
from galaxy.util.template import fill_template
except ImportError:
fill_template = None # type: ignore[assignment]
fill_template = None # type: ignore[assignment, unused-ignore]
log = logging.getLogger(__name__)
@@ -324,7 +324,7 @@ class MetadataToolOutputAction(ToolOutputAction):
else:
# fallback when Cheetah not available, equivalent to how this was handled prior 23.0
# definitely not needed for CWL tool parsing
log.warning("Cheetah not installed, falling back to legacy 'apply_action' behavior.") # type: ignore[unreachable]
log.warning("Cheetah not installed, falling back to legacy 'apply_action' behavior.") # type: ignore[unreachable, unused-ignore]
value = self.default
if value is not None:
setattr(output_dataset.metadata, self.name, value)
+1 -8
View File
@@ -4,15 +4,8 @@ import threading
try:
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
from watchdog.observers.polling import PollingObserver
can_watch = True
except ImportError:
Observer = None # type:ignore[assignment, misc]
FileSystemEventHandler = object # type:ignore[assignment, misc]
PollingObserver = None # type:ignore[assignment, misc]
can_watch = False
FileSystemEventHandler = object # type:ignore[assignment, misc, unused-ignore]
from galaxy.util.hash_util import md5_hash_file
from galaxy.util.watcher import (
+2 -2
View File
@@ -31,11 +31,11 @@ except ImportError:
try:
from PIL import Image
except ImportError:
Image = None # type: ignore[assignment]
Image = None # type: ignore[assignment, unused-ignore]
try:
import tifffile
except ImportError:
tifffile = None # type: ignore[assignment]
tifffile = None # type: ignore[assignment, unused-ignore]
from galaxy.tool_util.parser.util import (
+1 -1
View File
@@ -2178,7 +2178,7 @@ class DataToolParameter(BaseDataToolParameter):
elif isinstance(value, HistoryDatasetCollectionAssociation) or isinstance(value, DatasetCollectionElement):
rval.append(value)
else:
rval.append(session.get(HistoryDatasetAssociation, int(value))) # type:ignore[arg-type]
rval.append(session.get(HistoryDatasetAssociation, int(value)))
dataset_matcher_factory = get_dataset_matcher_factory(trans)
dataset_matcher = dataset_matcher_factory.dataset_matcher(self, other_values)
for v in rval:
+19 -19
View File
@@ -34,6 +34,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from hashlib import md5
from os.path import relpath
from pathlib import Path
from typing import (
Any,
cast,
@@ -61,7 +62,7 @@ from boltons.iterutils import (
remap,
)
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore[import-untyped]
from requests.packages.urllib3.util.retry import Retry # type: ignore[import-untyped, unused-ignore]
from typing_extensions import (
Literal,
Self,
@@ -116,7 +117,7 @@ try:
except ImportError:
LXML_AVAILABLE = False
import xml.etree.ElementTree as etree # type: ignore[assignment,no-redef]
import xml.etree.ElementTree as etree # type: ignore[no-redef]
from xml.etree.ElementTree import ( # type: ignore[assignment] # noqa: F401
Element,
ElementTree,
@@ -134,7 +135,7 @@ from .path import ( # noqa: F401
from .rst_to_html import rst_to_html # noqa: F401
try:
shlex_join = shlex.join # type: ignore[attr-defined]
shlex_join = shlex.join # type: ignore[attr-defined, unused-ignore]
except AttributeError:
# Python < 3.8
def shlex_join(split_command):
@@ -178,9 +179,10 @@ def str_removeprefix(s: str, prefix: str):
"""
if sys.version_info >= (3, 9):
return s.removeprefix(prefix)
if s.startswith(prefix): # type: ignore[unreachable]
elif s.startswith(prefix):
return s[len(prefix) :]
return s
else:
return s
def remove_protocol_from_url(url):
@@ -1132,7 +1134,7 @@ def commaify(amount):
@overload
def unicodify( # type: ignore[misc]
def unicodify( # type: ignore[overload-overlap]
value: Literal[None],
encoding: str = DEFAULT_ENCODING,
error: str = "replace",
@@ -1736,25 +1738,23 @@ def safe_str_cmp(a, b):
return rv == 0
# Don't use these two directly, prefer method version that "works" with packaged Galaxy.
galaxy_root_path = os.path.join(__path__[0], os.pardir, os.pardir, os.pardir) # type: ignore[name-defined]
galaxy_samples_path = os.path.join(__path__[0], os.pardir, "config", "sample") # type: ignore[name-defined]
# Don't use this directly, prefer method version that "works" with packaged Galaxy.
galaxy_root_path = Path(__file__).parent.parent.parent.parent
def galaxy_directory():
path = galaxy_root_path
def galaxy_directory() -> str:
if in_packages():
path = os.path.join(galaxy_root_path, "..")
# This will work only when running pytest from <galaxy_root>/packages/<package_name>/
cwd = Path.cwd()
path = cwd.parent.parent
else:
path = galaxy_root_path
return os.path.abspath(path)
def in_packages():
# Normalize first; otherwise basename will be `..`
return os.path.basename(os.path.normpath(galaxy_root_path)) == "packages"
def galaxy_samples_directory():
return os.path.join(galaxy_directory(), "lib", "galaxy", "config", "sample")
def in_packages() -> bool:
galaxy_lib_path = Path(__file__).parent.parent.parent
return galaxy_lib_path.name != "lib"
def config_directories_from_setting(directories_setting, galaxy_root=galaxy_root_path):
+1 -1
View File
@@ -81,7 +81,7 @@ class BoolBinaryOperation:
return f"({sep.join(map(str, self.args))})"
def __bool__(self):
return self.evalop(bool(a) for a in self.args) # type: ignore[misc,call-arg]
return self.evalop(bool(a) for a in self.args)
__nonzero__ = __bool__
+1 -1
View File
@@ -10,7 +10,7 @@ from typing import (
try:
from PIL import Image
except ImportError:
Image = None # type: ignore[assignment]
Image = None # type: ignore[assignment, unused-ignore]
log = logging.getLogger(__name__)
+3 -3
View File
@@ -13,9 +13,9 @@ try:
can_watch = True
except ImportError:
Observer = None # type:ignore[assignment]
FileSystemEventHandler = object # type:ignore[assignment, misc]
PollingObserver = None # type:ignore[assignment, misc]
Observer = None # type:ignore[assignment, unused-ignore]
FileSystemEventHandler = object # type:ignore[assignment,misc, unused-ignore]
PollingObserver = None # type:ignore[assignment, misc, unused-ignore]
can_watch = False
from galaxy.util.hash_util import md5_hash_file
+1 -1
View File
@@ -8,7 +8,7 @@ from yaml.constructor import ConstructorError
try:
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader # type: ignore[misc, assignment]
from yaml import SafeLoader # type: ignore[assignment]
log = logging.getLogger(__name__)
+2 -2
View File
@@ -269,8 +269,8 @@ class Genomes:
dbkeys = []
# Add user's custom keys to dbkeys.
if user and user.preferences and "dbkeys" in user.preferences: # type:ignore[unreachable]
user_keys_dict = loads(user.preferences["dbkeys"]) # type:ignore[unreachable]
if user and user.preferences and "dbkeys" in user.preferences:
user_keys_dict = loads(user.preferences["dbkeys"])
dbkeys.extend([(attributes["name"], key) for key, attributes in user_keys_dict.items()])
# Add app keys to dbkeys.
+1 -1
View File
@@ -2,4 +2,4 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__) # type: ignore[has-type]
__path__ = extend_path(__path__, __name__)
+19 -17
View File
@@ -8,6 +8,7 @@ import os
import re
import socket
import time
from contextlib import ExitStack
from http.cookies import CookieError
from typing import (
Any,
@@ -51,6 +52,10 @@ from galaxy.util import (
safe_makedirs,
unicodify,
)
from galaxy.util.resources import (
as_file,
resource_path,
)
from galaxy.util.sanitize_html import sanitize_html
from galaxy.version import VERSION
from galaxy.web.framework import (
@@ -60,12 +65,6 @@ from galaxy.web.framework import (
)
from galaxy.web.framework.middleware.static import CacheableStaticURLParser as Static
try:
from importlib.resources import files # type: ignore[attr-defined]
except ImportError:
# Python < 3.9
from importlib_resources import files # type: ignore[no-redef]
log = logging.getLogger(__name__)
@@ -183,16 +182,19 @@ class WebApplication(base.WebApplication):
base_package = (
"tool_shed.webapp" if galaxy_app.name == "tool_shed" else "galaxy.webapps.base"
) # reports has templates in galaxy package
base_template_path = files(base_package) / "templates"
# First look in webapp specific directory
if name is not None:
paths.append(base_template_path / "webapps" / name)
# Then look in root directory
paths.append(base_template_path)
# Create TemplateLookup with a small cache
return mako.lookup.TemplateLookup(
directories=paths, module_directory=galaxy_app.config.template_cache_path, collection_size=500
)
base_template_path = resource_path(base_package, "templates")
with ExitStack() as stack:
# First look in webapp specific directory
if name is not None:
path = stack.enter_context(as_file(base_template_path / "webapps" / name))
paths.append(path)
# Then look in root directory
path = stack.enter_context(as_file(base_template_path))
paths.append(path)
# Create TemplateLookup with a small cache
return mako.lookup.TemplateLookup(
directories=paths, module_directory=galaxy_app.config.template_cache_path, collection_size=500
)
def handle_controller_exception(self, e, trans, method, **kwargs):
if isinstance(e, TypeError):
@@ -343,7 +345,7 @@ class GalaxyWebTransaction(base.DefaultWebTransaction, context.ProvidesHistoryCo
self._ensure_valid_session(session_cookie)
if hasattr(self.app, "authnz_manager") and self.app.authnz_manager:
self.app.authnz_manager.refresh_expiring_oidc_tokens(self) # type: ignore[attr-defined]
self.app.authnz_manager.refresh_expiring_oidc_tokens(self)
if self.galaxy_session:
# When we've authenticated by session, we have to check the
+1 -1
View File
@@ -117,4 +117,4 @@ def get_openapi(
output["webhooks"] = webhook_paths
if tags:
output["tags"] = tags
return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True) # type: ignore
return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True)
+3 -3
View File
@@ -1385,14 +1385,14 @@ class InputParameterModule(WorkflowModule):
def restrict_options(self, step, connections: Iterable[WorkflowStepConnection], default_value):
try:
static_options = [] # type:ignore[var-annotated]
static_options = []
# Retrieve possible runtime options for 'select' type inputs
for connection in connections:
# Well this isn't a great assumption...
assert connection.input_step
module = connection.input_step.module
assert isinstance(module, (ToolModule, SubWorkflowModule))
if isinstance(module, ToolModule): # type:ignore[unreachable]
if isinstance(module, ToolModule):
assert module.tool
tool_inputs = module.tool.inputs # may not be set, but we're catching the Exception below.
@@ -2551,7 +2551,7 @@ class WorkflowModuleInjector:
def compute_runtime_state(self, step: WorkflowStep, step_args=None):
assert step.module, "module must be injected before computing runtime state"
state, step_errors = step.module.compute_runtime_state(self.trans, step, step_args) # type:ignore[unreachable]
state, step_errors = step.module.compute_runtime_state(self.trans, step, step_args)
step.state = state
# Fix any missing parameters
+1 -1
View File
@@ -17,7 +17,7 @@ try:
except ImportError:
# Galaxy libraries and galaxy test driver not available, just assume we're
# targetting a remote Galaxy.
GalaxyTestDriver = None # type: ignore[misc,assignment]
GalaxyTestDriver = None # type: ignore[assignment, misc, unused-ignore]
class ApiTestCase(FunctionalTestCase, UsesApiTestCaseMixin, UsesCeleryTasks):
+3 -3
View File
@@ -536,7 +536,7 @@ else:
NavigatesGalaxyMixin = object
class UsesLibraryAssertions(NavigatesGalaxyMixin): # type:ignore[valid-type, misc]
class UsesLibraryAssertions(NavigatesGalaxyMixin):
@retry_assertion_during_transitions
def assert_num_displayed_items_is(self, n):
num_displayed = self.num_displayed_items()
@@ -546,7 +546,7 @@ class UsesLibraryAssertions(NavigatesGalaxyMixin): # type:ignore[valid-type, mi
return len(self.libraries_table_elements())
class UsesHistoryItemAssertions(NavigatesGalaxyMixin): # type:ignore[valid-type, misc]
class UsesHistoryItemAssertions(NavigatesGalaxyMixin):
def assert_item_peek_includes(self, hid, expected):
item_body = self.history_panel_item_component(hid=hid)
peek_text = item_body.peek.wait_for_text()
@@ -584,7 +584,7 @@ EXAMPLE_WORKFLOW_URL_1 = (
)
class UsesWorkflowAssertions(NavigatesGalaxyMixin): # type:ignore[valid-type, misc]
class UsesWorkflowAssertions(NavigatesGalaxyMixin):
@retry_assertion_during_transitions
def _assert_showing_n_workflows(self, n):
if (actual_count := len(self.workflow_card_elements())) != n:
+3 -3
View File
@@ -132,7 +132,7 @@ class PlaywrightShedBrowser(ShedBrowser):
input_s = form.locator(f"select[name='{control_name}']")
if input_i.count():
if control_name in ["redirect"]:
input_i.input_value = value # type:ignore[method-assign, assignment]
input_i.input_value = value # type:ignore[assignment, unused-ignore]
else:
if isinstance(value, bool):
if value and not input_i.is_checked():
@@ -142,9 +142,9 @@ class PlaywrightShedBrowser(ShedBrowser):
else:
input_i.fill(value)
if input_t.count():
input_t.fill(value) # type:ignore[arg-type]
input_t.fill(value) # type:ignore[arg-type, unused-ignore]
if input_s.count():
input_s.select_option(value) # type:ignore[arg-type]
input_s.select_option(value) # type:ignore[arg-type, unused-ignore]
def edit_repository_categories(self, categories_to_add: List[str], categories_to_remove: List[str]) -> None:
multi_select = "form[name='categories'] select[name='category_id']"
+14 -17
View File
@@ -2,6 +2,7 @@ import tarfile
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import (
Iterator,
List,
Optional,
Union,
@@ -11,7 +12,7 @@ import requests
from typing_extensions import Protocol
from galaxy.util.resources import (
files,
as_file,
resource_path,
Traversable,
)
@@ -50,31 +51,27 @@ from .api_util import (
HasRepositoryId = Union[str, Repository]
DEFAULT_PREFIX = "repofortest"
COLUMN_MAKER_PATH = resource_path(__package__, "../test_data/column_maker/column_maker.tar")
COLUMN_MAKER_1_1_1_PATH = resource_path(__package__, "../test_data/column_maker/column_maker.tar")
TEST_DATA_REPO_FILES = resource_path(__package__, "../test_data")
COLUMN_MAKER_PATH = TEST_DATA_REPO_FILES.joinpath("column_maker/column_maker.tar")
COLUMN_MAKER_1_1_1_PATH = TEST_DATA_REPO_FILES.joinpath("column_maker/column_maker_1.1.1.tar")
DEFAULT_COMMIT_MESSAGE = "a test commit message"
TEST_DATA_REPO_FILES = files("tool_shed.test.test_data")
def repo_files(test_data_path: str) -> List[Path]:
def repo_files(test_data_path: str) -> Iterator[Path]:
repos = TEST_DATA_REPO_FILES.joinpath(f"repos/{test_data_path}")
paths = sorted(Path(str(x)) for x in repos.iterdir())
return paths
for child in sorted(_.name for _ in repos.iterdir()):
with as_file(repos.joinpath(child)) as path:
yield path
def repo_tars(test_data_path: str) -> List[Path]:
tar_paths = []
def repo_tars(test_data_path: str) -> Iterator[Path]:
for path in repo_files(test_data_path):
if path.is_dir():
prefix = f"shedtest_{test_data_path}_{path.name}_"
tf = NamedTemporaryFile(delete=False, prefix=prefix)
assert path.is_dir()
prefix = f"shedtest_{test_data_path}_{path.name}_"
with NamedTemporaryFile(prefix=prefix) as tf:
with tarfile.open(tf.name, "w:gz") as tar:
tar.add(str(path.absolute()), arcname=test_data_path or path.name)
tar_path = tf.name
else:
tar_path = str(path)
tar_paths.append(Path(tar_path))
return tar_paths
yield Path(tf.name)
class HostsTestToolShed(Protocol):
+3 -3
View File
@@ -5,7 +5,7 @@ from typing import (
)
import twill.commands as tc
from twill.browser import FormElement # type:ignore[attr-defined]
from twill.browser import FormElement # type:ignore[attr-defined, unused-ignore]
from galaxy.util import smart_str
from .browser import (
@@ -19,13 +19,13 @@ tc.timeout(240)
def visit_url(url: str, allowed_codes: List[int]) -> str:
new_url = tc.go(url) # type:ignore[func-returns-value]
tc.go(url)
return_code = tc.browser.code
assert return_code in allowed_codes, "Invalid HTTP return code {}, allowed codes: {}".format(
return_code,
", ".join(str(code) for code in allowed_codes),
)
return new_url
return url
def page_content() -> str:
+7 -7
View File
@@ -115,12 +115,12 @@ class User(Base, Dictifiable):
purged: Mapped[Optional[bool]] = mapped_column(Boolean, index=True, default=False)
active_repositories = relationship(
"Repository",
primaryjoin=(lambda: (Repository.user_id == User.id) & (not_(Repository.deleted))), # type: ignore[has-type]
primaryjoin=(lambda: (Repository.user_id == User.id) & (not_(Repository.deleted))),
back_populates="user",
order_by=lambda: desc(Repository.name), # type: ignore[has-type]
order_by=lambda: desc(Repository.name),
)
galaxy_sessions = relationship(
"GalaxySession", back_populates="user", order_by=lambda: desc(GalaxySession.update_time) # type: ignore[has-type]
"GalaxySession", back_populates="user", order_by=lambda: desc(GalaxySession.update_time)
)
api_keys = relationship("APIKeys", back_populates="user", order_by=lambda: desc(APIKeys.create_time))
reset_tokens = relationship("PasswordResetToken", back_populates="user")
@@ -134,9 +134,9 @@ class User(Base, Dictifiable):
"UserRoleAssociation",
viewonly=True,
primaryjoin=(
lambda: (User.id == UserRoleAssociation.user_id) # type: ignore[has-type]
& (UserRoleAssociation.role_id == Role.id) # type: ignore[has-type]
& not_(Role.name == User.email) # type: ignore[has-type]
lambda: (User.id == UserRoleAssociation.user_id)
& (UserRoleAssociation.role_id == Role.id)
& not_(Role.name == User.email)
),
)
@@ -379,7 +379,7 @@ class Repository(Base, Dictifiable):
user = relationship("User", back_populates="active_repositories")
downloadable_revisions = relationship(
"RepositoryMetadata",
primaryjoin=lambda: (Repository.id == RepositoryMetadata.repository_id) & (RepositoryMetadata.downloadable == true()), # type: ignore[attr-defined,has-type]
primaryjoin=lambda: (Repository.id == RepositoryMetadata.repository_id) & (RepositoryMetadata.downloadable == true()), # type: ignore[has-type]
viewonly=True,
order_by=lambda: desc(RepositoryMetadata.update_time), # type: ignore[attr-defined]
)
+5 -3
View File
@@ -4,15 +4,17 @@ show_error_codes = True
ignore_missing_imports = True
check_untyped_defs = True
exclude = (?x)(
^lib/galaxy/tools/bundled
| ^test/functional
| .*tool_shed/test/test_data/repos
^build/
| ^lib/galaxy/tools/bundled/
| ^test/functional/
| .*tool_shed/test/test_data/repos/
)
pretty = True
no_implicit_reexport = True
no_implicit_optional = True
strict_equality = True
warn_unreachable = True
warn_unused_ignores = True
platform = linux
# green list - work on growing these please!
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
+1
View File
@@ -1,3 +1,4 @@
include *.rst *.txt LICENSE */py.typed
include galaxy/config/schemas/*.yml
include galaxy/config/sample/*.sample*
graft galaxy/config/templates/
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
+1
View File
@@ -34,6 +34,7 @@ include_package_data = True
install_requires =
galaxy-files
galaxy-objectstore
galaxy-schema
galaxy-tool-util
galaxy-util[template]
alembic
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
+3
View File
@@ -0,0 +1,3 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__) # noqa: F821
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
+3 -3
View File
@@ -49,11 +49,11 @@ while read -r package_dir || [ -n "$package_dir" ]; do # https://stackoverflow.
# Install extras (if needed)
if [ "$package_dir" = "util" ]; then
pip install -e '.[template,jstree]'
pip install '.[template,jstree]'
elif [ "$package_dir" = "tool_util" ]; then
pip install -e '.[cwl,mulled,edam,extended-assertions]'
pip install '.[cwl,mulled,edam,extended-assertions]'
else
pip install -e '.'
pip install .
fi
pip install -r test-requirements.txt
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
-1
View File
@@ -1 +0,0 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
+1
View File
@@ -0,0 +1 @@
../../package.__init__.py
@@ -89,7 +89,7 @@ class TestCeleryUserRateLimitIntegration(IntegrationTestCase):
results: Dict[int, List[AsyncResult]] = {}
for user in users:
user_results: List[AsyncResult] = []
for _ in range(num_calls): # type: ignore
for _ in range(num_calls):
user_results.append(mock_user_id_task.delay(task_user_id=user))
results[user] = user_results
# Collect results of each call
+35 -24
View File
@@ -2,6 +2,10 @@ import datetime
import os
import shutil
import tempfile
from typing import (
Dict,
Optional,
)
from unittest import mock
from pykwalify.core import Core
@@ -9,9 +13,11 @@ from pykwalify.core import Core
from galaxy.config import GALAXY_SCHEMAS_PATH
from galaxy.job_metrics import JobMetrics
from galaxy.jobs import JobConfiguration
from galaxy.util import (
galaxy_directory,
galaxy_samples_directory,
from galaxy.util import galaxy_directory
from galaxy.util.path import StrPath
from galaxy.util.resources import (
as_file,
resource_path,
)
from galaxy.util.unittest import TestCase
from galaxy.web_stack import ApplicationStack
@@ -19,9 +25,10 @@ from galaxy.web_stack.handlers import HANDLER_ASSIGNMENT_METHODS
# File would be slightly more readable if contents were embedded directly, but
# there are advantages to testing the documentation/examples.
SIMPLE_JOB_CONF = os.path.join(galaxy_samples_directory(), "job_conf.xml.sample_basic")
ADVANCED_JOB_CONF = os.path.join(galaxy_samples_directory(), "job_conf.xml.sample_advanced")
ADVANCED_JOB_CONF_YAML = os.path.join(galaxy_samples_directory(), "job_conf.sample.yml")
GALAXY_SAMPLES_DIRECTORY = resource_path("galaxy.config", "sample")
SIMPLE_JOB_CONF = GALAXY_SAMPLES_DIRECTORY / "job_conf.xml.sample_basic"
ADVANCED_JOB_CONF = GALAXY_SAMPLES_DIRECTORY / "job_conf.xml.sample_advanced"
ADVANCED_JOB_CONF_YAML = GALAXY_SAMPLES_DIRECTORY / "job_conf.sample.yml"
CONDITIONAL_RUNNER_JOB_CONF = os.path.join(os.path.dirname(__file__), "conditional_runners_job_conf.xml")
HANDLER_TEMPLATE_JOB_CONF = os.path.join(os.path.dirname(__file__), "handler_template_job_conf.xml")
@@ -45,7 +52,8 @@ class BaseJobConfXmlParserTestCase(TestCase):
track_jobs_in_database=True,
server_name="main",
)
self._write_config_from(SIMPLE_JOB_CONF)
with as_file(SIMPLE_JOB_CONF) as path:
self._write_config_from(path)
self._app = None
self._application_stack = None
self._job_configuration = None
@@ -91,7 +99,7 @@ class BaseJobConfXmlParserTestCase(TestCase):
self._job_configuration_base_pools = base_pools
self._write_config_from(HANDLER_TEMPLATE_JOB_CONF, template=template)
def _write_config_from(self, path, template=None):
def _write_config_from(self, path: StrPath, template: Optional[Dict[str, str]] = None) -> None:
template = template or {}
try:
contents = open(path).read()
@@ -118,9 +126,11 @@ class BaseJobConfXmlParserTestCase(TestCase):
def _with_advanced_config(self):
if self.extension == "xml":
self._write_config_from(ADVANCED_JOB_CONF)
trav = ADVANCED_JOB_CONF
else:
self._write_config_from(ADVANCED_JOB_CONF_YAML)
trav = ADVANCED_JOB_CONF_YAML
with as_file(trav) as path:
self._write_config_from(path)
class TestSimpleJobConfXmlParser(BaseJobConfXmlParserTestCase):
@@ -357,17 +367,18 @@ class TestAdvancedJobConfYamlParser(TestAdvancedJobConfXmlParser):
def test_yaml_advanced_validation():
schema = GALAXY_SCHEMAS_PATH / "job_config_schema.yml"
integration_tests_dir = os.path.join(galaxy_directory(), "test", "integration")
valid_files = [
ADVANCED_JOB_CONF_YAML,
os.path.join(integration_tests_dir, "delay_job_conf.yml"),
os.path.join(integration_tests_dir, "embedded_pulsar_metadata_job_conf.yml"),
os.path.join(integration_tests_dir, "io_injection_job_conf.yml"),
os.path.join(integration_tests_dir, "resubmission_job_conf.yml"),
os.path.join(integration_tests_dir, "resubmission_default_job_conf.yml"),
]
for valid_file in valid_files:
c = Core(
source_file=valid_file,
schema_files=[str(schema)],
)
c.validate()
with as_file(ADVANCED_JOB_CONF_YAML) as advanced_job_conf_yaml_path, as_file(schema) as schema_path:
valid_files = [
os.fspath(advanced_job_conf_yaml_path),
os.path.join(integration_tests_dir, "delay_job_conf.yml"),
os.path.join(integration_tests_dir, "embedded_pulsar_metadata_job_conf.yml"),
os.path.join(integration_tests_dir, "io_injection_job_conf.yml"),
os.path.join(integration_tests_dir, "resubmission_job_conf.yml"),
os.path.join(integration_tests_dir, "resubmission_default_job_conf.yml"),
]
for valid_file in valid_files:
c = Core(
source_file=valid_file,
schema_files=[os.fspath(schema_path)],
)
c.validate()
+1 -1
View File
@@ -66,7 +66,7 @@ class AbstractTestCases:
@contextmanager
def _prepared_wrapper(self):
wrapper = self._wrapper()
wrapper._get_tool_evaluator = lambda *args, **kwargs: MockEvaluator(wrapper.app, wrapper.tool, wrapper.get_job(), wrapper.working_directory) # type: ignore[assignment]
wrapper._get_tool_evaluator = lambda *args, **kwargs: MockEvaluator(wrapper.app, wrapper.tool, wrapper.get_job(), wrapper.working_directory) # type: ignore[method-assign]
wrapper.prepare()
yield wrapper
@@ -88,7 +88,7 @@ class TestHistoryManager(BaseTestCase):
name_first_then_time = (
model.History.name,
sqlalchemy.desc(model.History.create_time),
) # type:ignore[var-annotated]
)
assert self.history_manager.list(order_by=name_first_then_time) == [history2, history1, history3]
def test_copy(self):
+10 -10
View File
@@ -46,15 +46,15 @@ class BaseExportTestCase(BaseTestCase):
@contextmanager
def _expect_get_history(self, history):
self.app.history_manager.get_accessible.return_value = history # type: ignore[attr-defined,union-attr]
self.app.history_manager.get_accessible.return_value = history
yield
self.app.history_manager.get_accessible.assert_called_once_with(history.id, self.trans.user) # type: ignore[attr-defined,union-attr]
self.app.history_manager.get_accessible.assert_called_once_with(history.id, self.trans.user)
@contextmanager
def _expect_get_hda(self, hda, hda_id=1):
self.app.hda_manager.get_accessible.return_value = hda # type: ignore[attr-defined,union-attr]
self.app.hda_manager.get_accessible.return_value = hda
yield
self.app.hda_manager.get_accessible.assert_called_once_with(hda.id, self.trans.user) # type: ignore[attr-defined,union-attr]
self.app.hda_manager.get_accessible.assert_called_once_with(hda.id, self.trans.user)
def _new_pair_collection(self):
hda_forward = self._new_hda(contents="Forward dataset.")
@@ -222,7 +222,7 @@ history_dataset_type(history_dataset_id=1)
hdca.collection = self._new_pair_collection()
hdca.id = 1
self.trans.app.dataset_collection_manager.get_dataset_collection_instance.return_value = hdca # type: ignore[attr-defined,union-attr]
self.trans.app.dataset_collection_manager.get_dataset_collection_instance.return_value = hdca
example = """# Example
```galaxy
history_dataset_collection_display(history_dataset_collection_id=1)
@@ -243,7 +243,7 @@ history_dataset_collection_display(history_dataset_collection_id=1)
stored_workflow.latest_workflow = workflow
workflow_step_0 = model.WorkflowStep()
workflow.steps = [workflow_step_0]
self.trans.app.workflow_manager.get_stored_accessible_workflow.return_value = stored_workflow # type: ignore[attr-defined,union-attr]
self.trans.app.workflow_manager.get_stored_accessible_workflow.return_value = stored_workflow
example = """# Example
```galaxy
workflow_display(workflow_id=1)
@@ -278,7 +278,7 @@ invocation_time(invocation_id=1)
```
"""
invocation = self._new_invocation()
self.app.workflow_manager.get_invocation.side_effect = [invocation] # type: ignore[attr-defined,union-attr]
self.app.workflow_manager.get_invocation.side_effect = [invocation]
result = self._to_basic(example)
expectedtime = invocation.create_time.strftime("%Y-%m-%d, %H:%M:%S")
assert f"\n {expectedtime}" in result
@@ -356,7 +356,7 @@ history_dataset_display(history_dataset_id=1)
history_dataset_display(history_dataset_id=2)
```
"""
self.app.hda_manager.get_accessible.side_effect = [hda, hda2] # type: ignore[attr-defined,union-attr]
self.app.hda_manager.get_accessible.side_effect = [hda, hda2]
export_markdown, extra_data = self._ready_export(example)
assert "history_datasets" in extra_data
assert len(extra_data["history_datasets"]) == 2
@@ -369,7 +369,7 @@ history_dataset_display(history_dataset_id=2)
hdca.history_id = 1
hdca.collection_id = hdca.collection.id
self.trans.app.dataset_collection_manager.get_dataset_collection_instance.return_value = hdca # type: ignore[attr-defined,union-attr]
self.trans.app.dataset_collection_manager.get_dataset_collection_instance.return_value = hdca
example = """# Example
```galaxy
history_dataset_collection_display(history_dataset_collection_id=1)
@@ -404,7 +404,7 @@ generate_time()
def test_get_invocation_time(self):
invocation = self._new_invocation()
self.app.workflow_manager.get_invocation.side_effect = [invocation] # type: ignore[attr-defined,union-attr]
self.app.workflow_manager.get_invocation.side_effect = [invocation]
example = """# Example
```galaxy
invocation_time(invocation_id=1)
+1 -1
View File
@@ -7,7 +7,7 @@ import pytest
try:
import psycopg
except ImportError:
psycopg = None # type: ignore[assignment]
psycopg = None # type: ignore[assignment, unused-ignore]
try:
import psycopg2
+12 -8
View File
@@ -24,10 +24,11 @@ from galaxy.model.unittest_utils.migration_scripts_testing_utils import ( # noq
from galaxy.model.unittest_utils.model_testing_utils import ( # noqa: F401 - url_factory is a fixture we have to import explicitly
url_factory,
)
from galaxy.util import in_packages
from galaxy.util.resources import resource_path
pytestmark = pytest.mark.skipif(in_packages(), reason="Running from packages")
from galaxy.util.resources import (
as_file,
resource_path,
Traversable,
)
DbUrl = NewType("DbUrl", str)
@@ -42,19 +43,21 @@ COMMANDS = [ADMIN_CMD, DEV_CMD]
@pytest.fixture(scope="session")
def migrations_dir():
def migrations_dir() -> Traversable:
"""[galaxy-root]/lib/galaxy/model/migrations/"""
return resource_path("galaxy.model", "migrations")
@pytest.fixture(scope="session")
def alembic_env_dir(migrations_dir) -> str:
def alembic_env_dir(migrations_dir: Traversable) -> Traversable:
"""[galaxy-root]/lib/galaxy/model/migrations/alembic/"""
return migrations_dir / "alembic"
@pytest.fixture(params=["one database", "two databases"])
def config(url_factory, alembic_env_dir, alembic_config_text, tmp_directory, monkeypatch, request): # noqa: F811
def config(
url_factory, alembic_env_dir: Traversable, alembic_config_text, tmp_directory, monkeypatch, request # noqa: F811
):
"""
Construct Config object for staging; setup staging env.
"""
@@ -69,7 +72,8 @@ def config(url_factory, alembic_env_dir, alembic_config_text, tmp_directory, mon
# Copy production alembic.ini to staging location
config_file_path = os.path.join(tmp_directory, "alembic.ini")
update_config_for_staging(alembic_config_text, alembic_env_dir, version_locations, gxy_dburl)
with as_file(alembic_env_dir) as alembic_env_dir_path:
update_config_for_staging(alembic_config_text, os.fspath(alembic_env_dir_path), version_locations, gxy_dburl)
write_to_file(config_file_path, alembic_config_text)
alembic_cfg = Config(config_file_path)

Some files were not shown because too many files have changed in this diff Show More