Skip to main content

使用 mypy-boto3-builder 7.10.0 生成的 boto3.Glacier 1.24.36 服务的类型注释

项目描述

mypy-boto3-冰川

PyPI - mypy-boto3-glacier PyPI - Python 版本 文档 PyPI - 下载

boto3.typed

boto3.Glacier 1.24.36服务的类型注释 兼容VSCodePyCharmEmacsSublime Textmypypyright和其他工具。

mypy-boto3-builder 7.10.0 生成

更多信息可以在 boto3-stubs页面和 mypy-boto3-glacier 文档中找到。

了解它如何帮助查找和修复潜在错误:

boto3-stubs 演示

如何安装

VSCode 扩展

AWS Boto3 扩展添加到您的 VSCode 并运行AWS boto3: Quick Start命令。

单击Modify并选择boto3 commonGlacier

来自带有 pip 的 PyPI

安装boto3-stubs服务Glacier

# install with boto3 type annotations
python -m pip install 'boto3-stubs[glacier]'


# Lite version does not provide session.client/resource overloads
# it is more RAM-friendly, but requires explicit type annotations
python -m pip install 'boto3-stubs-lite[glacier]'


# standalone installation
python -m pip install mypy-boto3-glacier

如何卸载

python -m pip uninstall -y mypy-boto3-glacier

用法

VSCode

  • 安装 Python 扩展
  • 安装 Pylance 扩展
  • 设置Pylance为您的 Python 语言服务器
  • boto3-stubs[glacier]在您的环境中安装:
python -m pip install 'boto3-stubs[glacier]'

类型检查和代码完成现在都应该可以工作了。不需要显式类型注释,boto3像往常一样编写代码。

PyCharm

boto3-stubs-lite[glacier]在您的环境中安装:

python -m pip install 'boto3-stubs-lite[glacier]'`

类型检查和代码完成现在都应该可以工作了。需要显式类型注释。

使用boto3-stubs包代替隐式类型发现。

Emacs

  • 安装boto3-stubs您在环境中使用的服务:
python -m pip install 'boto3-stubs[glacier]'
(use-package lsp-pyright
  :ensure t
  :hook (python-mode . (lambda ()
                          (require 'lsp-pyright)
                          (lsp)))  ; or lsp-deferred
  :init (when (executable-find "python3")
          (setq lsp-pyright-python-executable-cmd "python3"))
  )
  • 确保 emacs 使用您安装的环境boto3-stubs

类型检查现在应该可以工作了。不需要显式类型注释,boto3像往常一样编写代码。

崇高的文本

  • 安装boto3-stubs[glacier]您在环境中使用的服务:
python -m pip install 'boto3-stubs[glacier]'

类型检查现在应该可以工作了。不需要显式类型注释,boto3像往常一样编写代码。

其他 IDE

未经测试,但只要您的 IDE 支持mypyor pyright,一切都应该工作。

我的

  • 安装mypypython -m pip install mypy
  • boto3-stubs[glacier]在您的环境中安装:
python -m pip install 'boto3-stubs[glacier]'`

类型检查现在应该可以工作了。不需要显式类型注释,boto3像往常一样编写代码。

版权

  • 安装pyrightnpm i -g pyright
  • boto3-stubs[glacier]在您的环境中安装:
python -m pip install 'boto3-stubs[glacier]'

或者,您可以安装boto3-stubstypings文件夹。

类型检查现在应该可以工作了。不需要显式类型注释,boto3像往常一样编写代码。

显式类型注释

客户端注释

GlacierClientboto3.client("glacier").

from boto3.session import Session

from mypy_boto3_glacier import GlacierClient

client: GlacierClient = Session().client("glacier")

# now client usage is checked by mypy and IDE should provide code completion

分页器注释

mypy_boto3_glacier.paginator模块包含所有分页器的类型注释。

from boto3.session import Session

from mypy_boto3_glacier import GlacierClient
from mypy_boto3_glacier.paginator import (
    ListJobsPaginator,
    ListMultipartUploadsPaginator,
    ListPartsPaginator,
    ListVaultsPaginator,
)

client: GlacierClient = Session().client("glacier")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
# VSCode requires explicit type annotations
list_jobs_paginator: ListJobsPaginator = client.get_paginator("list_jobs")
list_multipart_uploads_paginator: ListMultipartUploadsPaginator = client.get_paginator("list_multipart_uploads")
list_parts_paginator: ListPartsPaginator = client.get_paginator("list_parts")
list_vaults_paginator: ListVaultsPaginator = client.get_paginator("list_vaults")

服务员注释

mypy_boto3_glacier.waiter模块包含所有服务员的类型注释。

from boto3.session import Session

from mypy_boto3_glacier import GlacierClient
from mypy_boto3_glacier.waiter import (
    VaultExistsWaiter,
    VaultNotExistsWaiter,
)

