Replace and rewrite "assert" statements in non-test code

未關閉
#175 51 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@SaitejaBandari756 已經在處理了。

開始於 2025年12月10日。

  • #224 來自 @SaitejaBandari756 —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
55/100
Issue 類型
重構
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python
領域
backend, tooling

研究方向

從連結的 GitHub 程式碼搜尋開始,尋找 aboutcode-org 儲存庫中非測試程式碼裡的 Python assert 陳述式。對於主要程式碼中的每個 assert,判斷應使用哪個明確的執行階段例外和訊息來取代它,然後執行相關的專案測試。完成的標準是:非測試程式碼中的 assert 已被移除或說明其合理性,且行為仍由測試涵蓋。

由索引模型根據 Issue 內容生成。

描述

easy good first issue

See https://www.reddit.com/r/learnpython/comments/zd217y/is_using_assert_considered_good_practice/

assert statements should only be used for debugging purposes. They are removed when not running in debug mode (i.e. when invoking the Python command with the -O or -OO options).

Instead use a raise statement to throw a proper, informative runtime exception, if you need to. That would definitely be best practice when there'd otherwise be no sensible return value for the function.

We are using a few asserts in our main code. See https://github.com/search?q=org%3Aaboutcode-org+NOT+path%3A*test*++"assert"++language%3APython&type=code

主要語言
Batchfile
星號
310
分支
255
平均合併
10 小時 5 分鐘
30 天內合併 PR
1

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aboutcode-org/aboutcode 的其他 Issue

查看 aboutcode-org/aboutcode 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。