我们总是感谢Django代码的补丁。确实,具有相关补丁的错误报告将比没有补丁的错误报告 更 快地得到修复。
如果您正在修复一个非常微不足道的问题,例如更改文档中的一个单词,推荐的方法是使用 GitHub 提交拉取请求,而无需使用 Trac 工单。
有关如何使用拉取请求的更多详细信息,请参见:doc:working-with-git
在一个全球有数百个贡献者的开源项目中,有效地管理沟通以避免重复工作并尽可能提高贡献者的效率是非常重要的。
因此,我们的政策是供贡献者“发布”工单,以便让其他开发人员知道正在处理特定的错误或功能。
如果您确定了要做出的贡献并且有能力解决(通过编程能力,Django内核知识水平和时间可用性来衡量),请按照以下步骤进行发表:
备注
Django软件基金会要求对Django贡献不小的补丁的人签署并提交 Contributor License Agreement 贡献者许可协议,以确保Django软件基金会对所有贡献都拥有明确的许可,从而为所有用户提供明确的许可。
发布工单后,您有责任以合理及时的方式处理该工单。 如果您没有时间来处理它,请先取消发布或不发布它!
如果一两周内没有任何关于特定已发布工单的进展迹象,则另一位开发人员可能会要求您放弃该发布了的工单,以使其不再被垄断,而其他人也可以发布。
如果您已发布工单,并且要花很长时间(几天或几周)编写代码,请通过在工单上发布评论来使每个人都保持最新状态。如果您不提供定期更新,并且不响应进度报告的请求,则您对工单的要求可能会被撤消。
与往常一样,多交流好过少交流!
在某些情况下,执行认领工单的步骤可能过于繁琐。
对于一些小的改动,比如文档中的错别字或只需要几分钟修复的小错误,您无需进行认领工单的繁琐步骤。直接提交您的补丁即可完成!
It is always acceptable, regardless whether someone has claimed it or not, to submit patches to a ticket if you happen to have a patch ready.
确保您所做的任何贡献至少满足以下要求:
When you think your work is ready to be reviewed, send a GitHub pull request. Please review the patch yourself using our patch review checklist first.
如果由于某种原因无法发送拉取请求,您还可以在 Trac 中使用补丁。在使用这种方式时,请遵循以下准则。
git diff
command..diff
命名补丁文件; 这将使工单跟踪系统应用正确的语法突出显示,这非常有帮助。无论您以何种方式提交工作成果,请按照以下步骤操作。
一个“非微小”的补丁是指不仅仅是修复小错误的补丁。它是一个引入 Django 功能并做出某种设计决策的补丁。
If you provide a non-trivial patch, include evidence that alternatives have been discussed on the Django Forum or django-developers list.
如果你不确定你的补丁是否应该被认为是非微小的,请在票务系统上征求意见。
Django 中的代码可能被弃用的原因有几个:
As the deprecation policy describes,
the first release of Django that deprecates a feature (A.B
) should raise a
RemovedInDjangoXXWarning
(where XX is the Django version where the feature
will be removed) when the deprecated feature is invoked. Assuming we have good
test coverage, these warnings are converted to errors when running the
test suite with warnings enabled:
python -Wa runtests.py
. Thus, when adding a RemovedInDjangoXXWarning
you need to eliminate or silence any warnings generated when running the tests.
The first step is to remove any use of the deprecated behavior by Django itself.
Next you can silence warnings in tests that actually test the deprecated
behavior by using the ignore_warnings
decorator, either at the test or class
level:
在一个特定的测试中:
from django.test import ignore_warnings
from django.utils.deprecation import RemovedInDjangoXXWarning
@ignore_warnings(category=RemovedInDjangoXXWarning)
def test_foo(self):
...
对于整个测试用例:
from django.test import ignore_warnings
from django.utils.deprecation import RemovedInDjangoXXWarning
@ignore_warnings(category=RemovedInDjangoXXWarning)
class MyDeprecatedTests(unittest.TestCase):
...
您还应该为弃用警告添加一个测试:
from django.utils.deprecation import RemovedInDjangoXXWarning
def test_foo_deprecation_warning(self):
msg = "Expected deprecation message"
with self.assertWarnsMessage(RemovedInDjangoXXWarning, msg):
# invoke deprecated behavior
...
It's important to include a RemovedInDjangoXXWarning
comment above code
which has no warning reference, but will need to be changed or removed when the
deprecation ends. This could include hooks which have been added to keep the
previous behavior, or standalone items that are unnecessary or unused when the
deprecation ends. For example:
import warnings
from django.utils.deprecation import RemovedInDjangoXXWarning
# RemovedInDjangoXXWarning.
def old_private_helper():
# Helper function that is only used in foo().
pass
def foo():
warnings.warn(
"foo() is deprecated.",
category=RemovedInDjangoXXWarning,
)
old_private_helper()
...
Finally, there are a couple of updates to Django's documentation to make:
.. deprecated:: A.B
annotation. Include a short description
and a note about the upgrade path if applicable.docs/releases/A.B.txt
) under
the "Features deprecated in A.B" heading.docs/internals/deprecation.txt
)
under the appropriate version describing what code will be removed.Once you have completed these steps, you are finished with the deprecation.
In each feature release, all
RemovedInDjangoXXWarning
s matching the new version are removed.
For information on JavaScript patches, see the JavaScript 补丁 documentation.
Use this checklist to review a pull request. If you are reviewing a pull request that is not your own and it passes all the criteria below, please set the "Triage Stage" on the corresponding Trac ticket to "Ready for checkin". If you've left comments for improvement on the pull request, please tick the appropriate flags on the Trac ticket based on the results of your review: "Patch needs improvement", "Needs documentation", and/or "Needs tests". As time and interest permits, mergers do final reviews of "Ready for checkin" tickets and will either commit the patch or bump it back to "Accepted" if further works need to be done. If you're looking to become a merger, doing thorough reviews of patches is a great way to earn trust.
Looking for a patch to review? Check out the "Patches needing review" section of the Django Development Dashboard. Looking to get your patch reviewed? Ensure the Trac flags on the ticket are set so that the ticket appears in that queue.
make html
, or
make.bat html
on Windows, from the docs
directory)?docs/releases/A.B.C.txt
? Bug fixes that will be applied only to the main
branch don't need a release note.docs/releases/A.B.txt
?.. versionadded:: A.B
or .. versionchanged:: A.B
?black
, blacken-docs
, flake8
, or
isort
errors? You can install the pre-commit hooks to automatically catch these errors.docs/releases/A.B.txt
)?9月 22, 2023