Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings #2756

Merged
merged 27 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bed6e11
:recycle: Replace deprecated `pkg_resources` with `importlib`
ff137 Feb 2, 2024
3bc3735
:recycle: Refactor tests to accommodate for pkg_resources being repla…
ff137 Feb 2, 2024
3f05059
:art: remove unused import
ff137 Feb 2, 2024
52e671b
:art: remove the return type
ff137 Feb 2, 2024
3f74fad
:art: fix test
ff137 Feb 2, 2024
fc9894d
:art:
ff137 Feb 2, 2024
af87e1e
:art: Fix Marshmallow deprecation warnings by introducing metadata field
ff137 Feb 2, 2024
b6ff481
:arrow_up: Upgrade `jsonpath-ng`
ff137 Feb 2, 2024
1a49a0e
Update lock file
ff137 Feb 2, 2024
c73527d
:arrow_up: Bump `rlp` to latest
ff137 Feb 2, 2024
c8386ec
Update lock file
ff137 Feb 2, 2024
adcd45b
:art: Fix Marshmallow deprecation warnings with metadata field
ff137 Feb 2, 2024
a865df7
:art: `send_webhook` tests to expect and absorb deprecation warning
ff137 Feb 2, 2024
d1d276b
:arrow_up: Upgrade `Markdown` to latest
ff137 Feb 2, 2024
b8a8e68
Update lock file
ff137 Feb 2, 2024
97640e1
:art: replace usage of deprecated .warn method with .warning
ff137 Feb 7, 2024
492acd3
:art: set test scope to module level
ff137 Feb 7, 2024
71ebce7
:art: set test scope to module level
ff137 Feb 7, 2024
58f9490
:art: fix metadata containing required field
ff137 Feb 12, 2024
4df2984
:art: fix marshmallow warning
ff137 Feb 12, 2024
dfd829d
:art: ignore specific warnings from external packages
ff137 Feb 12, 2024
dc63049
Add Dependabot configuration
WadeBarnes Feb 14, 2024
8eceb59
chore(deps): Bump the all-actions group with 10 updates
dependabot[bot] Feb 14, 2024
6cc9790
Merge branch 'main' into fix-deprecation-warnings
swcurran Feb 14, 2024
afae3db
Merge branch 'main' into fix-deprecation-warnings
ff137 Feb 16, 2024
f77019c
Merge branch 'main' into fix-deprecation-warnings
ff137 Feb 17, 2024
8822abb
Merge branch 'main' into fix-deprecation-warnings
ff137 Feb 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions aries_cloudagent/admin/tests/test_admin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
from ..server import AdminServer, AdminSetupError


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

