Skip to content

Commit 75e35c1

Browse files
authored
Merge pull request #2756 from ff137/fix-deprecation-warnings
Fix deprecation warnings
2 parents 27bce43 + 8822abb commit 75e35c1

File tree

21 files changed

+363
-263
lines changed

21 files changed

+363
-263
lines changed

aries_cloudagent/admin/tests/test_admin_server.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
from ..server import AdminServer, AdminSetupError
2121

2222

23+
# Ignore Marshmallow warning, as well as 'NotAppKeyWarning' coming from apispec packages
24+
@pytest.mark.filterwarnings(
25+
"ignore:The 'missing' attribute of fields is deprecated. Use 'load_default' instead.",
26+
"ignore:It is recommended to use web.AppKey instances for keys.",
27+
)
2328
class TestAdminServer(IsolatedAsyncioTestCase):
2429
async def asyncSetUp(self):
2530
self.message_results = []
@@ -507,5 +512,6 @@ def _smaller_scope():
507512
with pytest.raises(RuntimeError):
508513
await responder.send_outbound(None)
509514

510-
with pytest.raises(RuntimeError):
511-
await responder.send_webhook("test", {})
515+
with pytest.deprecated_call():
516+
with pytest.raises(RuntimeError):
517+
await responder.send_webhook("test", {})

