Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python: ["3.11", "3.12", "3.13", "3.14", "3.15"]
collection:
- { name: "Amadeus", id: "amadeus" }
- { name: "Autosar", id: "autosar" }
Expand All @@ -37,11 +37,11 @@ jobs:
- { name: "Voko", id: "voko" }
- { name: "XCBL", id: "xcbl" }
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
exclude: "models|output|samples"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
rev: v0.17.1
hooks:
- id: ruff-check
args: [ --fix, --show-fixes ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
rev: v2.4.0
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -18,7 +18,7 @@ repos:
hooks:
- id: doc8
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.8.1
rev: v3.9.10
hooks:
- id: prettier
types_or: [markdown]
Expand Down
6 changes: 4 additions & 2 deletions amadeus/test_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from lxml import etree

from amadeus.models import FareMasterPricerTravelBoardSearch
from amadeus.models import FareMasterPricerTravelBoardSearchReply
from amadeus.models import (
FareMasterPricerTravelBoardSearch,
FareMasterPricerTravelBoardSearchReply,
)

cwd = Path(__file__).parent.absolute()
xsd_location = str(
Expand Down
7 changes: 2 additions & 5 deletions bnm/test_xrates.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from pathlib import Path
from unittest import mock
from unittest import TestCase
from unittest import TestCase, mock

from requests import Response

from bnm.xrates import Currencies
from bnm.xrates import Currency
from bnm.xrates import fetch
from bnm.xrates import Currencies, Currency, fetch


class FetchTest(TestCase):
Expand Down
25 changes: 11 additions & 14 deletions bnm/xrates.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import datetime
from dataclasses import asdict
from dataclasses import dataclass
from dataclasses import field
from dataclasses import asdict, dataclass, field
from decimal import Decimal
from typing import List

import requests
from xsdata.formats.dataclass.parsers import XmlParser
Expand All @@ -13,23 +10,23 @@

@dataclass
class Currency:
id: int = field(metadata=dict(type="Attribute", name="ID"))
name: str = field(metadata=dict(type="Element", name="Name"))
num_code: int = field(metadata=dict(type="Element", name="NumCode"))
iso_code: str = field(metadata=dict(type="Element", name="CharCode"))
nominal: int = field(metadata=dict(type="Element", name="Nominal"))
value: Decimal = field(metadata=dict(type="Element", name="Value"))
id: int = field(metadata={"type": "Attribute", "name": "ID"})
name: str = field(metadata={"type": "Element", "name": "Name"})
num_code: int = field(metadata={"type": "Element", "name": "NumCode"})
iso_code: str = field(metadata={"type": "Element", "name": "CharCode"})
nominal: int = field(metadata={"type": "Element", "name": "Nominal"})
value: Decimal = field(metadata={"type": "Element", "name": "Value"})


@dataclass
class Currencies:
class Meta:
name = "ValCurs"

date: str = field(metadata=dict(type="Attribute", name="Date"))
name: str = field(metadata=dict(type="Attribute"))
values: List[Currency] = field(
default_factory=list, metadata=dict(type="Element", name="Valute")
date: str = field(metadata={"type": "Attribute", "name": "Date"})
name: str = field(metadata={"type": "Attribute"})
values: list[Currency] = field(
default_factory=list, metadata={"type": "Element", "name": "Valute"}
)


Expand Down
3 changes: 1 addition & 2 deletions bpmn/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from typing import Dict

from bpmn.models import Definitions

Expand All @@ -10,7 +9,7 @@ def test_waypoint_example(xml_parser, xml_serializer):
fixture = "example"
xml_fixture = cwd.joinpath(f"{fixture}.xml")
xsdata_fixture = cwd.joinpath(f"{fixture}.xsdata.xml")
ns_map: Dict = {}
ns_map: dict = {}
obj = xml_parser.from_path(xml_fixture, Definitions, ns_map)
result = xml_serializer.render(obj, ns_map=ns_map)

Expand Down
14 changes: 7 additions & 7 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

import pytest
from xsdata.formats.dataclass.context import XmlContext
from xsdata.formats.dataclass.parsers import JsonParser
from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.serializers import JsonSerializer
from xsdata.formats.dataclass.serializers import PycodeSerializer
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.parsers import JsonParser, XmlParser
from xsdata.formats.dataclass.serializers import (
JsonSerializer,
PycodeSerializer,
TreeSerializer,
XmlSerializer,
)
from xsdata.formats.dataclass.serializers.config import SerializerConfig
from xsdata.formats.dataclass.serializers import TreeSerializer
from xsdata.utils.debug import convert


_session_context_data: dict[str, Any] = {}


Expand Down
5 changes: 2 additions & 3 deletions generali/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pathlib import Path
from typing import Dict

from generali.models.com.generali.enterprise_services.core.gbm.enterprise.agreement.v1 import ( # noqa
from generali.models.com.generali.enterprise_services.core.gbm.enterprise.agreement.v1 import (
NotifyProgramGbmrequest,
)

Expand All @@ -12,7 +11,7 @@ def test_parser(xml_parser, xml_serializer):
fixture = "example"
xml_fixture = cwd.joinpath(f"{fixture}.xml")
xsdata_fixture = cwd.joinpath(f"{fixture}.xsdata.xml")
ns_map: Dict = {}
ns_map: dict = {}
obj = xml_parser.from_path(xml_fixture, NotifyProgramGbmrequest, ns_map)
result = xml_serializer.render(obj, ns_map)

Expand Down
5 changes: 2 additions & 3 deletions ipxact/test_bindings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from pathlib import Path
from typing import Dict

import pytest
from lxml import etree
from lxml.etree import DocumentInvalid

from ipxact.models import * # noqa
from ipxact.models import *

here = Path(__file__).parent
output = here.joinpath("output")
Expand All @@ -19,7 +18,7 @@

@pytest.mark.parametrize("sample", samples)
def test_bindings(sample, xml_parser, xml_serializer, code_serializer):
ns_map: Dict = {}
ns_map: dict = {}
obj = xml_parser.from_path(examples.joinpath(sample), ns_map=ns_map)
result = xml_serializer.render(obj, ns_map=ns_map)
code = code_serializer.render(obj)
Expand Down
11 changes: 6 additions & 5 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[tools]
python = "3.13"

python = "3.11"
uv = "latest"

[env]
_.python.venv = { path = ".venv", create = true }


[settings]
python.venv_stdlib = true
[tasks.install]
description = "Install dependencies"
alias = "i"
run = "uv pip install -r requirements.txt"
6 changes: 6 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ ignore_missing_imports = True

[mypy-typed_dataclass.*]
ignore_missing_imports = True

[mypy-generali.models.*]
ignore_errors = True

[mypy-sdmx_ml.models.*]
ignore_errors = True
13 changes: 6 additions & 7 deletions netex/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
import time
from contextlib import contextmanager
from pathlib import Path
from typing import Any
from sys import getsizeof
from typing import Any

from xsdata.formats.dataclass.context import XmlContext
from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.parsers.config import ParserConfig
from xsdata.formats.dataclass.parsers.handlers import LxmlEventHandler
from xsdata.formats.dataclass.parsers.handlers import XmlEventHandler
from xsdata.formats.dataclass.parsers.handlers import LxmlEventHandler, XmlEventHandler


@contextmanager
Expand All @@ -32,7 +31,7 @@ def get_size(obj, seen=None):
seen.add(obj_id)
if isinstance(obj, dict):
size += sum(get_size(v, seen) for v in obj.values())
size += sum(get_size(k, seen) for k in obj.keys())
size += sum(get_size(k, seen) for k in obj)
elif hasattr(obj, "__dict__"):
size += get_size(obj.__dict__, seen)
elif hasattr(obj, "__iter__") and not isinstance(obj, (str, bytes, bytearray)):
Expand All @@ -41,18 +40,18 @@ def get_size(obj, seen=None):


with timing("importing module"):
from netex.models import * # noqa
from netex.models import *

sample = str(Path(__file__).parent.joinpath("NeTEx_HTM__2020-10-12.tar.xz"))
with timing("decompress sample"):
subprocess.run(["tar", "-xf", sample, "-C", "/tmp"])
subprocess.run(["tar", "-xf", sample, "-C", "/tmp"], check=True)

sample = "/tmp/NeTEx_HTM__2020-10-12.xml"
context = XmlContext()
config = ParserConfig(fail_on_unknown_properties=False)


from netex.models import PublicationDelivery # noqa
from netex.models import PublicationDelivery

with timing("XmlContext warmup"):
context.build_recursive(PublicationDelivery)
Expand Down
3 changes: 1 addition & 2 deletions netex/test_bindings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from typing import Dict

import pytest
from lxml import etree
Expand All @@ -17,7 +16,7 @@

@pytest.mark.parametrize("sample", samples)
def test_bindings(sample, xml_parser, xml_serializer, code_serializer):
ns_map: Dict = {}
ns_map: dict = {}
obj = xml_parser.from_path(functions.joinpath(sample), PublicationDelivery, ns_map)
result = xml_serializer.render(obj, ns_map=ns_map)
code = code_serializer.render(obj)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
invoke
mypy
types-dataclasses
pytest
pre-commit
requests
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
target-version = "py310"
target-version = "py311"
2 changes: 1 addition & 1 deletion sabre/test_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from lxml import etree
from xsdata.formats.dataclass.serializers import DictFactory

from sabre.models import OtaAirLowFareSearchRs, OtaAirLowFareSearchRq
from sabre.models import OtaAirLowFareSearchRq, OtaAirLowFareSearchRs

cwd = Path(__file__).parent.absolute()
xsd_location = str(cwd.joinpath("schemas/BargainFinderMaxRQ_v1-9-7.xsd"))
Expand Down
5 changes: 2 additions & 3 deletions sdmx_ml/test_bindings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from pathlib import Path
from typing import Dict

import pytest
from lxml import etree

from sdmx_ml.models import * # noqa
from sdmx_ml.models import *

here = Path(__file__).parent
output = here.joinpath("output")
Expand All @@ -19,7 +18,7 @@

@pytest.mark.parametrize("sample", samples)
def test_bindings(sample, xml_parser, xml_serializer, code_serializer):
ns_map: Dict = {}
ns_map: dict = {}
sample_xml = samples_dir.joinpath(sample).read_bytes()
obj = xml_parser.from_bytes(sample_xml)
result = xml_serializer.render(obj, ns_map=ns_map)
Expand Down
3 changes: 1 addition & 2 deletions spacex/test_bindings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from typing import List

from spacex.models import Launches

Expand All @@ -8,7 +7,7 @@

def test_parser(json_parser, json_serializer):
sample = here.joinpath("launches.json")
launches = json_parser.from_path(sample, List[Launches])
launches = json_parser.from_path(sample, list[Launches])

assert 145 == len(launches)

Expand Down
12 changes: 5 additions & 7 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import sys
from typing import Iterator
from collections.abc import Iterator

from invoke import task, Context, Collection
from invoke import Collection, Context, task

# ANSI color codes for suite prefixes (similar to docker-compose)
COLORS = [
Expand Down Expand Up @@ -55,7 +55,7 @@ def get_suite(c: Context, suite: str | None = None) -> Iterator[str]:

def get_prefix(suite: str) -> str:
"""Get a colored prefix for a suite."""
max_suite_len = max(len(s) for s in SUITES.keys())
max_suite_len = max(len(s) for s in SUITES)
suite_index = list(SUITES.keys()).index(suite)
color = COLORS[suite_index % len(COLORS)]
return f"{color}[{suite:<{max_suite_len}}]{RESET}"
Expand Down Expand Up @@ -150,9 +150,7 @@ async def run_suite_all(
return False
if not await run_suite_test(suite, output_format, dump_context):
return False
if not await run_suite_mypy(suite):
return False
return True
return await run_suite_mypy(suite)


def print_summary(results: dict[str, bool], task_name: str) -> bool:
Expand Down Expand Up @@ -301,7 +299,7 @@ def config(c: Context, suite: str | None = None):
ns.add_task(test)
ns.add_task(config)

for key in SUITES.keys():
for key in SUITES:
collection = Collection(key)
collection.add_task(build)
collection.add_task(test)
Expand Down
Loading
Loading