From 7d27113ce45c4224c2e0b776ad5c031951b05568 Mon Sep 17 00:00:00 2001 From: Christodoulos Tsoulloftas Date: Sun, 22 Dec 2024 08:58:36 +0200 Subject: [PATCH 1/3] Deprecate xsdata shorthand --- README.md | 2 +- docs/codegen/config.md | 2 +- docs/codegen/dtd_modeling.md | 2 +- docs/codegen/intro.md | 8 ++++---- docs/codegen/samples_modeling.md | 4 ++-- docs/codegen/wsdl_modeling.md | 2 +- docs/plugins/how_to.md | 2 +- tests/test_cli.py | 2 +- xsdata/cli.py | 15 ++++++++++++++- 9 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ec14b654f..ae00e7f81 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ $ pip install xsdata[cli,lxml,soap] ```console $ # Generate models -$ xsdata tests/fixtures/primer/order.xsd --package tests.fixtures.primer +$ xsdata generate tests/fixtures/primer/order.xsd --package tests.fixtures.primer ``` ```python diff --git a/docs/codegen/config.md b/docs/codegen/config.md index dfc731e22..3c65cf5f6 100644 --- a/docs/codegen/config.md +++ b/docs/codegen/config.md @@ -26,7 +26,7 @@ print(output.getvalue()) **Usage** ```console -$ xsdata --config project/.xsdata.xml +$ xsdata generate --config project/.xsdata.xml ``` !!! Info "CLI options override the project configuration settings." diff --git a/docs/codegen/dtd_modeling.md b/docs/codegen/dtd_modeling.md index e6219cc8b..d4d9da1ca 100644 --- a/docs/codegen/dtd_modeling.md +++ b/docs/codegen/dtd_modeling.md @@ -15,7 +15,7 @@ $ pip install xsdata[lxml] ## Example ```console -$ xsdata --package tests.fixtures.dtd.models tests/fixtures/dtd/complete_example.dtd +$ xsdata generate --package tests.fixtures.dtd.models tests/fixtures/dtd/complete_example.dtd ``` === "DTD Definition" diff --git a/docs/codegen/intro.md b/docs/codegen/intro.md index 87d620b44..43839639f 100644 --- a/docs/codegen/intro.md +++ b/docs/codegen/intro.md @@ -27,13 +27,13 @@ You can instruct the cli to search all subdirectories recursively with the `-r, --recursive` flag. ```console -$ xsdata project/schemas -$ xsdata project/schemas --recursive +$ xsdata generate project/schemas +$ xsdata generate project/schemas --recursive ``` ## Use a filename or URI as source ```console -$ xsdata project/schemas/feed.xsd -$ xsdata http://www.gstatic.com/localfeed/local_feed.xsd +$ xsdata generate project/schemas/feed.xsd +$ xsdata generate http://www.gstatic.com/localfeed/local_feed.xsd ``` diff --git a/docs/codegen/samples_modeling.md b/docs/codegen/samples_modeling.md index e4bc88844..67f16d85b 100644 --- a/docs/codegen/samples_modeling.md +++ b/docs/codegen/samples_modeling.md @@ -8,7 +8,7 @@ merge and flatten duplicate classes, fields and field types. ## XML Documents ```console -$ xsdata --package tests.fixtures.artists tests/fixtures/artists +$ xsdata generate --package tests.fixtures.artists tests/fixtures/artists ``` === "Sample #1" @@ -38,7 +38,7 @@ $ xsdata --package tests.fixtures.artists tests/fixtures/artists ## JSON Documents ```console -$ xsdata --package tests.fixtures.series tests/fixtures/series/samples +$ xsdata generate --package tests.fixtures.series tests/fixtures/series/samples ``` === "Sample #1" diff --git a/docs/codegen/wsdl_modeling.md b/docs/codegen/wsdl_modeling.md index 63fc1ef6f..de8445b89 100644 --- a/docs/codegen/wsdl_modeling.md +++ b/docs/codegen/wsdl_modeling.md @@ -13,7 +13,7 @@ $ pip install xsdata[cli,soap] ``` ```console -$ xsdata --package calculator http://www.dneonline.com/calculator.asmx?WSDL +$ xsdata generate --package calculator http://www.dneonline.com/calculator.asmx?WSDL ``` ## Message Model diff --git a/docs/plugins/how_to.md b/docs/plugins/how_to.md index 0a6318954..d19472f20 100644 --- a/docs/plugins/how_to.md +++ b/docs/plugins/how_to.md @@ -21,7 +21,7 @@ CodeWriter.register_generator("awesome", AwesomeGenerator) Which can be used during code generation. ```console -$ xsdata --output awesome +$ xsdata generate --output awesome ``` ## `xsdata.plugins.class_types` diff --git a/tests/test_cli.py b/tests/test_cli.py index a8326e98d..b9e5a45e8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -53,7 +53,7 @@ def test_generate_with_error(self, mock_process): mock_process.side_effect = CodegenError("Testing", foo="bar") source = fixtures_dir.joinpath("defxmlschema/chapter03.xsd") - result = self.runner.invoke(cli, [str(source), "--package", "foo"]) + result = self.runner.invoke(cli, ["generate", str(source), "--package", "foo"]) expected = "=========\n" "Error: Testing\n" "foo: bar\n" self.assertIn(expected, result.output) diff --git a/xsdata/cli.py b/xsdata/cli.py index 3be1c8f43..9b32e0a02 100644 --- a/xsdata/cli.py +++ b/xsdata/cli.py @@ -36,7 +36,20 @@ logging.captureWarnings(True) -@click.group(cls=DefaultGroup, default="generate", default_if_no_args=False) +class DeprecatedDefaultGroup(DefaultGroup): + """Deprecated default group.""" + + def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command: + """Override to deprecate xsdata shorthand.""" + if cmd_name not in self.commands: + logger.warning( + "`xsdata ` is deprecated. " + "Use `xsdata generate ` instead." + ) + return super().get_command(ctx, cmd_name) + + +@click.group(cls=DeprecatedDefaultGroup, default="generate", default_if_no_args=False) @click.pass_context @click.version_option(__version__) def cli(ctx: click.Context, **kwargs: Any): From 709da36c2a263a393fdc809aaaf6f8052bd280e4 Mon Sep 17 00:00:00 2001 From: Christodoulos Tsoulloftas Date: Sun, 22 Dec 2024 08:59:18 +0200 Subject: [PATCH 2/3] Update pre-commit hooks --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index daea7b66a..fb356ec3f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,18 +8,18 @@ repos: - id: end-of-file-fixer - id: debug-statements - repo: https://github.com/crate-ci/typos - rev: v1.28.2 + rev: v1.28.4 hooks: - id: typos exclude: ^tests/|.xsd|xsdata/models/datatype.py$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.2 + rev: v0.8.4 hooks: - id: ruff args: [ --fix, --show-fixes] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v1.14.0 hooks: - id: mypy files: ^(xsdata/) From 21d72c7d8ec671ee26c95fa6e7b284598773111f Mon Sep 17 00:00:00 2001 From: Christodoulos Tsoulloftas Date: Sun, 22 Dec 2024 09:08:13 +0200 Subject: [PATCH 3/3] Bump version 24.12 --- CHANGES.md | 27 +++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++------ xsdata/__init__.py | 2 +- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e38037911..44fcf45d1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,30 @@ +## 24.12 (2024-12-22) + +**Fixes** + +- Set the default value of prohibited fields to None + ([#1098](https://github.com/tefra/xsdata/pull/1098)) + +- Set body and fault as optional in output soap classes + ([#1099](https://github.com/tefra/xsdata/pull/1099)) + +- Resolve a conflict with type location when an element and a complex type have the same + name ([#1107](https://github.com/tefra/xsdata/pull/1107)) + +**Features** + +- Allow Xml Parser subclasses to override how the root class is located + ([#1090](https://github.com/tefra/xsdata/pull/1090)) + +- Include common soap encoding schema + ([#1100](https://github.com/tefra/xsdata/pull/1100)) + +**Deprecations** + +- Remove subscritable types config option +- Remove Type,Tuple,List,Dict from stop words +- Deprecate xsdata shorthand, use xsdata generate instead + ## 24.11 (2024-11-03) **Fixes** diff --git a/README.md b/README.md index ae00e7f81..d6d5b1e63 100644 --- a/README.md +++ b/README.md @@ -74,18 +74,29 @@ Check the [documentation](https://xsdata.readthedocs.io) for more ✨✨✨ - Support xinclude statements and unknown properties - Customize behaviour through config -## Changelog: 24.11 (2024-11-03) +## Changelog: 24.12 (2024-12-22) **Fixes** -- Avoid conflict with attributes named value when flattening extensions - ([#1085](https://github.com/tefra/xsdata/pull/1085)) +- Set the default value of prohibited fields to None + ([#1098](https://github.com/tefra/xsdata/pull/1098)) + +- Set body and fault as optional in output soap classes + ([#1099](https://github.com/tefra/xsdata/pull/1099)) + +- Resolve a conflict with type location when an element and a complex type have the same + name ([#1107](https://github.com/tefra/xsdata/pull/1107)) **Features** -- Add cli config to use generic collections - ([#1082](https://github.com/tefra/xsdata/pull/1082)) +- Allow Xml Parser subclasses to override how the root class is located + ([#1090](https://github.com/tefra/xsdata/pull/1090)) + +- Include common soap encoding schema + ([#1100](https://github.com/tefra/xsdata/pull/1100)) **Deprecations** -- Drop support for python 3.8 +- Remove subscritable types config option +- Remove Type,Tuple,List,Dict from stop words +- Deprecate xsdata shorthand, use xsdata generate instead diff --git a/xsdata/__init__.py b/xsdata/__init__.py index 580232f75..aa02de839 100644 --- a/xsdata/__init__.py +++ b/xsdata/__init__.py @@ -1 +1 @@ -__version__ = "24.11" +__version__ = "24.12"