Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable warn_unreachable mypy option #17365

Merged
merged 18 commits into from Feb 12, 2024
Merged

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Jan 26, 2024

Haven't fixed all cases, see mypy.ini.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

Copy link
Member

@nsoranzo nsoranzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@@ -758,7 +758,7 @@ def get_tool(self, tool_id, tool_version=None, get_all_versions=False, exact=Fal
def has_tool(self, tool_id: str, tool_version: Optional[str] = None, exact: bool = False):
return self.get_tool(tool_id, tool_version=tool_version, exact=exact) is not None

def is_missing_shed_tool(self, tool_id: str) -> bool:
def is_missing_shed_tool(self, tool_id: Optional[str]) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the only place from which this is called ( lib/galaxy/webapps/galaxy/services/workflows.py ), the tool_id passed is never None, so maybe keep the previous annotation and drop lines 763-765?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

step.tool_id can be None, I don't think this is safe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right ...

lib/galaxy/tool_util/verify/__init__.py Show resolved Hide resolved
Comment on lines -330 to -335
args = []
args = [RuntimeContext(job_args)]
kwargs: Dict[str, str] = {}
if RuntimeContext is not None:
args.append(RuntimeContext(job_args))
else:
kwargs = job_args
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous code should be restored with a # type: ignore[unreachable] added to this last line, as RuntimeContext can be None in the tool-util package if the cwl extra is not specified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, but tool parsing would fail in https://github.com/mvdbeek/galaxy/blob/c713b37c588bba50ad7d7897632e36bc16215e4d/lib/galaxy/tool_util/cwl/parser.py#L342 too ... idk if this partial support approach makes sense ?

Copy link
Member Author

@mvdbeek mvdbeek Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

diff --git a/lib/galaxy/tool_util/cwl/parser.py b/lib/galaxy/tool_util/cwl/parser.py
index 3207eea965..ac71393c61 100644
--- a/lib/galaxy/tool_util/cwl/parser.py
+++ b/lib/galaxy/tool_util/cwl/parser.py
@@ -293,6 +293,7 @@ class ExpressionToolProxy(CommandLineToolProxy):

 class JobProxy:
     def __init__(self, tool_proxy, input_dict, output_dict, job_directory):
+        assert RuntimeContext is not None, "cwltool is not installed, cannot run CWL jobs"
         self._tool_proxy = tool_proxy
         self._input_dict = input_dict
         self._output_dict = output_dict

instead ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good for me. @jmchilton ?

@mvdbeek mvdbeek force-pushed the warn_unreachable branch 2 times, most recently from 267f497 to 214bffc Compare February 1, 2024 10:46
@mvdbeek mvdbeek merged commit 818c147 into galaxyproject:dev Feb 12, 2024
51 of 53 checks passed
@nsoranzo nsoranzo deleted the warn_unreachable branch February 12, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants