89 captures
25 Jun 2018 - 05 Feb 2026
Mar APR May
18
2021 2022 2023
success
fail

About this capture

COLLECTED BY

Collection: Ukrainian Web

TIMESTAMPS

The Wayback Machine - http://web.archive.org/web/20220418081213/https://devguide.python.org/pullrequest/
  Contents   <span class="latin" style="width:19px;height:19px;">M</span><span class="latin" style="width:19px;height:19px;">e</span><span class="latin" style="width:19px;height:19px;">n</span><span class="latin" style="width:19px;height:19px;">u</span>   <span class="latin" style="width:19px;height:19px;">E</span><span class="latin" style="width:19px;height:19px;">x</span><span class="latin" style="width:19px;height:19px;">p</span><span class="latin" style="width:19px;height:19px;">a</span><span class="latin" style="width:19px;height:19px;">n</span><span class="latin" style="width:19px;height:19px;">d</span>   <span class="latin" style="width:19px;height:19px;">L</span><span class="latin" style="width:19px;height:19px;">i</span><span class="latin" style="width:19px;height:19px;">g</span><span class="latin" style="width:19px;height:19px;">h</span><span class="latin" style="width:19px;height:19px;">t</span><span class="latin" style="display:block;width:19px;height:19px;"> </span><span class="latin" style="width:19px;height:19px;">m</span><span class="latin" style="width:19px;height:19px;">o</span><span class="latin" style="width:19px;height:19px;">d</span><span class="latin" style="width:19px;height:19px;">e</span>   <span class="latin" style="width:19px;height:19px;">D</span><span class="latin" style="width:19px;height:19px;">a</span><span class="latin" style="width:19px;height:19px;">r</span><span class="latin" style="width:19px;height:19px;">k</span><span class="latin" style="display:block;width:19px;height:19px;"> </span><span class="latin" style="width:19px;height:19px;">m</span><span class="latin" style="width:19px;height:19px;">o</span><span class="latin" style="width:19px;height:19px;">d</span><span class="latin" style="width:19px;height:19px;">e</span>   <span class="latin" style="width:19px;height:19px;">A</span><span class="latin" style="width:19px;height:19px;">u</span><span class="latin" style="width:19px;height:19px;">t</span><span class="latin" style="width:19px;height:19px;">o</span><span class="latin" style="display:block;width:19px;height:19px;"> </span><span class="latin" style="width:19px;height:19px;">l</span><span class="latin" style="width:19px;height:19px;">i</span><span class="latin" style="width:19px;height:19px;">g</span><span class="latin" style="width:19px;height:19px;">h</span><span class="latin" style="width:19px;height:19px;">t</span><span class="latin" style="width:19px;height:19px;">/</span><span class="latin" style="width:19px;height:19px;">d</span><span class="latin" style="width:19px;height:19px;">a</span><span class="latin" style="width:19px;height:19px;">r</span><span class="latin" style="width:19px;height:19px;">k</span><span class="latin" style="display:block;width:19px;height:19px;"> </span><span class="latin" style="width:19px;height:19px;">m</span><span class="latin" style="width:19px;height:19px;">o</span><span class="latin" style="width:19px;height:19px;">d</span><span class="latin" style="width:19px;height:19px;">e</span>  
Hide navigation sidebar

Hide table of contents sidebar

 


Toggle site navigation sidebar
 


Python Developer's Guide 



Toggle Light / Dark / Auto color theme
 

Toggle table of contents sidebar
 




Python Developer's Guide 



Getting Started

Where to Get Help

Lifecycle of a Pull Request

Running & Writing Tests

Increase Test Coverage

Helping with Documentation

Documenting Python

Silence Warnings From the Test Suite

Fixing easy Issues (and Beyond)

Issue Tracking
Toggle child pages in navigation


GitHub Labels

GitHub issues for BPO users



Triaging an Issue

Following Pythons Development

Porting Python to a new platform

How to Become a Core Developer

Developer Log

Accepting Pull Requests

Development Cycle

Continuous Integration

Adding to the Stdlib

Changing the Python Language

Experts Index

gdb Support

Exploring CPythons Internals

Changing CPythons Grammar

Guide to CPythons Parser

Design of CPythons Compiler

Design of CPythons Garbage Collector

Updating standard library extension modules

Changing Pythons C API

Coverity Scan

Dynamic Analysis with Clang

Running a buildbot worker

Core Developer Motivations and Affiliations

Git Bootcamp and Cheat Sheet

Appendix: Topics





     v: latest  


Versions

latest
 


Downloads

pdf

html

epub
 


On Read the Docs

