Skip to content

Commit

Permalink
Use pydantic dataclass instead of stdlib dataclass
Browse files Browse the repository at this point in the history
Pydantic's dataclass does not complain about optional attributes before
required attributes, so we can drop `--kw-only` from the `xsdata` call
(which is now `xsdata ../xsd/galaxy.xsd --unnest-classes --output
pydantic --docstring-style Accessible --ignore-patterns
--max-line-length 10000 && python postprocess_schema.py && python
test_file_from_xsd.py > test_file_schema.json && cd ~/src/galaxy && make
format && cd -`)
  • Loading branch information
mvdbeek committed Dec 6, 2023
1 parent 76ccbd0 commit 54a4697
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/galaxy/tool_util/schemas/generated/galaxy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from dataclasses import (
dataclass,
field,
)
from dataclasses import field
from decimal import Decimal
from enum import Enum
from typing import (
Expand All @@ -10,6 +7,8 @@
Union,
)

from pydantic.dataclasses import dataclass

from .config import (
BaseSetting,
ClassCollectionField,
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/schemas/test_file_from_xsd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import json
from dataclasses import dataclass
from typing import Union

# bug with pydantic, need everything in namespace, otherwise fails with
Expand All @@ -17,6 +16,7 @@
ConfigDict,
RootModel,
)
from pydantic.dataclasses import dataclass

extra_forbidden = ConfigDict(extra="forbid")

Expand Down
Loading

0 comments on commit 54a4697

Please sign in to comment.