Skip to content

Commit 5d4a6a2

Browse files
fix mypy
1 parent f28c414 commit 5d4a6a2

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

packages/settings-library/tests/test_base_w_postgres.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ def test_parse_from_individual_envs(
170170
}
171171

172172
s2 = S2()
173-
assert s2.dict(exclude_unset=True) == {}
174-
assert s2.dict() == {"WEBSERVER_POSTGRES_NULLABLE_OPTIONAL": None}
173+
assert s2.model_dump(exclude_unset=True) == {}
174+
assert s2.model_dump() == {"WEBSERVER_POSTGRES_NULLABLE_OPTIONAL": None}
175175

176176
s3 = S3()
177-
assert s3.dict(exclude_unset=True) == {}
178-
assert s3.dict() == {
177+
assert s3.model_dump(exclude_unset=True) == {}
178+
assert s3.model_dump() == {
179179
"WEBSERVER_POSTGRES_DEFAULT_ENV": {
180180
"POSTGRES_HOST": "pg",
181181
"POSTGRES_USER": "test",
@@ -189,8 +189,8 @@ def test_parse_from_individual_envs(
189189
}
190190

191191
s4 = S4()
192-
assert s4.dict(exclude_unset=True) == {}
193-
assert s4.dict() == {
192+
assert s4.model_dump(exclude_unset=True) == {}
193+
assert s4.model_dump() == {
194194
"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_ENV": {
195195
"POSTGRES_HOST": "pg",
196196
"POSTGRES_USER": "test",
@@ -204,8 +204,8 @@ def test_parse_from_individual_envs(
204204
}
205205

206206
s5 = S5()
207-
assert s5.dict(exclude_unset=True) == {}
208-
assert s5.dict() == {"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_NULL": None}
207+
assert s5.model_dump(exclude_unset=True) == {}
208+
assert s5.model_dump() == {"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_NULL": None}
209209

210210

211211
def test_parse_compact_env(
@@ -229,15 +229,15 @@ def test_parse_compact_env(
229229
# test
230230
s1 = S1()
231231

232-
assert s1.dict(exclude_unset=True) == {
232+
assert s1.model_dump(exclude_unset=True) == {
233233
"WEBSERVER_POSTGRES": {
234234
"POSTGRES_HOST": "pg2",
235235
"POSTGRES_USER": "test2",
236236
"POSTGRES_PASSWORD": "shh2",
237237
"POSTGRES_DB": "db2",
238238
}
239239
}
240-
assert s1.dict() == {
240+
assert s1.model_dump() == {
241241
"WEBSERVER_POSTGRES": {
242242
"POSTGRES_HOST": "pg2",
243243
"POSTGRES_USER": "test2",
@@ -258,7 +258,7 @@ def test_parse_compact_env(
258258
""",
259259
)
260260
s2 = S2()
261-
assert s2.dict(exclude_unset=True) == {
261+
assert s2.model_dump(exclude_unset=True) == {
262262
"WEBSERVER_POSTGRES_NULLABLE_OPTIONAL": {
263263
"POSTGRES_HOST": "pg2",
264264
"POSTGRES_USER": "test2",
@@ -278,7 +278,7 @@ def test_parse_compact_env(
278278
# default until it is really needed. Here before it would
279279
# fail because default cannot be computed even if the final value can!
280280
s3 = S3()
281-
assert s3.dict(exclude_unset=True) == {
281+
assert s3.model_dump(exclude_unset=True) == {
282282
"WEBSERVER_POSTGRES_DEFAULT_ENV": {
283283
"POSTGRES_HOST": "pg2",
284284
"POSTGRES_USER": "test2",
@@ -295,7 +295,7 @@ def test_parse_compact_env(
295295
""",
296296
)
297297
s4 = S4()
298-
assert s4.dict(exclude_unset=True) == {
298+
assert s4.model_dump(exclude_unset=True) == {
299299
"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_ENV": {
300300
"POSTGRES_HOST": "pg2",
301301
"POSTGRES_USER": "test2",
@@ -312,7 +312,7 @@ def test_parse_compact_env(
312312
""",
313313
)
314314
s5 = S5()
315-
assert s5.dict(exclude_unset=True) == {
315+
assert s5.model_dump(exclude_unset=True) == {
316316
"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_NULL": {
317317
"POSTGRES_HOST": "pg2",
318318
"POSTGRES_USER": "test2",
@@ -348,7 +348,7 @@ def test_parse_from_mixed_envs(
348348

349349
s1 = S1()
350350

351-
assert s1.dict() == {
351+
assert s1.model_dump() == {
352352
"WEBSERVER_POSTGRES": {
353353
"POSTGRES_HOST": "pg2",
354354
"POSTGRES_USER": "test2",
@@ -363,7 +363,7 @@ def test_parse_from_mixed_envs(
363363
# NOTE how unset marks also applies to embedded fields
364364
# NOTE: (1) priority of json-compact over granulated
365365
# NOTE: (2) json-compact did not define this but granulated did
366-
assert s1.dict(exclude_unset=True) == {
366+
assert s1.model_dump(exclude_unset=True) == {
367367
"WEBSERVER_POSTGRES": {
368368
"POSTGRES_HOST": "pg2", # <- (1)
369369
"POSTGRES_USER": "test2", # <- (1)
@@ -380,7 +380,7 @@ def test_parse_from_mixed_envs(
380380
)
381381

382382
s2 = S2()
383-
assert s2.dict(exclude_unset=True) == {
383+
assert s2.model_dump(exclude_unset=True) == {
384384
"WEBSERVER_POSTGRES_NULLABLE_OPTIONAL": {
385385
"POSTGRES_HOST": "pg2",
386386
"POSTGRES_USER": "test2",
@@ -397,7 +397,7 @@ def test_parse_from_mixed_envs(
397397
)
398398

399399
s3 = S3()
400-
assert s3.dict(exclude_unset=True) == {
400+
assert s3.model_dump(exclude_unset=True) == {
401401
"WEBSERVER_POSTGRES_DEFAULT_ENV": {
402402
"POSTGRES_HOST": "pg2",
403403
"POSTGRES_USER": "test2",
@@ -414,7 +414,7 @@ def test_parse_from_mixed_envs(
414414
)
415415

416416
s4 = S4()
417-
assert s4.dict(exclude_unset=True) == {
417+
assert s4.model_dump(exclude_unset=True) == {
418418
"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_ENV": {
419419
"POSTGRES_HOST": "pg2",
420420
"POSTGRES_USER": "test2",
@@ -431,7 +431,7 @@ def test_parse_from_mixed_envs(
431431
)
432432

433433
s5 = S5()
434-
assert s5.dict(exclude_unset=True) == {
434+
assert s5.model_dump(exclude_unset=True) == {
435435
"WEBSERVER_POSTGRES_NULLABLE_DEFAULT_NULL": {
436436
"POSTGRES_HOST": "pg2",
437437
"POSTGRES_USER": "test2",

packages/settings-library/tests/test_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def all_env_devel_undefined(
6767
],
6868
)
6969
def test_smtp_configuration_ok(cfg: dict[str, Any], all_env_devel_undefined: None):
70-
assert SMTPSettings.parse_obj(cfg)
70+
assert SMTPSettings.model_validate(cfg)
7171

7272

7373
@pytest.mark.parametrize(

packages/settings-library/tests/test_postgres.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def env_file():
1414

1515
def test_cached_property_dsn(mock_environment: dict):
1616

17-
settings = PostgresSettings()
17+
settings = PostgresSettings() # type: ignore[call-arg]
1818

1919
# all are upper-case
2020
assert all(key == key.upper() for key in settings.model_dump())
@@ -27,15 +27,15 @@ def test_cached_property_dsn(mock_environment: dict):
2727

2828
def test_dsn_with_query(mock_environment: dict, monkeypatch):
2929

30-
settings = PostgresSettings()
30+
settings = PostgresSettings() # type: ignore[call-arg]
3131

3232
assert not settings.POSTGRES_CLIENT_NAME
3333
assert settings.dsn == "postgresql://foo:secret@localhost:5432/foodb"
3434

3535
# now with app
3636
monkeypatch.setenv("POSTGRES_CLIENT_NAME", "Some &43 funky name")
3737

38-
settings_with_app = PostgresSettings()
38+
settings_with_app = PostgresSettings() # type: ignore[call-arg]
3939

4040
assert settings_with_app.POSTGRES_CLIENT_NAME
4141
assert (

0 commit comments

Comments
 (0)