Project Home  

Builds  








Back to top  

Edit this page  


Toggle Light / Dark / Auto color theme
 

Toggle table of contents sidebar
 

Lifecycle of a Pull Request#

Introduction#


CPython uses a workflow based on pull requests. What this means is that you create a branch in Git, make your changes, push those changes to your fork on GitHub (origin), and then create a pull request against the official CPython repository (upstream).

Quick Guide#


Clear communication is key to contributing to any project, especially an Open Source project like CPython.

Here is a quick overview of how you can contribute to CPython:


Create an issue that describes your change *

Create a new branch in Git

Work on changes (e.g. fix a bug or add a new feature)

Run tests and make patchcheck

Commit and push changes to your GitHub fork

Create Pull Request on GitHub to merge a branch from your fork

Make sure the continuous integration checks on your Pull Request are green (i.e. successful)

Review and address comments on your Pull Request

When your changes are merged, you can delete the PR branch

Celebrate contributing to CPython! :)



*

If an issue is trivial (e.g. typo fixes), or if an issue already exists, you can skip this step.




Note

In order to keep the commit history intact, please avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits.

Step-by-step Guide#


You should have already set up your system, got the source code, and built Python.


Update data from your upstream repository:

git fetch upstream




Create a new branch in your local clone:

git checkout -b <branch-name> upstream/main




Make changes to the code, and use git status and git diff to see them.

(Learn more about Making Good PRs)


Make sure the changes are fine and dont cause any test failure:

make patchcheck
./python -m test



(Learn more about patchcheck and about Running & Writing Tests)


Once you are satisfied with the changes, add the files and commit them:

git add <filenames>
git commit -m '<message>'



(Learn more about Making Good Commits)


Then push your work to your GitHub fork:

git push origin <branch-name>




Finally go on https://github.com/<your-username>/cpython: you will see a box with the branch you just pushed and a green button that allows you to create a pull request against the official CPython repository.

When people start adding review comments, you can address them by switching to your branch, making more changes, committing them, and pushing them to automatically update your PR:

git checkout <branch-name>
# make changes and run tests
git add <filenames>
git commit -m '<message>'
git push origin <branch-name>




If a core developer reviewing your PR pushed one or more commits to your PR branch, then after checking out your branch and before editing, run:

git pull origin <branch-name>  # pull = fetch + merge



If you have made local changes that have not been pushed to your fork and there are merge conflicts, git will warn you about this and enter conflict resolution mode. See Resolving Merge Conflicts below.




If time passes and there are merge conflicts with the main branch, GitHub will show a warning to this end and you may be asked to address this. Merge the changes from the main branch while resolving the conflicts locally:

git checkout <branch-name>
git pull upstream main  # pull = fetch + merge
# resolve conflicts: see "Resolving Merge Conflicts" below
git push origin <branch-name>




After your PR has been accepted and merged, you can delete the branch:

git branch -D <branch-name>  # delete local branch
git push origin -d <branch-name>  # delete remote branch




Resolving Merge Conflicts#


When merging changes from different branches (or variants of a branch on different repos), the two branches may contain incompatible changes to one or more files. These are called merge conflicts and need to be manually resolved as follows:


Check which files have merge conflicts:

git status




Edit the affected files and bring them to their intended final state. Make sure to remove the special conflict markers inserted by git.

Commit the affected files:

git add <filenames>
git merge --continue





When running the final command, git may open an editor for writing a commit message. It is usually okay to leave that as-is and close the editor.

See the merge commands documentation for a detailed technical explanation.

Making Good PRs#


When creating a pull request for submission, there are several things that you should do to help ensure that your pull request is accepted.

First, make sure to follow Pythons style guidelines. For Python code you should follow PEP 8, and for C code you should follow PEP 7. If you have one or two discrepancies those can be fixed by the core developer who merges your pull request. But if you have systematic deviations from the style guides your pull request will be put on hold until you fix the formatting issues.


Note

Pull requests with only code formatting changes are usually rejected. On the other hand, fixes for typos and grammar errors in documents and docstrings are welcome.


Second, be aware of backwards-compatibility considerations. While the core developer who eventually handles your pull request will make the final call on whether something is acceptable, thinking about backwards-compatibility early will help prevent having your pull request rejected on these grounds. Put yourself in the shoes of someone whose code will be broken by the change(s) introduced by the pull request. It is quite likely that any change made will break someones code, so you need to have a good reason to make a change as you will be forcing someone to update their code. (This obviously does not apply to new classes or functions; new arguments should be optional and have default values which maintain the existing behavior.) If in doubt, have a look at PEP 387ordiscuss the issue with experienced developers.

