feat: update dependencies and capture network errors when retrieving remote public keys

This commit is contained in:
cătălin 2024-05-17 19:05:44 +02:00
commit 812fee592e
No known key found for this signature in database
4 changed files with 30 additions and 21 deletions

View file

@ -1 +1 @@
__version__ = "0.4.5"
__version__ = "0.4.6"

View file

@ -9,6 +9,7 @@ import yaml
from pydantic import DirectoryPath, Field, FilePath, HttpUrl, field_validator
from pydantic_core import Url
from pydantic_settings import BaseSettings, SettingsConfigDict
from rich import print
class Settings(BaseSettings):
@ -82,17 +83,25 @@ class Settings(BaseSettings):
keys = set()
for path in self.recipient_paths:
if isinstance(path, Url):
with hishel.CacheClient(
storage=hishel.FileStorage(base_path=self.cache_path / "hishel"),
) as client:
response = client.get(
str(path),
timeout=self.remote_public_keys_timeout,
try:
with hishel.CacheClient(
storage=hishel.FileStorage(
base_path=self.cache_path / "hishel"
),
timeout=3,
) as client:
response = client.get(
str(path),
timeout=self.remote_public_keys_timeout,
)
if response.status_code == httpx.codes.OK:
for line in response.content.decode().split("\n"):
if line:
keys.add(line)
except Exception as e: # noqa: BLE001
print(
f"[yellow] Could not retrieve public key from {path}. Ignoring error: '{e}'"
)
if response.status_code == httpx.codes.OK:
for line in response.content.decode().split("\n"):
if line:
keys.add(line)
elif isinstance(path, Path):
with path.open("r") as f:
keys.add(f.read())

2
pdm.lock generated
View file

@ -5,7 +5,7 @@
groups = ["default", "docs", "linting", "testing", "dev"]
strategy = ["cross_platform"]
lock_version = "4.4.1"
content_hash = "sha256:7ac93593b9b93325db09d2e6d1121558b1f40de0891790971deae7531e2b5955"
content_hash = "sha256:386a15bb1ebd589f1aa4e7f9ebf6f5795e3219716277e28fdbd0a4c9a86465fa"
[[package]]
name = "annotated-types"

View file

@ -4,16 +4,16 @@ authors = [
]
requires-python = ">=3.10"
dependencies = [
"typer<1.0.0,>=0.6.1",
"typer>=0.12",
"rich>=13.3.3",
"pydantic>=2.0.3",
"pydantic>=2.7",
"pyyaml>=6.0",
"pyrage>=1.1.1",
"pendulum>=2.1.2",
"httpx>=0.24.0",
"platformdirs>=3.5.1",
"pydantic-settings>=2.0.2",
"hishel>=0.0.17",
"pyrage>=1.1",
"pendulum>=3.0",
"httpx>=0.27",
"platformdirs>=4.2",
"pydantic-settings>=2.0",
"hishel>=0.0.26",
]
name = "halig"
dynamic = ["version"]
@ -90,7 +90,7 @@ reportAttributeAccessIssue = false
[tool.ruff.lint]
extend-select = ["W", "C90", "I", "N", "UP", "S", "BLE", "B", "A", "COM", "C4", "DTZ", "T10", "EM", "ISC", "T20", "PT", "RSE", "RET", "SIM", "PTH", "ERA", "PGH", "PL", "TRY", "RUF"]
extend-ignore = ["S101", "ISC002"]
extend-ignore = ["S101", "ISC002", "COM812", "ISC001"]
[tool.mypy]
python_version = "3.11"