Skip to content

Commit

Permalink
Don't assume that pydantic.HttpUrl is a str subclass
Browse files Browse the repository at this point in the history
In Pydantic v2, `pydantic.HttpUrl` is no longer a subclass of `str`, so
it's necessary to coerce it into a str for functions that expect that.

Relates: ansible-community/antsibull-core#119
  • Loading branch information
gotmax23 committed Dec 1, 2023
1 parent fbd6ba2 commit a8182e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/antsibull/build_ansible_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def prepare_command() -> int:
get_collection_and_core_versions(
deps,
ansible_core_version_obj,
app_ctx.galaxy_url,
str(app_ctx.galaxy_url),
ansible_core_allow_prerelease=_is_alpha(app_ctx.extra["ansible_version"]),
constraints=constraints,
)
Expand Down Expand Up @@ -613,7 +613,7 @@ def rebuild_single_command() -> int:
asyncio.run(
download_collections(
included_versions,
app_ctx.galaxy_url,
str(app_ctx.galaxy_url),
download_dir,
app_ctx.collection_cache,
)
Expand Down
2 changes: 2 additions & 0 deletions src/antsibull/cli/antsibull_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ def run(args: list[str]) -> int:

context_data = app_context.create_contexts(args=parsed_args, cfg=cfg)
with app_context.app_and_lib_context(context_data) as (app_ctx, dummy_):
# TODO: Call `model_dump()` instead of deprecated `dict()`
# once support for pydantic v1/antsibull-core v2 is dropped
twiggy.dict_config(app_ctx.logging_cfg.dict())
flog.debug("Set logging config")

Expand Down
2 changes: 1 addition & 1 deletion src/antsibull/new_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def new_ansible_command() -> int:
os.path.join(app_ctx.extra["data_dir"], app_ctx.extra["pieces_file"])
)
ansible_core_release_infos, dependencies = asyncio.run(
get_version_info(collections, app_ctx.pypi_url)
get_version_info(collections, str(app_ctx.pypi_url))
)
ansible_core_versions = [
(PypiVer(version), data[0]["requires_python"])
Expand Down

0 comments on commit a8182e4

Please sign in to comment.