add Object.__eq__ and Object.__hash__
未關閉
還沒有人認領這個 Issue。
feature
- 主要語言
- Python
- 星號
- 1.7k
- 分支
- 408
- 平均合併
- 2 天 57 分鐘
- 30 天內合併 PR
- 7
描述
It would be intuitive if this worked:
r = Repository('.git')
r['103ea4507a9df26a19388cd4115c8bfd1fb784af'] == r['103ea4507a9df26a19388cd4115c8bfd1fb784af']
I'd like to add a __eq__ method to Object which compares the underlying Oid object held by the id attribute.
Additionally, since this this attribute is read-only Objects are effectively immutable, thus it would be great to have a __hash__ method (which returns hash(self.id)) so that Objects can be placed in sets and used as keys in dictionaries.
I'm happy to make the PR for this if you think it makes sense.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先找出 Object 的進入點及其唯讀的 id 屬性,接著檢查 Repository 查詢如何產生物件。使用 Repository('.git') 範例驗證所要求的相等性與雜湊行為,包括物件可以放入集合並作為字典鍵使用。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- git, python
- 領域
- backend
- Issue 類型
- 功能
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100