Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Better example code?

オープン
#53 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@ericzbeard がすでに取り組んでいます。

2022年10月13日 から。

評価

この issue はまだ評価されていません。

説明

documentation good first issue p1

This could also be misunderstanding, the current example code in the create_handler looks like:

    try:
        if isinstance(session, SessionProxy):
            client = session.client("s3")
        # Setting Status to success will signal to cfn that the operation is complete
        progress.status = OperationStatus.SUCCESS
    except TypeError as e:
        # exceptions module lets CloudFormation know the type of failure that occurred
        raise exceptions.InternalFailure(f"was not expecting type {e}")
        # this can also be done by returning a failed progress event
        # return ProgressEvent.failed(HandlerErrorCode.InternalFailure, f"was not expecting type {e}")
    return progress

as far as I can see that will never raise a TypeError. So I feel this code will be better to get people started:

    if not isinstance(session, SessionProxy):
        # exceptions module lets CloudFormation know the type of failure that occurred
        raise exceptions.InternalFailure(f"session should be a SessionProxy")
        # this can also be done by returning a failed progress event
        # return ProgressEvent.failed(HandlerErrorCode.InternalFailure, f"was not expecting type {e}")
    
    # TODO: put code here

    # Setting Status to success will signal to cfn that the operation is complete
    progress.status = OperationStatus.SUCCESS
    return progress

That shows the same concepts, without having that try except increasing indentation.

Even if it would throw that exception, I don't see the added value of replacing that with a custom exception (it makes debugging harder if we do not re-raise the original exception)

If CloudFormation requires the thrown exception to be from the exceptions, this sort of code will lead to pokemon exception handling (gotta catch them all), and converting unknown exceptions to InternlFailure would be better handled in cloudformation-cli-python-lib

主要言語
Python
スター
107
フォーク
46
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws-cloudformation/cloudformation-cli-python-plugin のほかの issue

aws-cloudformation/cloudformation-cli-python-plugin の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。