From 66ecb9ca46a5d57d6babcd17d43c7c89d6a8c21d Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 11 Nov 2023 19:30:19 -0500 Subject: [PATCH] fix: fix build by adding ruff unsafe-fixes and other build fixes (#229) --- mkdocs.yml | 4 ++-- pyproject.toml | 9 ++++++++- src/ome_autogen/main.py | 2 +- src/xsdata_pydantic_basemodel/generator.py | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 37d89576..658880fe 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -47,8 +47,8 @@ markdown_extensions: - pymdownx.superfences - tables - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg - toc: permalink: true diff --git a/pyproject.toml b/pyproject.toml index 8f5371ab..370030c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ test-qt = ["qtpy", "pytest-qt"] # requirements to run the autogen script in hatch_build.py require-runtime-dependencies = true # pin ruff for builds because it changes often -dependencies = ["black", "ruff ==0.0.291", "xsdata[cli]>=23.6"] +dependencies = ["black", "ruff ==0.1.5", "xsdata[cli]>=23.6"] # https://hatch.pypa.io/latest/config/metadata/ @@ -195,6 +195,13 @@ module = ['ome_types._autogenerated.ome_2016_06.structured_annotations'] # is incompatible with definition in base class "Sequence" disable_error_code = "misc" +[[tool.mypy.overrides]] +module = ['ome_types._autogenerated.*'] +# FIXME: this is because we use type hints from pydantic2 Field +# (via pydantic_compat ... cause that's what it forwards) +# but we *have* to use pydantic v1 syntax +disable_error_code = "call-arg" + # https://coverage.readthedocs.io/en/6.4/config.html [tool.coverage.report] exclude_lines = [ diff --git a/src/ome_autogen/main.py b/src/ome_autogen/main.py index 90b184c3..fe1479a4 100644 --- a/src/ome_autogen/main.py +++ b/src/ome_autogen/main.py @@ -64,7 +64,7 @@ def build_model( def _fix_formatting(package_dir: str, ruff_ignore: list[str] = RUFF_IGNORE) -> None: _print_gray("Running black and ruff ...") - ruff = ["ruff", "-q", "--fix", package_dir] + ruff = ["ruff", "-q", "--fix", "--unsafe-fixes", package_dir] ruff.extend(f"--ignore={ignore}" for ignore in ruff_ignore) subprocess.check_call(ruff) # noqa S diff --git a/src/xsdata_pydantic_basemodel/generator.py b/src/xsdata_pydantic_basemodel/generator.py index 77deafd1..c97669cb 100644 --- a/src/xsdata_pydantic_basemodel/generator.py +++ b/src/xsdata_pydantic_basemodel/generator.py @@ -75,6 +75,7 @@ def move_restrictions_to_pydantic_field( # The choice to use v1 syntax for cross-compatible mode has to do with # https://docs.pydantic.dev/usage/schema/#unenforced-field-constraints # There were more fields in v1 than in v2, so "min_length" is degenerate in v2 + # NOTE: ... this might be fixed by using pydantic_compat? if self.pydantic_support == "v2": use_v2 = True elif self.pydantic_support == "auto":