Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 647 Bytes

0.develop_specifications.md

File metadata and controls

35 lines (25 loc) · 647 Bytes

开发规范

一.导包规范

1.禁止“裸顶级导入”

# ❌ 不允许:
from config import settings
from core import xxx
from registrar.app import registrar_app

因为它们依赖运行目录,脆弱。

2.跨模块一律使用「绝对导入」

# ✅ 统一写成:
from backend.config import settings
from backend.core.xxx import yyy
from backend.registrar.app.registrar_app import registrar_app

这条规则无脑安全。

3.仅在“同一子包内部”允许相对导入

backend/registrar/app/
├── __init__.py
├── registrar_app.py
└── helpers.py