aries_cloudagent/anoncreds/default/legacy_indy/registry.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,8 @@ async def _revoc_reg_entry_with_fix(
796796
# Ledger rejected transaction request: client request invalid:
797797
# InvalidClientRequest(...)
798798
# In this scenario we try to post a correction
799-
LOGGER.warn("Retry ledger update/fix due to error")
800-
LOGGER.warn(err)
799+
LOGGER.warning("Retry ledger update/fix due to error")
800+
LOGGER.warning(err)
801801
(_, _, rev_entry_res) = await self.fix_ledger_entry(
802802
profile,
803803
rev_list,
@@ -806,7 +806,7 @@ async def _revoc_reg_entry_with_fix(
806806
write_ledger,
807807
endorser_did,
808808
)
809-
LOGGER.warn("Ledger update/fix applied")
809+
LOGGER.warning("Ledger update/fix applied")
810810
elif "InvalidClientTaaAcceptanceError" in err.roll_up:
811811
# if no write access (with "InvalidClientTaaAcceptanceError")
812812
# e.g. aries_cloudagent.ledger.error.LedgerTransactionError:

aries_cloudagent/anoncreds/models/anoncreds_cred_def.py

+49-26
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
NUM_STR_WHOLE_VALIDATE,
1717
)
1818

19-
NUM_STR_WHOLE = {"validate": NUM_STR_WHOLE_VALIDATE, "example": NUM_STR_WHOLE_EXAMPLE}
19+
NUM_STR_WHOLE = {
20+
"validate": NUM_STR_WHOLE_VALIDATE,
21+
"metadata": {"example": NUM_STR_WHOLE_EXAMPLE},
22+
}
2023

2124

2225
class CredDefValuePrimary(BaseModel):
@@ -126,17 +129,27 @@ class Meta:
126129
model_class = CredDefValueRevocation
127130
unknown = EXCLUDE
128131

129-
g = fields.Str(example="1 1F14F&ECB578F 2 095E45DDF417D")
130-
g_dash = fields.Str(example="1 1D64716fCDC00C 1 0C781960FA66E3D3 2 095E45DDF417D")
131-
h = fields.Str(example="1 16675DAE54BFAE8 2 095E45DD417D")
132-
h0 = fields.Str(example="1 21E5EF9476EAF18 2 095E45DDF417D")
133-
h1 = fields.Str(example="1 236D1D99236090 2 095E45DDF417D")
134-
h2 = fields.Str(example="1 1C3AE8D1F1E277 2 095E45DDF417D")
135-
htilde = fields.Str(example="1 1D8549E8C0F8 2 095E45DDF417D")
136-
h_cap = fields.Str(example="1 1B2A32CF3167 1 2490FEBF6EE55 1 0000000000000000")
137-
u = fields.Str(example="1 0C430AAB2B4710 1 1CB3A0932EE7E 1 0000000000000000")
138-
pk = fields.Str(example="1 142CD5E5A7DC 1 153885BD903312 2 095E45DDF417D")
139-
y = fields.Str(example="1 153558BD903312 2 095E45DDF417D 1 0000000000000000")
132+
g = fields.Str(metadata={"example": "1 1F14F&ECB578F 2 095E45DDF417D"})
133+
g_dash = fields.Str(
134+
metadata={"example": "1 1D64716fCDC00C 1 0C781960FA66E3D3 2 095E45DDF417D"}
135+
)
136+
h = fields.Str(metadata={"example": "1 16675DAE54BFAE8 2 095E45DD417D"})
137+
h0 = fields.Str(metadata={"example": "1 21E5EF9476EAF18 2 095E45DDF417D"})
138+
h1 = fields.Str(metadata={"example": "1 236D1D99236090 2 095E45DDF417D"})
139+
h2 = fields.Str(metadata={"example": "1 1C3AE8D1F1E277 2 095E45DDF417D"})
140+
htilde = fields.Str(metadata={"example": "1 1D8549E8C0F8 2 095E45DDF417D"})
141+
h_cap = fields.Str(
142+
metadata={"example": "1 1B2A32CF3167 1 2490FEBF6EE55 1 0000000000000000"}
143+
)
144+
u = fields.Str(
145+
metadata={"example": "1 0C430AAB2B4710 1 1CB3A0932EE7E 1 0000000000000000"}
146+
)
147+
pk = fields.Str(
148+
metadata={"example": "1 142CD5E5A7DC 1 153885BD903312 2 095E45DDF417D"}
149+
)
150+
y = fields.Str(
151+
metadata={"example": "1 153558BD903312 2 095E45DDF417D 1 0000000000000000"}
152+
)
140153

141154

142155
class CredDefValue(BaseModel):
@@ -178,11 +191,11 @@ class Meta:
178191

179192
primary = fields.Nested(
180193
CredDefValuePrimarySchema(),
181-
description="Primary value for credential definition",
194+
metadata={"description": "Primary value for credential definition"},
182195
)
183196
revocation = fields.Nested(
184197
CredDefValueRevocationSchema(),
185-
description="Revocation value for credential definition",
198+
metadata={"description": "Revocation value for credential definition"},
186199
required=False,
187200
)
188201

@@ -243,20 +256,26 @@ class Meta:
243256
unknown = EXCLUDE
244257

245258
issuer_id = fields.Str(
246-
description="Issuer Identifier of the credential definition or schema",
259+
metadata={
260+
"description": "Issuer Identifier of the credential definition or schema",
261+
"example": INDY_OR_KEY_DID_EXAMPLE,
262+
},
247263
data_key="issuerId",
248-
example=INDY_OR_KEY_DID_EXAMPLE,
249264
)
250265
schema_id = fields.Str(
251266
data_key="schemaId",
252-
description="Schema identifier",
253-
example=INDY_SCHEMA_ID_EXAMPLE,
267+
metadata={
268+
"description": "Schema identifier",
269+
"example": INDY_SCHEMA_ID_EXAMPLE,
270+
},
254271
)
255272
type = fields.Str(validate=OneOf(["CL"]))
256273
tag = fields.Str(
257-
description="""The tag value passed in by the Issuer to
274+
metadata={
275+
"description": """The tag value passed in by the Issuer to
258276
an AnonCred's Credential Definition create and store implementation.""",
259-
example="default",
277+
"example": "default",
278+
}
260279
)
261280
value = fields.Nested(CredDefValueSchema())
262281

@@ -315,12 +334,14 @@ class Meta:
315334
)
316335
)
317336
credential_definition_id = fields.Str(
318-
description="credential definition id",
337+
metadata={
338+
"description": "credential definition id",
339+
"example": INDY_CRED_DEF_ID_EXAMPLE,
340+
},
319341
allow_none=True,
320-
example=INDY_CRED_DEF_ID_EXAMPLE,
321342
)
322343
credential_definition = fields.Nested(
323-
CredDefSchema(), description="credential definition"
344+
CredDefSchema(), metadata={"description": "credential definition"}
324345
)
325346

326347

@@ -418,11 +439,13 @@ class Meta:
418439
unknown = EXCLUDE
419440

420441
credential_definition_id = fields.Str(
421-
description="credential definition id",
422-
example=INDY_CRED_DEF_ID_EXAMPLE,
442+
metadata={
443+
"description": "credential definition id",
444+
"example": INDY_CRED_DEF_ID_EXAMPLE,
445+
},
423446
)
424447
credential_definition = fields.Nested(
425-
CredDefSchema(), description="credential definition"
448+
CredDefSchema(), metadata={"description": "credential definition"}
426449
)
427450
resolution_metadata = fields.Dict()
428451
credential_definitions_metadata = fields.Dict()

