Skip to content

Commit da08dd2

Browse files
committed
fix: monkeypatching pydanclick to fix Python 2.10- compatibility
Until it is fixed and released upstream felix-martel/pydanclick#25
1 parent ca57e77 commit da08dd2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

scim2_cli/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import json
2+
from typing import Any
3+
from typing import TypeGuard
24

35
import click
46
from httpx import Client
7+
from pydantic import BaseModel
58
from scim2_client.engines.httpx import SyncSCIMClient
69
from scim2_models import Group
710
from scim2_models import User
@@ -16,6 +19,24 @@
1619
from scim2_cli.utils import DOC_URL
1720

1821

22+
# monkeypatching pydanclick until this patch is released
23+
# https://github.com/felix-martel/pydanclick/pull/25
24+
def patch_pydanclick():
25+
def _is_pydantic_model(model: Any) -> TypeGuard[type[BaseModel]]:
26+
"""Return True if `model` is a Pydantic `BaseModel` class."""
27+
try:
28+
return issubclass(model, BaseModel)
29+
except TypeError:
30+
return False
31+
32+
import pydanclick.model.field_collection
33+
34+
pydanclick.model.field_collection._is_pydantic_model = _is_pydantic_model
35+
36+
37+
patch_pydanclick()
38+
39+
1940
@click.group(cls=make_rst_to_ansi_formatter(DOC_URL, group=True))
2041
@click.argument("url")
2142
@click.pass_context

0 commit comments

Comments
 (0)