From 8bb9ef8d8bb77199a42da12049defa1deb7ac950 Mon Sep 17 00:00:00 2001
From: Peder Hovdan Andresen <107681714+pederhan@users.noreply.github.com>
Date: Tue, 21 Jan 2025 12:19:49 +0100
Subject: [PATCH] Fix import of removed httpx type (#103)
---
CHANGELOG.md | 6 +++++-
harborapi/client.py | 14 +++++++-------
pyproject.toml | 2 +-
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7af87fa9..46601a05 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,11 @@ While the project is still on major version 0, breaking changes may be introduce
-
+## Unreleased
+
+### Fixed
+
+- Missing import error when using httpx>=0.28.0. ([#102](https://github.com/unioslo/harborapi/issues/102))
## [0.26.1](https://github.com/unioslo/harborapi/tree/harborapi-v0.26.1) - 2024-11-26
diff --git a/harborapi/client.py b/harborapi/client.py
index c81ca9b2..8e8e3c21 100644
--- a/harborapi/client.py
+++ b/harborapi/client.py
@@ -2,6 +2,7 @@
import contextlib
import os
+import ssl
import warnings
from http.cookiejar import CookieJar
from pathlib import Path
@@ -22,7 +23,6 @@
import httpx
from httpx import Response
from httpx import Timeout
-from httpx._types import VerifyTypes
from pydantic import BaseModel
from pydantic import SecretStr
from pydantic import ValidationError
@@ -184,7 +184,7 @@ def __init__(
# HTTPX client options
follow_redirects: bool = True,
timeout: Union[float, Timeout] = 10.0,
- verify: VerifyTypes = True,
+ verify: Union[ssl.SSLContext, str, bool] = True,
# Retry options
retry: Optional[RetrySettings] = RetrySettings(), # type: ignore[call-arg]
**kwargs: Any,
@@ -226,10 +226,10 @@ def __init__(
timeout : Union[float, Timeout]
The timeout to use for requests.
Can be either a float or a `httpx.Timeout` object.
- verify : VerifyTypes
+ verify : Union[ssl.SSLContext, str, bool]
Control verification of the server's TLS certificate.
- See `httpx._types.VerifyTypes` for more information or
- .
+ Can be an SSL context, a path to a CA bundle, or a boolean.
+ Defaults to True.
**kwargs : Any
Backwards-compatibility with deprecated parameters.
Unknown kwargs are ignored.
@@ -271,7 +271,7 @@ def authenticate(
basicauth: Optional[str] = None,
credentials_file: Optional[Union[str, Path]] = None,
url: Optional[str] = None,
- verify: Optional[VerifyTypes] = None,
+ verify: Optional[Union[ssl.SSLContext, str, bool]] = None,
**kwargs: Any,
) -> None:
"""(Re-)Authenticate the client with the provided credentials.
@@ -291,7 +291,7 @@ def authenticate(
`username`, `secret` and `basicauth` must not be provided if this is used.
url : Optional[str]
The URL of the Harbor server in the format `http://host:[port]/api/v`
- verify : Optional[VerifyTypes]
+ verify : Optional[Union[ssl.SSLContext, str, bool]]
Control verification of the server's TLS certificate.
**kwargs : Any
Additional keyword arguments to pass in.
diff --git a/pyproject.toml b/pyproject.toml
index 89a7cdaa..a7336e09 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -29,7 +29,7 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
- "httpx>=0.22.0",
+ "httpx>=0.28.1",
"pydantic>=2.2.1",
"backoff>=2.1.2",
"typing_extensions>=4.4.0",