Third, make sure you have proper tests to verify your pull request works as expected. Pull requests will not be accepted without the proper tests!

Fourth, make sure the entire test suite runs without failure because of your changes. It is not sufficient to only run whichever test seems impacted by your changes, because there might be interferences unknown to you between your changes and some other part of the interpreter.

Fifth, proper documentation additions/changes should be included.

patchcheck#


patchcheck is a simple automated patch checklist that guides a developer through the common patch generation checks. To run patchcheck:


OnUNIX (including Mac OS X):

make patchcheck



OnWindows (after any successful build):

python.bat Tools\scripts\patchcheck.py




The automated patch checklist runs through:


Are there any whitespace problems in Python files? (using Tools/scripts/reindent.py)

Are there any whitespace problems in C files?

Are there any whitespace problems in the documentation? (using Tools/scripts/reindent-rst.py)

Has the documentation been updated?

Has the test suite been updated?

Has an entry under Misc/NEWS.d/next been added? (using blurb-it, or the blurb tool)

Has Misc/ACKS been updated?

Has configure been regenerated, if necessary?

Has pyconfig.h.in been regenerated, if necessary?


The automated patch check doesnt actually answer all of these questions. Aside from the whitespace checks, the tool is a memory aid for the various elements that can go into making a complete patch.

Making Good Commits#


Each feature or bugfix should be addressed by a single pull request, and for each pull request there may be several commits. In particular:


Donot fix more than one issue in the same commit (except, of course, if one code change fixes all of them).

Donot do cosmetic changes to unrelated code in the same commit as some feature/bugfix.


Commit messages should follow the following structure:

gh-42: Make the spam module more spammy (GH-NNNN)

The spam module sporadically came up short on spam. This change
raises the amount of spam in the module by making it more spammy.



The first line or sentence is meant to be a dense, to-the-point explanation of what the purpose of the commit is. The imperative form (used in the example above) is strongly preferred to a descriptive form such as the spam module is now more spammy. Use git log --oneline to see existing title lines. Furthermore, the first line should not end in a period.

If this is not enough detail for a commit, a new paragraph(s) can be added to explain in proper depth what has happened (detail should be good enough that a core developer reading the commit message understands the justification for the change).

Check the git bootcamp for further instructions on how the commit message should look like when merging a pull request.


Note

How to Write a Git Commit Message is a nice article that describes how to write a good commit message.

Licensing#


To accept your change we must have your formal approval for distributing your work under the PSF license. Therefore, you need to sign a contributor agreement which allows the Python Software Foundation to license your code for use with Python (you retain the copyright).


Note

You only have to sign this document once, it will then apply to all your further contributions to Python.


Here are the steps needed in order to sign the CLA:


Create a change and submit it as a pull request.

When cpython-cla-bot comments on your pull request that commit authors are required to sign a Contributor License Agreement, click on the button in the comment to sign it. Its enough to log in through GitHub. The process is automatic.

After signing, the comment by cpython-cla-bot will update to indicate that all commit authors signed the Contributor License Agreement.

Submitting#


Once you are satisfied with your work you will want to commit your changes to your branch. In general you can run git commit -a and that will commit everything. You can always run git status to see what changes are outstanding.

When all of your changes are committed (i.e. git status doesnt list anything), you will want to push your branch to your fork:

git push origin <branch name>



This will get your changes up to GitHub.

Now you want to create a pull request from your fork. If this is a pull request in response to a pre-existing issue on the issue tracker, please make sure to reference the issue number using gh-NNNN in the pull request title or message.

If this is a pull request for an unreported issue (assuming you already performed a search on the issue tracker for a pre-existing issue), create a new issue and reference it in the pull request. Please fill in as much relevant detail as possible to prevent reviewers from having to delay reviewing your pull request because of lack of information.

If this issue is so simple that theres no need for an issue to track any discussion of what the pull request is trying to solve (e.g. fixing a spelling mistake), then the pull request needs to have the skip issue label added to it by someone with commit access.

Your pull request may involve several commits as a result of addressing code review comments. Please keep the commit history in the pull request intact by not squashing, amending, or anything that would require a force push to GitHub. A detailed commit history allows reviewers to view the diff of one commit to another so they can easily verify whether their comments have been addressed. The commits will be squashed when the pull request is merged.

Converting an Existing Patch from b.p.o to GitHub#


