Skip to content

Commit

Permalink
Fixes for errors reported by mypy 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Jul 27, 2024
1 parent 543ad8b commit 4c44716
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/dependencies/pinned-typecheck-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cryptography==42.0.8 ; python_version >= "3.8" and python_version < "3.13"
lxml-stubs==0.5.1 ; python_version >= "3.8" and python_version < "3.13"
mypy-boto3-s3==1.34.138 ; python_version >= "3.8" and python_version < "3.13"
mypy-extensions==1.0.0 ; python_version >= "3.8" and python_version < "3.13"
mypy==1.10.1 ; python_version >= "3.8" and python_version < "3.13"
mypy==1.11.0 ; python_version >= "3.8" and python_version < "3.13"
pycparser==2.22 ; python_version >= "3.8" and python_version < "3.13" and platform_python_implementation != "PyPy"
pydantic-core==2.20.1 ; python_version >= "3.8" and python_version < "3.13"
pydantic==2.8.2 ; python_version >= "3.8" and python_version < "3.13"
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/managers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def serialize(self, item, keys, **context):
try:
returned[key] = self.serializers[key](item, key, **context)
except SkipAttribute:
# dont add this key if the deserializer threw this
# don't add this key if the serializer threw this
pass
elif key in self.serializable_keyset:
returned[key] = self.default_serializer(item, key, **context)
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/managers/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def __init__(self, app):
self.default_view = "all"
self.add_view("all", list(self.serializers.keys()))

def default_serializer(self, config, key):
return getattr(config, key, None)
def default_serializer(self, item, key, **context):
return getattr(item, key, None)

def add_serializers(self):
def _defaults_to(default) -> base.Serializer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def reset_metadata_on_selected_repositories(self, user, **kwd):
status = "error"
return message, status

def set_repository(self, repository):
def set_repository(
self, repository, relative_install_dir: Optional[str] = None, changeset_revision: Optional[str] = None
):
super().set_repository(repository)
self.repository_clone_url = common_util.generate_clone_url_for_installed_repository(self.app, repository)

Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/tool_util/unittest_utils/parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import List

from galaxy.tool_util.parameters import (
from_input_source,
Expand All @@ -11,7 +10,6 @@


class ParameterBundle(ToolParameterBundle):
input_models: List[ToolParameterT]

def __init__(self, parameter: ToolParameterT):
self.input_models = [parameter]
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/error_reports/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class ErrorPlugin(metaclass=ABCMeta):
def plugin_type(self):
"""Short string providing labelling this plugin"""

def submit_report(self, dataset, job, tool, user_submission=False, **kwargs):
def submit_report(self, dataset, job, tool, **kwargs):
"""Submit the bug report and render a string to be displayed to the user."""
return None
2 changes: 1 addition & 1 deletion lib/galaxy/tools/error_reports/plugins/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class SlackPlugin(BaseGitPlugin):
"""Send error report to Sentry."""
"""Send error report to Slack."""

plugin_type = "slack"

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ def commaify(amount):


@overload
def unicodify( # type: ignore[overload-overlap]
def unicodify(
value: Literal[None],
encoding: str = DEFAULT_ENCODING,
error: str = "replace",
Expand Down
4 changes: 0 additions & 4 deletions lib/galaxy/util/odict.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def setdefault(self, key, failobj=None):
self._keys.append(key)
return UserDict.setdefault(self, key, failobj)

def update(self, dict):
for key, val in dict.items():
self.__setitem__(key, val)

def values(self):
return map(self.get, self._keys)

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy_test/driver/driver_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def __init__(self):
self.server_wrappers: List[ServerWrapper] = []
self.temp_directories: List[str] = []

def setup(self, config_object=None) -> None:
def setup(self) -> None:
"""Called before tests are built."""

def tear_down(self) -> None:
Expand Down
6 changes: 0 additions & 6 deletions lib/galaxy_test/selenium/test_workflow_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,12 +1481,6 @@ def workflow_index_open_with_name(self, name):
self.workflow_index_search_for(name)
self.components.workflows.edit_button.wait_for_and_click()

def workflow_upload_yaml_with_random_name(self, content):
workflow_populator = self.workflow_populator
name = self._get_random_name()
workflow_populator.upload_yaml_workflow(content, name=name)
return name

@retry_assertion_during_transitions
def assert_wf_name_is(self, expected_name):
edit_name_element = self.components.workflow_editor.edit_name.wait_for_visible()
Expand Down
6 changes: 4 additions & 2 deletions lib/tool_shed/metadata/repository_metadata_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,11 @@ def reset_metadata_on_selected_repositories(self, **kwd):
status = "error"
return message, status

def set_repository(self, repository, repository_clone_url=None):
def set_repository(
self, repository, relative_install_dir: Optional[str] = None, changeset_revision: Optional[str] = None
):
super().set_repository(repository)
self.repository_clone_url = repository_clone_url or common_util.generate_clone_url_for(self.trans, repository)
self.repository_clone_url = relative_install_dir or common_util.generate_clone_url_for(self.trans, repository)

def set_repository_metadata(self, host, content_alert_str="", **kwd):
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/test/base/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def build_shed_app(simple_kwargs):
class ToolShedTestDriver(driver_util.TestDriver):
"""Instantiate a Galaxy-style TestDriver for testing the tool shed."""

def setup(self):
def setup(self) -> None:
"""Entry point for test driver script."""
self.external_shed = bool(os.environ.get("TOOL_SHED_TEST_EXTERNAL", None))
if not self.external_shed:
Expand Down
6 changes: 3 additions & 3 deletions test/unit/tool_util/test_parameter_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
encode,
RequestInternalToolState,
RequestToolState,
ToolParameterModel,
validate_internal_job,
validate_internal_request,
validate_request,
validate_test_case,
)
from galaxy.tool_util.parameters.json import to_json_schema_string
from galaxy.tool_util.parameters.models import ToolParameterT
from galaxy.tool_util.unittest_utils.parameters import (
parameter_bundle,
parameter_bundle_for_file,
Expand Down Expand Up @@ -85,12 +85,12 @@ def _test_file(file: str, specification=None):
_assert_internal_requests_invalid(tool_parameter_model, combos["request_invalid"])


def _for_each(test: Callable, parameter: ToolParameterModel, requests: List[Dict[str, Any]]) -> None:
def _for_each(test: Callable, parameter: ToolParameterT, requests: List[Dict[str, Any]]) -> None:
for request in requests:
test(parameter, request)


def _assert_request_validates(parameter, request) -> None:
def _assert_request_validates(parameter: ToolParameterT, request: Dict[str, Any]) -> None:
try:
validate_request(parameter_bundle(parameter), request)
except RequestParameterInvalidException as e:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webapps/test_service_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, expected_filename: str, expected_mime_type: str) -> None:
self.expected_filename = expected_filename
self.expected_mime_type = expected_mime_type

def new_target(self, filename, mime_type):
def new_target(self, filename, mime_type, duration=None, security=None):
assert filename == self.expected_filename
assert mime_type == self.expected_mime_type

Expand Down

0 comments on commit 4c44716

Please sign in to comment.