aries_cloudagent/anoncreds/models/anoncreds_revocation.py

+47-23
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,18 @@ class Meta:
6262
unknown = EXCLUDE
6363

6464
public_keys = fields.Dict(
65-
data_key="publicKeys", example=INDY_RAW_PUBLIC_KEY_EXAMPLE
65+
data_key="publicKeys", metadata={"example": INDY_RAW_PUBLIC_KEY_EXAMPLE}
6666
)
67-
max_cred_num = fields.Int(data_key="maxCredNum", example=666)
67+
max_cred_num = fields.Int(data_key="maxCredNum", metadata={"example": 777})
6868
tails_location = fields.Str(
6969
data_key="tailsLocation",
70-
example="https://tails-server.com/hash/7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P",
70+
metadata={
71+
"example": "https://tails-server.com/hash/7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"
72+
},
7173
)
7274
tails_hash = fields.Str(
73-
data_key="tailsHash", example="7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"
75+
data_key="tailsHash",
76+
metadata={"example": "7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"},
7477
)
7578

7679

@@ -130,18 +133,25 @@ class Meta:
130133
unknown = EXCLUDE
131134

132135
issuer_id = fields.Str(
133-
description="Issuer Identifier of the credential definition or schema",
136+
metadata={
137+
"description": "Issuer Identifier of the credential definition or schema",
138+
"example": INDY_OR_KEY_DID_EXAMPLE,
139+
},
134140
data_key="issuerId",
135-
example=INDY_OR_KEY_DID_EXAMPLE,
136141
)
137142
type = fields.Str(data_key="revocDefType")
138143
cred_def_id = fields.Str(
139-
description="Credential definition identifier",
144+
metadata={
145+
"description": "Credential definition identifier",
146+
"example": INDY_CRED_DEF_ID_EXAMPLE,
147+
},
140148
data_key="credDefId",
141-
example=INDY_CRED_DEF_ID_EXAMPLE,
142149
)
143150
tag = fields.Str(
144-
description="tag for the revocation registry definition", example="default"
151+
metadata={
152+
"description": "tag for the revocation registry definition",
153+
"example": "default",
154+
}
145155
)
146156
value = fields.Nested(RevRegDefValueSchema())
147157

@@ -204,11 +214,13 @@ class Meta:
204214
)
205215
)
206216
revocation_registry_definition_id = fields.Str(
207-
description="revocation registry definition id",
208-
example=INDY_REV_REG_ID_EXAMPLE,
217+
metadata={
218+
"description": "revocation registry definition id",
219+
"example": INDY_REV_REG_ID_EXAMPLE,
220+
}
209221
)
210222
revocation_registry_definition = fields.Nested(
211-
RevRegDefSchema(), description="revocation registry definition"
223+
RevRegDefSchema(), metadata={"description": "revocation registry definition"}
212224
)
213225

214226

@@ -381,30 +393,40 @@ class Meta:
381393
unknown = EXCLUDE
382394

383395
issuer_id = fields.Str(
384-
description="Issuer Identifier of the credential definition or schema",
396+
metadata={
397+
"description": "Issuer Identifier of the credential definition or schema",
398+
"example": INDY_OR_KEY_DID_EXAMPLE,
399+
},
385400
data_key="issuerId",
386-
example=INDY_OR_KEY_DID_EXAMPLE,
387401
)
388402
rev_reg_def_id = fields.Str(
389-
description="The ID of the revocation registry definition",
403+
metadata={
404+
"description": "The ID of the revocation registry definition",
405+
"example": INDY_REV_REG_ID_EXAMPLE,
406+
},
390407
data_key="revRegDefId",
391-
example=INDY_REV_REG_ID_EXAMPLE,
392408
)
393409
revocation_list = fields.List(
394410
fields.Int(),
395-
description="Bit list representing revoked credentials",
411+
metadata={
412+
"description": "Bit list representing revoked credentials",
413+
"example": [0, 1, 1, 0],
414+
},
396415
data_key="revocationList",
397-
example=[0, 1, 1, 0],
398416
)
399417
current_accumulator = fields.Str(
400-
description="The current accumalator value",
401-
example="21 118...1FB",
418+
metadata={
419+
"description": "The current accumalator value",
420+
"example": "21 118...1FB",
421+
},
402422
data_key="currentAccumulator",
403423
)
404424
timestamp = fields.Int(
405-
description="Timestamp at which revocation list is applicable",
425+
metadata={
426+
"description": "Timestamp at which revocation list is applicable",
427+
"example": INDY_ISO8601_DATETIME_EXAMPLE,
428+
},
406429
required=False,
407-
example=INDY_ISO8601_DATETIME_EXAMPLE,
408430
)
409431

