When enabling the `warn_unused_ignores = True` option of mypy, this
was making the `test_galaxy_packages` tests fail with:
```
mypy .
Traceback (most recent call last):
File "/tmp/gxpkgtestenvu3fgDr/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/tmp/gxpkgtestenvu3fgDr/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/main.py", line 100, in main
File "mypy/main.py", line 182, in run_build
File "mypy/build.py", line 192, in build
File "mypy/build.py", line 266, in _build
File "mypy/build.py", line 2942, in dispatch
File "mypy/build.py", line 3333, in process_graph
File "mypy/build.py", line 3414, in process_fresh_modules
File "mypy/build.py", line 2110, in fix_cross_refs
File "mypy/fixup.py", line 52, in fixup_module
File "mypy/fixup.py", line 127, in visit_symbol_table
File "mypy/lookup.py", line 49, in lookup_fully_qualified
AssertionError: Cannot find component 'util' for 'galaxy.util'
make: *** [Makefile:96: mypy] Error 1
```
Moreover, installing packages in editable mode was hiding some issues
with how files from other packages were accessed.
It is valid to pass None as a default value to the validator. It should
just return ValueError, which it will do with this change via the inner
validator.
Fixes https://github.com/galaxyproject/galaxy/issues/17961
Ideally we'd add type annotations, but with the current structure and
instantiation order it seems impossible to do this in a meaningful way.
If we refactored the validators to be functions, and validators
functions were registered per parameter type we could have narrow types on the
validator signature.
I doubt anyone instinctively know when to use `._state`, `.state`,
`.raw_set_dataset_state` or `.set_dataset_state` and I think that was
part of what led to this bug.
fixes#16947
also adds a setter to `MockApp` in order to fix the following
which was shown during tests
```
/home/berntm/projects/galaxy/.venv/lib/python3.10/site-packages/_pytest/threadexception.py:73: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-7 (check)
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/berntm/projects/galaxy/lib/galaxy/tool_util/toolbox/watcher.py", line 153, in check
self.reload_callback()
File "/home/berntm/projects/galaxy/lib/galaxy/app_unittest_utils/toolbox_support.py", line 44, in <lambda>
app.watchers.tool_config_watcher.reload_callback = lambda: reload_callback(test_case)
File "/home/berntm/projects/galaxy/lib/galaxy/app_unittest_utils/toolbox_support.py", line 193, in reload_callback
test_case._toolbox = test_case.app.toolbox = SimplifiedToolBox(test_case)
AttributeError: can't set attribute 'toolbox'
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
```