DHI / DHI/python-package-development

Add content on deprecating functionality

未關閉
#33 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jupyter Notebook
星號
8
分支
1
平均合併
4 分鐘
30 天內合併 PR
1

描述

## Problem
The course covers semantic versioning and breaking changes in Module 7, but lacks content on **deprecation strategies** - a critical skill for package maintainers.

## Proposed Content

Add a section to Module 7 (`07_packaging.qmd`) covering:

### 1. Deprecation Warnings
- Using Python's `warnings` module
- Proper `stacklevel` usage
- **DeprecationWarning vs FutureWarning**:
- `DeprecationWarning`: For developers (filtered by default, shown when running tests)
- `FutureWarning`: For end users (always visible, for changes affecting user code)

### 2. Deprecation Timeline
- Announce in version X.Y
- Remove in version (X+1).0
- Maintain for 1-2 minor releases minimum

### 3. Communication Strategy
- CHANGELOG updates
- Release notes
- Documentation migration guides
- Clear docstring warnings

### 4. Code Examples
```python
import warnings

def old_function(x):
warnings.warn(
"old_function is deprecated and will be removed in version 2.0. "
"Use new_function instead.",
DeprecationWarning,
stacklevel=2
)
return new_function(x)
```

### 5. Real-World Examples
Reference deprecation practices from popular packages (pandas, numpy, scikit-learn).

## Location
Module 7 - after the "Breaking changes" section (around line 132)

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

開啟 07_packaging.qmd 中的 Module 7,閱讀第 132 行附近現有的「Breaking changes」區段。新增一個聚焦於 warning 類型與 stacklevel、deprecation 時程、溝通實務,以及程式碼和真實世界範例的區段。當模組清楚說明這些策略,並與周圍的課程內容相符時,即視為完成。

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

評估

技術堆疊
python
領域
documentation
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
52/100

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

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