410432

@@ -458,7 +480,9 @@ class Meta:
458480
]
459481
)
460482
)
461-
revocation_list = fields.Nested(RevListSchema(), description="revocation list")
483+
revocation_list = fields.Nested(
484+
RevListSchema(), metadata={"description": "revocation list"}
485+
)
462486

463487

464488
class RevListResult(BaseModel):

aries_cloudagent/anoncreds/models/anoncreds_schema.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,26 @@ class Meta:
6161
unknown = EXCLUDE
6262

6363
issuer_id = fields.Str(
64-
description="Issuer Identifier of the credential definition or schema",
64+
metadata={
65+
"description": "Issuer Identifier of the credential definition or schema",
66+
"example": INDY_OR_KEY_DID_EXAMPLE,
67+
},
6568
data_key="issuerId",
66-
example=INDY_OR_KEY_DID_EXAMPLE,
6769
)
6870
attr_names = fields.List(
6971
fields.Str(
70-
description="Attribute name",
71-
example="score",
72+
metadata={
73+
"description": "Attribute name",
74+
"example": "score",
75+
}
7276
),
73-
description="Schema attribute names",
77+
metadata={"description": "Schema attribute names"},
7478
data_key="attrNames",
7579
)
76-
name = fields.Str(description="Schema name", example="Example schema")
77-
version = fields.Str(description="Schema version", example="1.0")
80+
name = fields.Str(
81+
metadata={"description": "Schema name", "example": "Example schema"}
82+
)
83+
version = fields.Str(metadata={"description": "Schema version", "example": "1.0"})
7884

7985

8086
class GetSchemaResult(BaseModel):
@@ -130,7 +136,7 @@ class Meta:
130136

131137
schema_value = fields.Nested(AnonCredsSchemaSchema(), data_key="schema")
132138
schema_id = fields.Str(
133-
description="Schema identifier", example=INDY_SCHEMA_ID_EXAMPLE
139+
metadata={"description": "Schema identifier", "example": INDY_SCHEMA_ID_EXAMPLE}
134140
)
135141
resolution_metadata = fields.Dict()
136142
schema_metadata = fields.Dict()
@@ -184,8 +190,10 @@ class Meta:
184190
)
185191
)
186192
schema_id = fields.Str(
187-
description="Schema identifier",
188-
example=INDY_SCHEMA_ID_EXAMPLE,
193+
metadata={
194+
"description": "Schema identifier",
195+
"example": INDY_SCHEMA_ID_EXAMPLE,
196+
}
189197
)
190198
schema_value = fields.Nested(AnonCredsSchemaSchema(), data_key="schema")
191199

aries_cloudagent/anoncreds/revocation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1209,15 +1209,15 @@ async def revoke_pending_credentials(
12091209
)
12101210
failed_crids.add(rev_id)
12111211
elif rev_id >= rev_info["next_index"]:
1212-
LOGGER.warn(
1212+
LOGGER.warning(
12131213
"Skipping requested credential revocation"
12141214
"on rev reg id %s, cred rev id=%s not yet issued",
12151215
revoc_reg_id,
12161216
rev_id,
12171217
)
12181218
failed_crids.add(rev_id)
12191219
elif rev_list.revocation_list[rev_id] == 1:
1220-
LOGGER.warn(
1220+
LOGGER.warning(
12211221
"Skipping requested credential revocation"
12221222
"on rev reg id %s, cred rev id=%s already revoked",
12231223
revoc_reg_id,
@@ -1259,7 +1259,7 @@ async def revoke_pending_credentials(
12591259
CATEGORY_REV_LIST, revoc_reg_id, for_update=True
12601260
)
12611261
if not rev_info_upd:
1262-
LOGGER.warn(
1262+
LOGGER.warning(
12631263
"Revocation registry missing, skipping update: {}",
12641264
revoc_reg_id,
12651265
)

0 commit comments

Comments
 (0)