Skip to content

Commit

Permalink
wraps to carry docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Dec 13, 2024
1 parent 682c86b commit 2b0c813
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/atproto_client/models/string_formats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
from datetime import datetime
from functools import wraps
from typing import Callable, Mapping, Set, Union, cast
from urllib.parse import urlparse

Expand Down Expand Up @@ -54,7 +55,8 @@
def only_validate_if_strict(validate_fn: Callable[..., str]) -> Callable[..., str]:
"""Skip pydantic validation if not opting into strict validation via context."""

# Could likely be generalized to support arbitrary signatures.
# Wrapper could be likely be generalized to support other signatures
@wraps(validate_fn)
def wrapper(v: str, info: ValidationInfo) -> str:
if info and isinstance(info.context, Mapping) and info.context.get(_OPT_IN_KEY, False):
return cast(core_schema.NoInfoValidatorFunction, validate_fn)(v)
Expand Down

0 comments on commit 2b0c813

Please sign in to comment.