with pytest.raises(RuntimeError):
await responder.send_webhook("test", {})
with pytest.deprecated_call():
with pytest.raises(RuntimeError):
await responder.send_webhook("test", {})
6 changes: 3 additions & 3 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ async def _revoc_reg_entry_with_fix(
# Ledger rejected transaction request: client request invalid:
# InvalidClientRequest(...)
# In this scenario we try to post a correction
LOGGER.warn("Retry ledger update/fix due to error")
LOGGER.warn(err)
LOGGER.warning("Retry ledger update/fix due to error")
LOGGER.warning(err)
(_, _, rev_entry_res) = await self.fix_ledger_entry(
profile,
rev_list,
Expand All @@ -806,7 +806,7 @@ async def _revoc_reg_entry_with_fix(
write_ledger,
endorser_did,
)
LOGGER.warn("Ledger update/fix applied")
LOGGER.warning("Ledger update/fix applied")
elif "InvalidClientTaaAcceptanceError" in err.roll_up:
# if no write access (with "InvalidClientTaaAcceptanceError")
# e.g. aries_cloudagent.ledger.error.LedgerTransactionError:
Expand Down
75 changes: 49 additions & 26 deletions aries_cloudagent/anoncreds/models/anoncreds_cred_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
NUM_STR_WHOLE_VALIDATE,
)

NUM_STR_WHOLE = {"validate": NUM_STR_WHOLE_VALIDATE, "example": NUM_STR_WHOLE_EXAMPLE}
NUM_STR_WHOLE = {
"validate": NUM_STR_WHOLE_VALIDATE,
"metadata": {"example": NUM_STR_WHOLE_EXAMPLE},
}


class CredDefValuePrimary(BaseModel):
Expand Down Expand Up @@ -126,17 +129,27 @@ class Meta:
model_class = CredDefValueRevocation
unknown = EXCLUDE

g = fields.Str(example="1 1F14F&ECB578F 2 095E45DDF417D")
g_dash = fields.Str(example="1 1D64716fCDC00C 1 0C781960FA66E3D3 2 095E45DDF417D")
h = fields.Str(example="1 16675DAE54BFAE8 2 095E45DD417D")
h0 = fields.Str(example="1 21E5EF9476EAF18 2 095E45DDF417D")
h1 = fields.Str(example="1 236D1D99236090 2 095E45DDF417D")
h2 = fields.Str(example="1 1C3AE8D1F1E277 2 095E45DDF417D")
htilde = fields.Str(example="1 1D8549E8C0F8 2 095E45DDF417D")
h_cap = fields.Str(example="1 1B2A32CF3167 1 2490FEBF6EE55 1 0000000000000000")
u = fields.Str(example="1 0C430AAB2B4710 1 1CB3A0932EE7E 1 0000000000000000")
pk = fields.Str(example="1 142CD5E5A7DC 1 153885BD903312 2 095E45DDF417D")
y = fields.Str(example="1 153558BD903312 2 095E45DDF417D 1 0000000000000000")
g = fields.Str(metadata={"example": "1 1F14F&ECB578F 2 095E45DDF417D"})
g_dash = fields.Str(
metadata={"example": "1 1D64716fCDC00C 1 0C781960FA66E3D3 2 095E45DDF417D"}
)
h = fields.Str(metadata={"example": "1 16675DAE54BFAE8 2 095E45DD417D"})
h0 = fields.Str(metadata={"example": "1 21E5EF9476EAF18 2 095E45DDF417D"})
h1 = fields.Str(metadata={"example": "1 236D1D99236090 2 095E45DDF417D"})
h2 = fields.Str(metadata={"example": "1 1C3AE8D1F1E277 2 095E45DDF417D"})
htilde = fields.Str(metadata={"example": "1 1D8549E8C0F8 2 095E45DDF417D"})
h_cap = fields.Str(
metadata={"example": "1 1B2A32CF3167 1 2490FEBF6EE55 1 0000000000000000"}
)
u = fields.Str(
metadata={"example": "1 0C430AAB2B4710 1 1CB3A0932EE7E 1 0000000000000000"}
)
pk = fields.Str(
metadata={"example": "1 142CD5E5A7DC 1 153885BD903312 2 095E45DDF417D"}
)
y = fields.Str(
metadata={"example": "1 153558BD903312 2 095E45DDF417D 1 0000000000000000"}
)


class CredDefValue(BaseModel):
Expand Down Expand Up @@ -178,11 +191,11 @@ class Meta:

primary = fields.Nested(
CredDefValuePrimarySchema(),
description="Primary value for credential definition",
metadata={"description": "Primary value for credential definition"},
)
revocation = fields.Nested(
CredDefValueRevocationSchema(),
description="Revocation value for credential definition",
metadata={"description": "Revocation value for credential definition"},
required=False,
)

Expand Down Expand Up @@ -243,20 +256,26 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
schema_id = fields.Str(
data_key="schemaId",
description="Schema identifier",
example=INDY_SCHEMA_ID_EXAMPLE,
metadata={
"description": "Schema identifier",
"example": INDY_SCHEMA_ID_EXAMPLE,
},
)
type = fields.Str(validate=OneOf(["CL"]))
tag = fields.Str(
description="""The tag value passed in by the Issuer to
metadata={
"description": """The tag value passed in by the Issuer to
an AnonCred's Credential Definition create and store implementation.""",
example="default",
"example": "default",
}
)
value = fields.Nested(CredDefValueSchema())