When a patch exists in the issue tracker that should be converted into a GitHub pull request, please first ask the original patch author to prepare their own pull request. If the author does not respond after a week, it is acceptable for another contributor to prepare the pull request based on the existing patch. In this case, both parties should sign the CLA. When creating a pull request based on another persons patch, provide attribution to the original patch author by adding Co-authored-by: Author Name <email_address> . to the pull request description and commit message. See the GitHub article on how to properly add the co-author info.

See also Applying a Patch to Git.

Reviewing#


To begin with, please be patient! There are many more people submitting pull requests than there are people capable of reviewing your pull request. Getting your pull request reviewed requires a reviewer to have the spare time and motivation to look at your pull request (we cannot force anyone to review pull requests and no one is employed to look at pull requests). If your pull request has not received any notice from reviewers (i.e., no comment made) after one month, first ping the issue on the issue tracker to remind the nosy list that the pull request needs a review. If you dont get a response within a week after pinging the issue, then you can try emailing python-dev@python.org to ask for someone to review your pull request.

When someone does manage to find the time to look at your pull request they will most likely make comments about how it can be improved (dont worry, even core developers of Python have their pull requests sent back to them for changes). It is then expected that you update your pull request to address these comments, and the review process will thus iterate until a satisfactory solution has emerged.

How to Review a Pull Request#


One of the bottlenecks in the Python development process is the lack of code reviews. If you browse the bug tracker, you will see that numerous issues have a fix, but cannot be merged into the main source code repository, because no one has reviewed the proposed solution. Reviewing a pull request can be just as informative as providing a pull request and it will allow you to give constructive comments on another developers work. This guide provides a checklist for submitting a code review. It is a common misconception that in order to be useful, a code review has to be perfect. This is not the case at all! It is helpful to just test the pull request and/or play around with the code and leave comments in the pull request or issue tracker.


If you have not already done so, get a copy of the CPython repository by following the setup guide, build it and run the tests.

Check the bug tracker to see what steps are necessary to reproduce the issue and confirm that you can reproduce the issue in your version of the Python REPL (the interactive shell prompt), which you can launch by executing ./python inside the repository.

Checkout and apply the pull request (Please refer to the instruction Downloading Others Patches)

If the changes affect any C file, run the build again.

Launch the Python REPL (the interactive shell prompt) and check if you can reproduce the issue. Now that the pull request has been applied, the issue should be fixed (in theory, but mistakes do happen! A good review aims to catch these before the code is merged into the Python repository). You should also try to see if there are any corner cases in this or related issues that the author of the fix may have missed.

If you have time, run the entire test suite. If you are pressed for time, run the tests for the module(s) where changes were applied. However, please be aware that if you are recommending a pull request as merge-ready, you should always make sure the entire test suite passes.

Leaving a Pull Request Review on GitHub#


When you review a pull request, you should provide additional details and context of your review process.

Instead of simply approving the pull request, leave comments. For example:


If you tested the PR, report the result and the system and version tested on, such as Windows 10, Ubuntu 16.4, or Mac High Sierra.

If you request changes, try to suggest how.

Comment on what is good about the pull request, not just the bad. Doing so will make it easier for the PR author to find the good in your comments.

Dismissing Review from Another Core Developer#


A core developer can dismiss another core developers review if they confirmed that the requested changes have been made. When a core developer has assigned the PR to themselves, then it is a sign that they are actively looking after the PR, and their review should not be dismissed.

Committing/Rejecting#


Once your pull request has reached an acceptable state (and thus considered accepted), it will either be merged or rejected. If it is rejected, please do not take it personally! Your work is still appreciated regardless of whether your pull request is merged. Balancing what does and does not go into Python is tricky and we simply cannot accept everyones contributions.

But if your pull request is merged it will then go into Pythons VCS to be released with the next major release of Python. It may also be backported to older versions of Python as a bugfix if the core developer doing the merge believes it is warranted.

Crediting#


Non-trivial contributions are credited in the Misc/ACKS file (and, most often, in a contributions news entry as well). You may be asked to make these edits on the behalf of the core developer who accepts your pull request.
 



Next  

Running & Writing Tests
 


Previous  

Where to Get Help
 



Copyright © 2011-2022, Python Software Foundation  
Made with Sphinx and @pradyunsg's   Furo  
Last updated on Apr 16, 2022
 






Contents  




Lifecycle of a Pull Request

Introduction

Quick Guide

Step-by-step Guide

Resolving Merge Conflicts



Making Good PRs

patchcheck

Making Good Commits

Licensing

Submitting

Converting an Existing Patch from b.p.o to GitHub

Reviewing

How to Review a Pull Request



Leaving a Pull Request Review on GitHub

Dismissing Review from Another Core Developer

Committing/Rejecting

Crediting