client: GlacierClient = Session().client("glacier")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
# VSCode requires explicit type annotations
vault_exists_waiter: VaultExistsWaiter = client.get_waiter("vault_exists")
vault_not_exists_waiter: VaultNotExistsWaiter = client.get_waiter("vault_not_exists")

服务资源注释

GlacierServiceResourceboto3.resource("glacier").

from boto3.session import Session

from mypy_boto3_glacier import GlacierServiceResource

resource: GlacierServiceResource = Session().resource("glacier")

# now resource usage is checked by mypy and IDE should provide code completion

其他资源注释

mypy_boto3_glacier.service_resource模块包含所有资源的类型注释。

from boto3.session import Session

from mypy_boto3_glacier import GlacierServiceResource
from mypy_boto3_glacier.service_resource import (
    Account,
    Archive,
    Job,
    MultipartUpload,
    Notification,
    Vault,
)

resource: GlacierServiceResource = Session().resource("glacier")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
my_account: Account = resource.Account(...)
my_archive: Archive = resource.Archive(...)
my_job: Job = resource.Job(...)
my_multipart_upload: MultipartUpload = resource.MultipartUpload(...)
my_notification: Notification = resource.Notification(...)
my_vault: Vault = resource.Vault(...)

集合注释

mypy_boto3_glacier.service_resource模块包含所有 GlacierServiceResource集合的类型注释。

from boto3.session import Session

from mypy_boto3_glacier import GlacierServiceResource
from mypy_boto3_glacier.service_resource import (
    ServiceResourceVaultsCollection,
)

resource: GlacierServiceResource = Session().resource("glacier")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
vaults: glacier_resources.ServiceResourceVaultsCollection = resource.vaults

字面量

mypy_boto3_glacier.literals模块包含从形状中提取的文字,可在用户代码中用于类型检查。

from mypy_boto3_glacier.literals import (
    ActionCodeType,
    CannedACLType,
    EncryptionTypeType,
    ExpressionTypeType,
    FileHeaderInfoType,
    ListJobsPaginatorName,
    ListMultipartUploadsPaginatorName,
    ListPartsPaginatorName,
    ListVaultsPaginatorName,
    PermissionType,
    QuoteFieldsType,
    StatusCodeType,
    StorageClassType,
    TypeType,
    VaultExistsWaiterName,
    VaultNotExistsWaiterName,
    GlacierServiceName,
    ServiceName,
    ResourceServiceName,
    PaginatorName,
    WaiterName,
    RegionName,
)

def check_value(value: ActionCodeType) -> bool:
    ...

打字字典

mypy_boto3_glacier.type_defs模块包含组装到类型化字典的结构和形状,以进行额外的类型检查。

