-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Run mypy in azure-keyvault-secrets CI #20507
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
Changes from 9 commits
e0e2e0c
0863a5d
622efd0
1c95057
251393a
2f028b7
fcad93a
e5c5670
2e2629e
91c34d6
aff13b0
c7678e3
8d90691
3c99736
968ab6b
71c65ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,19 +11,19 @@ | |
|
|
||
| if TYPE_CHECKING: | ||
| # pylint:disable=unused-import | ||
| from typing import Any, Dict, Optional | ||
| from typing import Any, Dict, Optional, Union | ||
| from datetime import datetime | ||
| from ._generated.v7_1 import models as _models | ||
|
|
||
|
|
||
| class SecretProperties(object): | ||
| """A secret's id and attributes.""" | ||
|
|
||
| def __init__(self, attributes, vault_id, **kwargs): | ||
| # type: (_models.SecretAttributes, str, **Any) -> None | ||
| def __init__(self, attributes=None, vault_id=None, **kwargs): | ||
| # type: (Optional[_models.SecretAttributes], Optional[str], **Any) -> None | ||
| self._attributes = attributes | ||
| self._id = vault_id | ||
| self._vault_id = KeyVaultSecretIdentifier(vault_id) | ||
| self._vault_id = KeyVaultSecretIdentifier(vault_id) if vault_id else None | ||
YalinLi0312 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self._content_type = kwargs.get("content_type", None) | ||
| self._key_id = kwargs.get("key_id", None) | ||
| self._managed = kwargs.get("managed", None) | ||
|
|
@@ -69,10 +69,10 @@ def content_type(self): | |
|
|
||
| @property | ||
| def id(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
YalinLi0312 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """The secret's id | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
YalinLi0312 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| return self._id | ||
|
|
||
|
|
@@ -87,55 +87,55 @@ def key_id(self): | |
|
|
||
| @property | ||
| def enabled(self): | ||
| # type: () -> bool | ||
| # type: () -> Union[bool, None] | ||
YalinLi0312 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """Whether the secret is enabled for use | ||
|
|
||
| :rtype: bool | ||
| :rtype: union[bool, None] | ||
| """ | ||
| return self._attributes.enabled | ||
| return self._attributes.enabled if self._attributes else None | ||
|
|
||
| @property | ||
| def not_before(self): | ||
| # type: () -> datetime | ||
| # type: () -> Union[datetime, None] | ||
| """The time before which the secret can not be used, in UTC | ||
|
|
||
| :rtype: ~datetime.datetime | ||
| :rtype: union[~datetime.datetime, None] | ||
| """ | ||
| return self._attributes.not_before | ||
| return self._attributes.not_before if self._attributes else None | ||
|
|
||
| @property | ||
| def expires_on(self): | ||
| # type: () -> datetime | ||
| # type: () -> Union[datetime, None] | ||
| """When the secret expires, in UTC | ||
|
|
||
| :rtype: ~datetime.datetime | ||
| :rtype: union[~datetime.datetime, None] | ||
| """ | ||
| return self._attributes.expires | ||
| return self._attributes.expires if self._attributes else None | ||
|
|
||
| @property | ||
| def created_on(self): | ||
| # type: () -> datetime | ||
| # type: () -> Union[datetime, None] | ||
| """When the secret was created, in UTC | ||
|
|
||
| :rtype: ~datetime.datetime | ||
| :rtype: union[~datetime.datetime, None] | ||
| """ | ||
| return self._attributes.created | ||
| return self._attributes.created if self._attributes else None | ||
|
|
||
| @property | ||
| def updated_on(self): | ||
| # type: () -> datetime | ||
| # type: () -> Union[datetime, None] | ||
| """When the secret was last updated, in UTC | ||
|
|
||
| :rtype: ~datetime.datetime | ||
| :rtype: union[~datetime.datetime, None] | ||
| """ | ||
| return self._attributes.updated | ||
| return self._attributes.updated if self._attributes else None | ||
|
|
||
| @property | ||
| def recoverable_days(self): | ||
| # type: () -> Optional[int] | ||
| """The number of days the key is retained before being deleted from a soft-delete enabled Key Vault. | ||
|
|
||
| :rtype: int | ||
| :rtype: optional[int] | ||
| """ | ||
| # recoverable_days was added in 7.1-preview | ||
| if self._attributes and hasattr(self._attributes, "recoverable_days"): | ||
|
|
@@ -144,39 +144,39 @@ def recoverable_days(self): | |
|
|
||
| @property | ||
| def recovery_level(self): | ||
| # type: () -> str | ||
| # type: () -> Union[str, None] | ||
| """The vault's deletion recovery level for secrets | ||
|
|
||
| :rtype: str | ||
| :rtype: union[str, None] | ||
| """ | ||
| return self._attributes.recovery_level | ||
| return self._attributes.recovery_level if self._attributes else None | ||
|
|
||
| @property | ||
| def vault_url(self): | ||
| # type: () -> str | ||
| # type: () -> Union[str, None] | ||
| """URL of the vault containing the secret | ||
|
|
||
| :rtype: str | ||
| :rtype: union[str, None] | ||
| """ | ||
| return self._vault_id.vault_url | ||
| return self._vault_id.vault_url if self._vault_id else None | ||
|
|
||
| @property | ||
| def name(self): | ||
| # type: () -> str | ||
| # type: () -> Union[str, None] | ||
| """The secret's name | ||
|
|
||
| :rtype: str | ||
| :rtype: union[str, None] | ||
| """ | ||
| return self._vault_id.name | ||
| return self._vault_id.name if self._vault_id else None | ||
|
|
||
| @property | ||
| def version(self): | ||
| # type: () -> str | ||
| # type: () -> Union[str, None] | ||
| """The secret's version | ||
|
|
||
| :rtype: str | ||
| :rtype: union[str, None] | ||
| """ | ||
| return self._vault_id.version | ||
| return self._vault_id.version if self._vault_id else None | ||
|
|
||
| @property | ||
| def tags(self): | ||
|
|
@@ -191,7 +191,7 @@ class KeyVaultSecret(object): | |
| """All of a secret's properties, and its value.""" | ||
|
|
||
| def __init__(self, properties, value): | ||
| # type: (SecretProperties, str) -> None | ||
| # type: (SecretProperties, Optional[str]) -> None | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a case where the type checking gets a little confusing. A SecretBundle can have a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When does SecretBundle have a None value?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't in any real scenario I've seen (and I doubt it ever would), but its type signature leaves the possibility open.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then this introduces one question that happened several times in mypy ci: |
||
| self._properties = properties | ||
| self._value = value | ||
|
|
||
|
|
@@ -210,19 +210,19 @@ def _from_secret_bundle(cls, secret_bundle): | |
|
|
||
| @property | ||
| def name(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
| """The secret's name | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
| """ | ||
| return self._properties.name | ||
|
|
||
| @property | ||
| def id(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
| """The secret's id | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
| """ | ||
| return self._properties.id | ||
|
|
||
|
|
@@ -237,10 +237,10 @@ def properties(self): | |
|
|
||
| @property | ||
| def value(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
| """The secret's value | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
| """ | ||
| return self._value | ||
|
|
||
|
|
@@ -329,19 +329,19 @@ def _from_deleted_secret_item(cls, deleted_secret_item): | |
|
|
||
| @property | ||
| def name(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
| """The secret's name | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
| """ | ||
| return self._properties.name | ||
|
|
||
| @property | ||
| def id(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
| """The secret's id | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
| """ | ||
| return self._properties.id | ||
|
|
||
|
|
@@ -356,27 +356,27 @@ def properties(self): | |
|
|
||
| @property | ||
| def deleted_date(self): | ||
| # type: () -> datetime | ||
| # type: () -> Optional[datetime] | ||
| """When the secret was deleted, in UTC | ||
|
|
||
| :rtype: ~datetime.datetime | ||
| :rtype: optional[~datetime.datetime] | ||
| """ | ||
| return self._deleted_date | ||
|
|
||
| @property | ||
| def recovery_id(self): | ||
| # type: () -> str | ||
| # type: () -> Optional[str] | ||
| """An identifier used to recover the deleted secret. Returns ``None`` if soft-delete is disabled. | ||
|
|
||
| :rtype: str | ||
| :rtype: optional[str] | ||
| """ | ||
| return self._recovery_id | ||
|
|
||
| @property | ||
| def scheduled_purge_date(self): | ||
| # type: () -> datetime | ||
| # type: () -> Optional[datetime] | ||
| """When the secret is scheduled to be purged, in UTC. Returns ``None`` if soft-delete is disabled. | ||
|
|
||
| :rtype: ~datetime.datetime | ||
| :rtype: optional[~datetime.datetime] | ||
| """ | ||
| return self._scheduled_purge_date | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [mypy] | ||
| python_version = 3.6 | ||
| warn_unused_configs = True | ||
| ignore_missing_imports = True | ||
|
|
||
| [mypy-azure.keyvault.*._generated.*] | ||
| ignore_errors = True |
Uh oh!
There was an error while loading. Please reload this page.