Commit Graph
14 Commits
Author SHA1 Message Date
Nicola Soranzo 7f89e0eab9 Code cleanups from pyupgrade
Found by running:

```
make pyupgrade
ruff check --fix .
ruff check --preview --unsafe-fixes --select=F401 --fix .
make format
make update-client-api-schema
```

The bulk of the changes are replacements of typing deprecated aliases
such as `Dict` and `List` with the standard library classes. These
aliases became redundant in Python 3.9 when the corresponding
pre-existing classes were enhanced to support `[]`, see
https://docs.python.org/3/library/typing.html#deprecated-aliases

Also:
- Update the `pyupgrade` Makefile target to use `--py38-plus` for the
  packages needed by Pulsar, including the new galaxy-tool-util-models
  package.
2025-07-31 11:17:22 +01:00
mvdbeek 384dfc8b4e Make conditional discriminators literals instead of generic string/bool
That's a much better consumer experience. A model generated for
gx_conditional.xml would look like
```typescript
export type ConditionalType =
  | WhenTestParameterA
  | WhenTestParameterB
  | WhenTestParameterC
export type TestParameter = "a"
export type IntegerParameter = number
export type TestParameter1 = "b"
export type BooleanParameter = boolean
export type TestParameter2 = "c"
export type ColorParameter = string

export interface MySchema {
  conditional_parameter: ConditionalType
}
export interface WhenTestParameterA {
  test_parameter: TestParameter
  integer_parameter: IntegerParameter
}
export interface WhenTestParameterB {
  test_parameter: TestParameter1
  boolean_parameter: BooleanParameter
}
export interface WhenTestParameterC {
  test_parameter: TestParameter2
  color_parameter: ColorParameter
}

```
instead of
```typescript
export type ConditionalType =
  | WhenTestParameterA
  | WhenTestParameterB
  | WhenTestParameterC
export type TestParameter = string | boolean
export type IntegerParameter = number
export type TestParameter1 = string | boolean
export type BooleanParameter = boolean
export type TestParameter2 = string | boolean
export type ColorParameter = string

export interface MySchema {
  conditional_parameter: ConditionalType
}
export interface WhenTestParameterA {
  test_parameter: TestParameter
  integer_parameter: IntegerParameter
}
export interface WhenTestParameterB {
  test_parameter: TestParameter1
  boolean_parameter: BooleanParameter
}
export interface WhenTestParameterC {
  test_parameter: TestParameter2
  color_parameter: ColorParameter
}

```
With the new model I can write an input object without looking at the
tool source, with the previous one I don't know what string I would need
to supply.
2025-01-03 16:17:49 +02:00
Nicola Soranzo 78234720c4 Replace deprecated `__package__ with __name__
`__package__` is deprecated since Python 3.13, see
https://docs.python.org/3/reference/datamodel.html#module.__package__

`importlib.resources.files()` can be passed a non-package module
since Python 3.12 (or importlib-resources 5.10.0, see
https://importlib-resources.readthedocs.io/en/latest/history.html#v5-10-0 ),
so we can use `__name__` instead of `__package__`.

Also, I noticed that in lib/galaxy/config/__init__.py we are passing
a directory to `importlib.resources.as_file()`, which is supported
only since Python 3.12 (or importlib-resources 5.9.0).

For the reasons above:
- Update conditional imports in `lib/galaxy/util/resources.py` to
  import from `importlib.resources` only for Python 3.12,
  otherwise from the importlib-resources package.
- Update importlib-resources requirement in galaxy-util package.
- Drop importlib-resources requirement from galaxy-web-apps as it's
  not imported directly from its code any more.
2024-12-16 15:16:41 +00:00
John Chilton c198c7cb97 models for tool landing request state... 2024-10-22 07:49:37 -04:00
John Chilton 7ef5cc22e4 Refactor for reuse in galaxy.tool_util.parameters. 2024-10-22 07:49:37 -04:00
John Chilton ad73e9e838 Tool Request models. 2024-09-30 13:25:02 -04:00
John Chilton 0a35eea309 Tool test case parameter models. 2024-08-23 09:46:44 -04:00
John Chilton da220efd23 First pass at workflow step models - linked and unlinked.
Work scoped out in 18536.
2024-08-23 09:46:44 -04:00
John Chilton 384a30728c Validate wild static select with no options. 2024-08-09 12:47:55 -04:00
John Chilton e8e569f820 Work toward data column support in tool parameter meta models. 2024-08-05 18:37:24 -04:00
John Chilton a9343f336b Refactor parameter unit testing to be more general. 2024-08-05 18:37:24 -04:00
John Chilton c5c4ba39b8 Simplify test_parameter_specification a bit. 2024-08-05 09:44:43 -04:00
Nicola Soranzo 359bcfeec8 Fixes for errors reported by mypy 1.11.0 2024-08-01 18:13:27 +01:00
John Chilton 5359f8ba74 Input parameter schema. 2024-07-15 09:46:13 -04:00