Skip to content

Commit 5ca5165

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore(internal): codegen related update (#52)
1 parent d1aa98d commit 5ca5165

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,14 @@ Note that requests that time out are [retried twice by default](#retries).
235235

236236
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
237237

238-
You can enable logging by setting the environment variable `ASKTABLE_LOG` to `debug`.
238+
You can enable logging by setting the environment variable `ASKTABLE_LOG` to `info`.
239239

240240
```shell
241-
$ export ASKTABLE_LOG=debug
241+
$ export ASKTABLE_LOG=info
242242
```
243243

244+
Or to `debug` for more verbose logging.
245+
244246
### How to tell whether `None` means `null` or missing
245247

246248
In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ dependencies = [
1414
"anyio>=3.5.0, <5",
1515
"distro>=1.7.0, <2",
1616
"sniffio",
17-
"cached-property; python_version < '3.8'",
1817
]
1918
requires-python = ">= 3.8"
2019
classifiers = [

src/asktable/_compat.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def model_dump(
145145
exclude=exclude,
146146
exclude_unset=exclude_unset,
147147
exclude_defaults=exclude_defaults,
148-
warnings=warnings,
148+
# warnings are not supported in Pydantic v1
149+
warnings=warnings if PYDANTIC_V2 else True,
149150
)
150151
return cast(
151152
"dict[str, Any]",
@@ -213,9 +214,6 @@ def __set_name__(self, owner: type[Any], name: str) -> None: ...
213214
# __set__ is not defined at runtime, but @cached_property is designed to be settable
214215
def __set__(self, instance: object, value: _T) -> None: ...
215216
else:
216-
try:
217-
from functools import cached_property as cached_property
218-
except ImportError:
219-
from cached_property import cached_property as cached_property
217+
from functools import cached_property as cached_property
220218

221219
typed_cached_property = cached_property

tests/test_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,14 @@ class Model(BaseModel):
561561
m.model_dump(warnings=False)
562562

563563

564+
def test_compat_method_no_error_for_warnings() -> None:
565+
class Model(BaseModel):
566+
foo: Optional[str]
567+
568+
m = Model(foo="hello")
569+
assert isinstance(model_dump(m, warnings=False), dict)
570+
571+
564572
def test_to_json() -> None:
565573
class Model(BaseModel):
566574
foo: Optional[str] = Field(alias="FOO", default=None)

0 commit comments

Comments
 (0)