Skip to content

Instantly share code, notes, and snippets.

@bveeramani
Last active March 11, 2022 07:36
Show Gist options
  • Save bveeramani/cc99b880ca2bbacf141a8fc9892850f4 to your computer and use it in GitHub Desktop.
Save bveeramani/cc99b880ca2bbacf141a8fc9892850f4 to your computer and use it in GitHub Desktop.
Script to comment on all open Ray pull requests.
import time
from github import Github
MESSAGE = """
## :bangbang: ACTION REQUIRED :bangbang:
We've switched our code formatter from YAPF to Black (see #21311).
To prevent issues with merging your code, here's what you'll need to do:
1. Install Black
```
pip install -I black==21.12b0
```
2. Format changed files with Black
```
curl -o format-changed.sh https://gist.githubusercontent.com/bveeramani/42ef0e9e387b755a8a735b084af976f2/raw/7631276790765d555c423b8db2b679fd957b984a/format-changed.sh
chmod +x ./format-changed.sh
./format-changed.sh
rm format-changed.sh
```
3. Commit your changes.
```
git add --all
git commit -m "Format Python code with Black"
```
4. Merge master into your branch.
```
git pull upstream master
```
5. Resolve merge conflicts (if necessary).
After running these steps, you'll have the updated `format.sh`.
"""
ACCESS_TOKEN = ...
github_client = Github(ACCESS_TOKEN)
ray_repo = github_client.get_repo("ray-project/ray")
for pull_request in ray_repo.get_pulls(state="open"):
pull_request.create_issue_comment(body=MESSAGE)
time.sleep(5) # To avoid rate limits
@simon-mo
Copy link

We've switched our code style from PEP8 to Black (see #21311)

Alternatively: ... our code formatter from Yapf to Black.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment