Drop Python 3.9 support (cleanup checklist)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- python
- 领域
- build-system, ci-cd, tooling
调研方向
先从四个仓库的 pyproject.toml 文件和 CI 矩阵开始,然后检查列出的 Python 文件以及 policyengine.py 的 Ruff 和 mypy 配置。在更改条件项之前,检查依赖版本和现有的 3.9 兼容性工作。完成的标准是四个仓库都支持 Python 3.10+、CI 通过,并且全新的 3.10 环境能够安装 us 和 uk extras。
由索引模型根据 Issue 内容生成。
描述
Trigger
File when all confirmed 3.9 users (currently: Census) have migrated to 3.10+.
Background
Supporting 3.9 across the stack required working around non-trivial syntax and dependency cruft in four repos. ~95% of the cruft is 3.9-specific — dropping 3.9 alone recovers most of it, even if 3.10 support remains (3.10 hits EOL Oct 2026, ~6 months out, so keeping it through natural life is cheap).
Landed as: PolicyEngine/policyengine-core#454, PolicyEngine/policyengine-us#8035, PolicyEngine/policyengine-uk#1625, PolicyEngine/policyengine.py#278.
Checklist
All 4 repos
-
pyproject.toml: raiserequires-pythonfrom>=3.9to>=3.10 - Remove
Programming Language :: Python :: 3.9classifier - Remove
"3.9"from all CI Python matrices
policyengine-core (PolicyEngine/policyengine-core)
- Remove numpy env marker; go back to single
numpy>=2.1.0,<3(2.1+ supports 3.10+) - Hand-revert
Optional[X]/Tuple[X]→X | None/tuple[X]inpolicyengine_core/tools/hugging_face.pyandpolicyengine_core/tools/google_cloud.py(~5 sites; this repo's ruff config doesn't have UP rules enabled)
policyengine-us (PolicyEngine/policyengine-us)
- Remove
[tool.uv] environmentsblock inpyproject.tomlif it still exists (likely already gone once downstream core picks up 3.9-compat release) - Hand-revert
Optional[X]→X | Nonein:policyengine_us/system.py,data/economic_assumptions.py,data/dataset_schema.py,tests/core/test_payroll_contributions.py,tests/microsimulation/data/fixtures/test_extend_single_year_dataset.py(5 sites) - Regenerate
uv.lock
policyengine-uk (PolicyEngine/policyengine-uk)
- Remove
[tool.uv] environmentsblock (if still present) - Hand-revert 3 sites in
policyengine_uk/data/dataset_schema.pyandpolicyengine_uk/simulation.py -
policyengine_uk/tests/test_build_metadata.py: revertExitStackback to parenthesizedwith (a, b, c): -
[tool.ruff] target-version = "py39"→"py310" - Regenerate
uv.lock
policyengine.py (this repo)
-
pyproject.toml:[tool.ruff] target-version = "py39"→"py310"[tool.mypy] python_version = "3.9"→"3.10"- Remove
UP006,UP007,UP035,UP045from[tool.ruff.lint] ignore
- Auto-revert ~210 annotation sites:
ruff check --fix --unsafe-fixes .— this re-applies UP045 (Optional[X]→X | None), UP007 (Union[X, Y]→X | Y), UP006/UP035 (List→list). - Hand-revert the two discriminated-union sites ruff's UP rules don't cover:
src/policyengine/core/scoping_strategy.py:222(insideAnnotated[]) andsrc/policyengine/core/region.py:18(module-level type alias). - Simplify
Python-CompatCI job in.github/workflows/pr_code_changes.yaml— drop the explicith5pyinstall (needed becausescoping_strategy.pyimports it but extras weren't available; once[us]/[uk]extras are bumped to versions that pull h5py via core, it's redundant). - Bump
[us]/[uk]/[dev]extras offpolicyengine-us==1.602.0/policyengine-uk==2.74.0to versions that don't pin 3.11+ themselves (separate follow-up from this cleanup — may already be bumped by the time this issue is actioned).
Not in scope
Keep until 3.10 EOL (October 2026):
class Foo(str, Enum)pattern (4 files:outputs/{aggregate,change_aggregate,inequality,poverty}.py) — StrEnum is 3.11+timezone.utcincore/tax_benefit_model_version.py—datetime.UTCis 3.11+- Gotcha when
StrEnumreturns:str(Foo.X)differs —StrEnumreturns"x",(str, Enum)returns"Foo.X". Audit any code relying onstr()of enum members before reverting.
Keep until 3.12 EOL (October 2028):
TypeVar+Generic[T]pattern incore/cache.pyandcore/output.py— PEP 695class Foo[T]is 3.12+.
Verification
After cleanup, each repo's CI should be green with reduced matrix (3.10+). Cross-repo smoke: pip install policyengine[us] and pip install policyengine[uk] succeed on 3.10 in a fresh venv.
- 主要语言
- Python
- 星标
- 8
- 派生
- 10
- 平均合并
- 16 小时 3 分钟
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PolicyEngine/policyengine.py 的其他 Issue
-
Raise the simulation cache memory warning to 16 GiB可能已有人在做 @anth-volk 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
PolicyEngine/policyengine.py#549 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
PolicyEngine/policyengine.py#473 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
PolicyEngine/policyengine.py#436 · 1 条评论 ·
维护者通常 1 天内回复
-
Certify populace-uk as the UK certified default可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
PolicyEngine/policyengine.py#408 ·
维护者通常 1 天内回复
-
Check the UK nation filters against policyengine-uk's country formula可能已有人在做 @MaxGhenis 于 1 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
PolicyEngine/policyengine.py#569 ·
维护者通常 1 天内回复
查看 PolicyEngine/policyengine.py 的全部 Issue
相似的 Issue
-
Performance: deprecated DeviceEntry.config_entries access blocks the event loop for tens of seconds未关闭
难度 2/5 1-3 小时 新手友好度 75/100
tuya/tuya_cloud_ha_bridge#14 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
semantica-agi/semantica#1968 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
agent: ready area: submission priority: high type: docs
难度 2/5 1-3 小时 新手友好度 62/100
dkritarth/scopewatch#213 ·
维护者通常 1 天内回复
-
Broken link in RELEASE.md可能已有人在做 @Jah-yee 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
sphinx-contrib/httpdomain#143 ·
维护者通常 1 天内回复