Expand Down Expand Up @@ -315,12 +334,14 @@ class Meta:
)
)
credential_definition_id = fields.Str(
description="credential definition id",
metadata={
"description": "credential definition id",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
allow_none=True,
example=INDY_CRED_DEF_ID_EXAMPLE,
)
credential_definition = fields.Nested(
CredDefSchema(), description="credential definition"
CredDefSchema(), metadata={"description": "credential definition"}
)


Expand Down Expand Up @@ -418,11 +439,13 @@ class Meta:
unknown = EXCLUDE

credential_definition_id = fields.Str(
description="credential definition id",
example=INDY_CRED_DEF_ID_EXAMPLE,
metadata={
"description": "credential definition id",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
)
credential_definition = fields.Nested(
CredDefSchema(), description="credential definition"
CredDefSchema(), metadata={"description": "credential definition"}
)
resolution_metadata = fields.Dict()
credential_definitions_metadata = fields.Dict()
70 changes: 47 additions & 23 deletions aries_cloudagent/anoncreds/models/anoncreds_revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ class Meta:
unknown = EXCLUDE

public_keys = fields.Dict(
data_key="publicKeys", example=INDY_RAW_PUBLIC_KEY_EXAMPLE
data_key="publicKeys", metadata={"example": INDY_RAW_PUBLIC_KEY_EXAMPLE}
)
max_cred_num = fields.Int(data_key="maxCredNum", example=666)
max_cred_num = fields.Int(data_key="maxCredNum", metadata={"example": 777})
tails_location = fields.Str(
data_key="tailsLocation",
example="https://tails-server.com/hash/7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P",
metadata={
"example": "https://tails-server.com/hash/7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"
},
)
tails_hash = fields.Str(
data_key="tailsHash", example="7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"
data_key="tailsHash",
metadata={"example": "7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"},
)


Expand Down Expand Up @@ -130,18 +133,25 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
type = fields.Str(data_key="revocDefType")
cred_def_id = fields.Str(
description="Credential definition identifier",
metadata={
"description": "Credential definition identifier",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
data_key="credDefId",
example=INDY_CRED_DEF_ID_EXAMPLE,
)
tag = fields.Str(
description="tag for the revocation registry definition", example="default"
metadata={
"description": "tag for the revocation registry definition",
"example": "default",
}
)
value = fields.Nested(RevRegDefValueSchema())

Expand Down Expand Up @@ -204,11 +214,13 @@ class Meta:
)
)
revocation_registry_definition_id = fields.Str(
description="revocation registry definition id",
example=INDY_REV_REG_ID_EXAMPLE,
metadata={
"description": "revocation registry definition id",
"example": INDY_REV_REG_ID_EXAMPLE,
}
)
revocation_registry_definition = fields.Nested(
RevRegDefSchema(), description="revocation registry definition"
RevRegDefSchema(), metadata={"description": "revocation registry definition"}
)


Expand Down Expand Up @@ -381,30 +393,40 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
rev_reg_def_id = fields.Str(
description="The ID of the revocation registry definition",
metadata={
"description": "The ID of the revocation registry definition",
"example": INDY_REV_REG_ID_EXAMPLE,
},
data_key="revRegDefId",
example=INDY_REV_REG_ID_EXAMPLE,
)
revocation_list = fields.List(
fields.Int(),
description="Bit list representing revoked credentials",
metadata={
"description": "Bit list representing revoked credentials",
"example": [0, 1, 1, 0],
},
data_key="revocationList",
example=[0, 1, 1, 0],
)
current_accumulator = fields.Str(
description="The current accumalator value",
example="21 118...1FB",
metadata={
"description": "The current accumalator value",
"example": "21 118...1FB",
},
data_key="currentAccumulator",
)
timestamp = fields.Int(
description="Timestamp at which revocation list is applicable",
metadata={
"description": "Timestamp at which revocation list is applicable",
"example": INDY_ISO8601_DATETIME_EXAMPLE,
},
required=False,
example=INDY_ISO8601_DATETIME_EXAMPLE,
)


Expand Down Expand Up @@ -458,7 +480,9 @@ class Meta:
]
)
)
revocation_list = fields.Nested(RevListSchema(), description="revocation list")
revocation_list = fields.Nested(
RevListSchema(), metadata={"description": "revocation list"}
)


class RevListResult(BaseModel):
Expand Down
28 changes: 18 additions & 10 deletions aries_cloudagent/anoncreds/models/anoncreds_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,26 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
attr_names = fields.List(
fields.Str(
description="Attribute name",
example="score",
metadata={
"description": "Attribute name",
"example": "score",
}
),
description="Schema attribute names",
metadata={"description": "Schema attribute names"},
data_key="attrNames",
)
name = fields.Str(description="Schema name", example="Example schema")
version = fields.Str(description="Schema version", example="1.0")
name = fields.Str(
metadata={"description": "Schema name", "example": "Example schema"}
)
version = fields.Str(metadata={"description": "Schema version", "example": "1.0"})


class GetSchemaResult(BaseModel):
Expand Down Expand Up @@ -130,7 +136,7 @@ class Meta:

schema_value = fields.Nested(AnonCredsSchemaSchema(), data_key="schema")
schema_id = fields.Str(
description="Schema identifier", example=INDY_SCHEMA_ID_EXAMPLE
metadata={"description": "Schema identifier", "example": INDY_SCHEMA_ID_EXAMPLE}
)
resolution_metadata = fields.Dict()
schema_metadata = fields.Dict()
Expand Down Expand Up @@ -184,8 +190,10 @@ class Meta:
)
)
schema_id = fields.Str(
description="Schema identifier",
example=INDY_SCHEMA_ID_EXAMPLE,
metadata={
"description": "Schema identifier",
"example": INDY_SCHEMA_ID_EXAMPLE,
}
)
schema_value = fields.Nested(AnonCredsSchemaSchema(), data_key="schema")

Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/anoncreds/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,15 +1209,15 @@ async def revoke_pending_credentials(
)
failed_crids.add(rev_id)
elif rev_id >= rev_info["next_index"]:
LOGGER.warn(
LOGGER.warning(
"Skipping requested credential revocation"
"on rev reg id %s, cred rev id=%s not yet issued",
revoc_reg_id,
rev_id,
)
failed_crids.add(rev_id)
elif rev_list.revocation_list[rev_id] == 1:
LOGGER.warn(
LOGGER.warning(
"Skipping requested credential revocation"
"on rev reg id %s, cred rev id=%s already revoked",
revoc_reg_id,
Expand Down Expand Up @@ -1259,7 +1259,7 @@ async def revoke_pending_credentials(
CATEGORY_REV_LIST, revoc_reg_id, for_update=True
)
if not rev_info_upd:
LOGGER.warn(
LOGGER.warning(
"Revocation registry missing, skipping update: {}",
revoc_reg_id,
)
Expand Down
Loading