Skip to content

Commit 6da95e9

Browse files
chore(internal): codegen related update (#388)
1 parent 298eedb commit 6da95e9

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

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

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

261-
You can enable logging by setting the environment variable `OPENLAYER_LOG` to `debug`.
261+
You can enable logging by setting the environment variable `OPENLAYER_LOG` to `info`.
262262

263263
```shell
264-
$ export OPENLAYER_LOG=debug
264+
$ export OPENLAYER_LOG=info
265265
```
266266

267+
Or to `debug` for more verbose logging.
268+
267269
### How to tell whether `None` means `null` or missing
268270

269271
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`:

src/openlayer/_compat.py

Lines changed: 2 additions & 1 deletion
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]",

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)