from mypy_boto3_glacier.type_defs import (
    AbortMultipartUploadInputRequestTypeDef,
    AbortVaultLockInputRequestTypeDef,
    AccountVaultRequestTypeDef,
    AddTagsToVaultInputRequestTypeDef,
    ResponseMetadataTypeDef,
    CSVInputTypeDef,
    CSVOutputTypeDef,
    CompleteMultipartUploadInputMultipartUploadCompleteTypeDef,
    CompleteMultipartUploadInputRequestTypeDef,
    CompleteVaultLockInputRequestTypeDef,
    CreateVaultInputAccountCreateVaultTypeDef,
    CreateVaultInputRequestTypeDef,
    CreateVaultInputServiceResourceCreateVaultTypeDef,
    DataRetrievalRuleTypeDef,
    DeleteArchiveInputRequestTypeDef,
    DeleteVaultAccessPolicyInputRequestTypeDef,
    DeleteVaultInputRequestTypeDef,
    DeleteVaultNotificationsInputRequestTypeDef,
    DescribeJobInputRequestTypeDef,
    DescribeVaultInputRequestTypeDef,
    WaiterConfigTypeDef,
    DescribeVaultOutputTypeDef,
    EncryptionTypeDef,
    GetDataRetrievalPolicyInputRequestTypeDef,
    GetJobOutputInputJobGetOutputTypeDef,
    GetJobOutputInputRequestTypeDef,
    GetVaultAccessPolicyInputRequestTypeDef,
    VaultAccessPolicyTypeDef,
    GetVaultLockInputRequestTypeDef,
    GetVaultNotificationsInputRequestTypeDef,
    VaultNotificationConfigTypeDef,
    InventoryRetrievalJobDescriptionTypeDef,
    GranteeTypeDef,
    InitiateMultipartUploadInputRequestTypeDef,
    InitiateMultipartUploadInputVaultInitiateMultipartUploadTypeDef,
    VaultLockPolicyTypeDef,
    InventoryRetrievalJobInputTypeDef,
    PaginatorConfigTypeDef,
    ListJobsInputRequestTypeDef,
    ListMultipartUploadsInputRequestTypeDef,
    UploadListElementTypeDef,
    ListPartsInputMultipartUploadPartsTypeDef,
    ListPartsInputRequestTypeDef,
    PartListElementTypeDef,
    ListProvisionedCapacityInputRequestTypeDef,
    ProvisionedCapacityDescriptionTypeDef,
    ListTagsForVaultInputRequestTypeDef,
    ListVaultsInputRequestTypeDef,
    PurchaseProvisionedCapacityInputRequestTypeDef,
    RemoveTagsFromVaultInputRequestTypeDef,
    ServiceResourceAccountRequestTypeDef,
    ServiceResourceArchiveRequestTypeDef,
    ServiceResourceJobRequestTypeDef,
    ServiceResourceMultipartUploadRequestTypeDef,
    ServiceResourceNotificationRequestTypeDef,
    ServiceResourceVaultRequestTypeDef,
    UploadArchiveInputRequestTypeDef,
    UploadArchiveInputVaultUploadArchiveTypeDef,
    UploadMultipartPartInputMultipartUploadUploadPartTypeDef,
    UploadMultipartPartInputRequestTypeDef,
    VaultArchiveRequestTypeDef,
    VaultJobRequestTypeDef,
    VaultMultipartUploadRequestTypeDef,
    ArchiveCreationOutputTypeDef,
    CreateVaultOutputTypeDef,
    DescribeVaultOutputResponseMetadataTypeDef,
    EmptyResponseMetadataTypeDef,
    GetJobOutputOutputTypeDef,
    GetVaultLockOutputTypeDef,
    InitiateJobOutputTypeDef,
    InitiateMultipartUploadOutputTypeDef,
    InitiateVaultLockOutputTypeDef,
    InventoryRetrievalJobDescriptionResponseMetadataTypeDef,
    ListTagsForVaultOutputTypeDef,
    PurchaseProvisionedCapacityOutputTypeDef,
    UploadMultipartPartOutputTypeDef,
    InputSerializationTypeDef,
    OutputSerializationTypeDef,
    DataRetrievalPolicyTypeDef,
    DescribeVaultInputVaultExistsWaitTypeDef,
    DescribeVaultInputVaultNotExistsWaitTypeDef,
    ListVaultsOutputTypeDef,
    GetVaultAccessPolicyOutputTypeDef,
    SetVaultAccessPolicyInputRequestTypeDef,
    GetVaultNotificationsOutputTypeDef,
    SetVaultNotificationsInputNotificationSetTypeDef,
    SetVaultNotificationsInputRequestTypeDef,
    GrantTypeDef,
    InitiateVaultLockInputRequestTypeDef,
    ListJobsInputListJobsPaginateTypeDef,
    ListMultipartUploadsInputListMultipartUploadsPaginateTypeDef,
    ListPartsInputListPartsPaginateTypeDef,
    ListVaultsInputListVaultsPaginateTypeDef,
    ListMultipartUploadsOutputTypeDef,
    ListPartsOutputTypeDef,
    ListProvisionedCapacityOutputTypeDef,
    SelectParametersResponseMetadataTypeDef,
    SelectParametersTypeDef,
    GetDataRetrievalPolicyOutputTypeDef,
    SetDataRetrievalPolicyInputRequestTypeDef,
    S3LocationTypeDef,
    OutputLocationResponseMetadataTypeDef,
    OutputLocationTypeDef,
    GlacierJobDescriptionResponseMetadataTypeDef,
    GlacierJobDescriptionTypeDef,
    JobParametersTypeDef,
    ListJobsOutputTypeDef,
    InitiateJobInputRequestTypeDef,
)

def get_structure() -> AbortMultipartUploadInputRequestTypeDef:
    return {
      ...
    }

这个怎么运作

全自动 的mypy-boto3-builder为每个服务仔细生成类型注解,耐心等待boto3 更新。它为您提供插入式注释,并确保:

  • 涵盖所有可用boto3服务。
  • 每个boto3服务的每个公共类和方法都会从文档中提取有效的类型注释(botocore如果类型不正确,请归咎于文档)。
  • 类型注释包括最新的文档。
  • 每种方法都提供了文档链接。
  • 为了可读性,代码由blackisort处理。

什么是新的

实现的功能

  • 全类型注释boto3botocoreaiobotocore
  • mypy, pyright, VSCode, PyCharm,Sublime TextEmacs 兼容性
  • Client, ServiceResource, Resource,Waiter Paginator为每个服务键入注释
  • TypeDefs为每个服务生成
  • Literals为每个服务生成
  • 自动发现类型boto3.clientboto3.session调用
  • 自动发现类型session.clientsession.session调用
  • 自动发现类型client.get_waiterclient.get_paginator 调用
  • 自动发现类型ServiceResourceResource集合
  • 自动发现aiobotocore.Session.create_client呼叫类型

最新变化

生成器更改日志可以在 Releases中找到。

版本控制

mypy-boto3-glacier版本与相关boto3版本相同,遵循 PEP 440格式。

谢谢

文档

所有服务类型注释都可以在 boto3 文档中找到

支持和贡献

这个包是自动生成的。请在mypy-boto3-builder存储库中报告任何错误或请求新功能 。

项目详情