All.submit code for review.how to guide
First Review Process#
We understand that receiving feedback on your code can be a difficult process, but it is an important part of our development workflow. Here we have gathered some helpful tips and resources to guide you through your first review.
Read Python Style Guide#
- Before submitting your code for review, we highly recommend that you read our Python Style Guide, which outlines the major conventions and best practices for writing Python code.
- Adhering to these standards will help ensure that your code is easy to read, maintain, and understand for other members of the team.
Run Linter#
- Linter is a tool that checks (and tries to fix automatically) your code for syntax errors, style violations, and other issues.
- Run it on all the changed files to automatically catch any code issues before filing any PR or before requesting a review!
- Run Linter with
invokecommand (which is abbreviated asi) and pass all the files you need to lint in quotation marks after the--filesoption, separated by a space - The command should be run from the root of the repo you are developing in
- The file paths should be relative to the repo root
- Command example:
> i lint --files="docs/coding/all.str_to_df.how_to_guide.md linters/utils.py" - Output example:
docs/coding/all.str_to_df.how_to_guide.md: 'docs/coding/all.str_to_df.how_to_guide.md' is not referenced in README.md [check_md_reference] docs/coding/all.str_to_df.how_to_guide.md:79: 'figs/str_to_df/image1.png' does not follow the format 'figs/all.str_to_df.how_to_guide.md/XYZ' [fix_md_links] linters/utils.py:294: [R0916(too-many-boolean-expressions), get_dirs_with_missing_init] Too many boolean expressions in if statement (6/5) [pylint] i linthas options for many workflows. E.g., you can automatically lint all the files that you touched in your PR with--branch, the files in the last commit with--last-commit. You can look at all the options with:> i lint --help
- Command example:
- Fix the lints
- No need to obsessively fix all of them - just crucial and obvious ones
- Running Linter on a file also applies some formatting fixes to it automatically and stages the updated file for commit
- If Linter introduces extensive changes in a PR, causing difficulty in reading the diff, a new pull request should be created exclusively for the Linter changes, based on the branch of the original PR.
Compare Your Code to Example Code#
- To get an idea of what well-formatted and well-organized code looks like, we suggest taking a look at some examples of code that adheres to our standards.
- We try to maintain universal approaches to all the parts of the code, so when
looking at a code example, check for:
- Code style
- Docstrings and comments
- Type hints
- Dir structure
- Here are some links to example code:
- Classes, functions and scripts:
- Unit tests:
Edit Code/Text Written by AI#
- We do not mind if the AI writes the first version of the code or text for you
- We do mind if you simply copy-and-paste its output and submit if for our review as-is
- Take whatever is produced by AI as the first draft: go over it, revise it, make sure it's readable and relevant, adjust it to fit our specific conventions
Save Reviewer Time#
- Follow the instructions given in
PR workflows
Make Sure Checks Are Green#
- Before requesting review, make sure that all the checks performed by GitHub
Actions pass
- The checks and their status can be seen at the bottom of the PR page or in the "Checks" tab
- Clicking on a failed check will take you to the extended report with the full failure stacktrace
- If the Linter check fails with "The Git client is not clean", then run Linter on the files reported by the check (it will automatically update them with formatting fixes), commit and push them
- In rare cases it's okay to submit a PR for review with some of the checks
failing:
- If the tests are already broken in master
- If a genuine bug in Linter causes the check to fail or requires reverting
the automatic fixes
- Check if this bug is already tracked in an issue, and if not, open a new issue to report it
Review Your Own PR#
- Before requesting review, take a final look at the "Files changed" tab
- Make sure there are
- No changes you haven't intended
- No leftovers from debugging
- No files added by mistake (such as tmp files)
Assign Reviewers#
- Make sure to select a Reviewer in a corresponding GitHub field so he/she gets
notified
- Junior contributors should assign Team Leaders (e.g., Grisha, DanY, Samarth,
...) to review their PR
- Team Leaders will assign integrators (GP & Paul) themselves after all their comments have been addressed
- Ping the assigned Reviewer in the issue if nothing happens in 24 hours
- If you want to keep someone notified about changes in the PR but do not want
to make him/her a Reviewer, type
FYI @github_namein the comment section
Mention the Issue#
- Mention the corresponding issue in the PR description to ease navigation
- E.g., see an
example
- E.g., see an
example
Resolve Conversations#
- When you've addressed a comment from a Reviewer, press
Resolve conversationbutton so the Reviewer knows that you actually took care of it
Merge Master Into Your Branch#
- Before any PR review request do
i git_merge_masterin order to keep the code updated- Resolve conflicts if there are any
- Do not forget to push it since this action is a commit itself
- Actually, a useful practice is to merge master to your branch every time you
get back to work on it
- This way you make sure that your branch is always using relevant code and avoid huge merge conflicts
- You can also easily merge master into your branch by clicking on "Update
branch" button on the PR page

- NEVER press
Squash and mergebutton yourself- You need to merge master branch into your branch - not vice verca!
- This is a strictly Team Leaders' and Integrators' responsibility
Ask for Reviews#
- When you've addressed all the comments and need another round of review:
- Press the circling arrows sign next to the Reviewer for the ping
- Remove
PR_for_authorsand add thePR_for_reviewerslabel (see here for the description of available labels)
- Press the circling arrows sign next to the Reviewer for the ping
Do Not Use Screenshots#
- Stack traces and logs are much more convenient to use for debugging
- Screenshots are often too small to capture both input and return logs while consuming a lot of basically useless memory
- Reviewers and collaborators cannot copy from the screenshot, which means that if they want to reproduce the error, they need to manually type the code shown in the screenshot, which is very inconvenient and error-prone
- The exceptions are plots and non-code information
- Examples:
-
Bad
- Good
Input:
```python type_ = "supply" supply_curve1 = ddcrsede.get_supply_demand_discrete_curve( type_, supply_orders_df1 ) supply_curve1
Error: ```text --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In [5], line 2 1 type_ = "supply" ----> 2 supply_curve1 = ddcrsede.get_supply_demand_discrete_curve( 3 type_, supply_orders_df1 4 ) 5 supply_curve1 NameError: name 'ddcrsede' is not defined
-
Report Bugs Correctly#
- Whenever you face any errors, put as much information about the problem as
possible, e.g.,:
- What you are trying to achieve
- Command line you ran, e.g.,
> i lint -f defi/tulip/test/test_dao_cross_sol.py - Copy-paste the error and the stack trace from the cmd line, no
screenshots, e.g.,
Traceback (most recent call last): File "/venv/bin/invoke", line 8, in <module> sys.exit(program.run()) File "/venv/lib/python3.8/site-packages/invoke/program.py", line 373, in run self.parse_collection() ValueError: One and only one set-up config should be true: - The log of the run
- Maybe the same run using
-v DEBUGto get more info on the problem
- Maybe the same run using
- What the problem is
- Why the outcome is different from what you expected
- E.g. on how to report any issues
Stick to Smaller Prs#
- It's better to push frequently and ask for feedback early to avoid large refactoring
Talk Through Code and Not Github#
- PR authors should, as a rule, talk to reviewers not through GitHub but through
code
- E.g., if there is something you want to explain to the reviewers, you should not comment on your own PR, but instead add comments in the code itself, or improve the code so that it doesn't need explanation
- Everything on GitHub is lost once the PR is closed, so all knowledge needs to go inside the code or the documentation
- Of course it's ok to respond to questions on GitHub
Look at Examples of First Reviews#
- It can be helpful to review some examples of previous first reviews to get an idea of what common issues are and how to address them.
- Here are some links to a few "painful" first reviews:
Checklist#
Post this checklist in a PR and check the boxes when the PR meets the requirements
- [ ] The branch is named following the format
RelatedIssueTag_Normalized_issue_title- E.g.,
HelpersTask123_Provide_branch_name_example, if the branch is for working on the issue #123 in thehelpersrepo with the title "Provide branch name example"
- E.g.,
- [ ] Commit messages are short and informative
- Ideally, they follow the format
RelatedIssueTag: High-level commit description - E.g.,
HelpersTask123: Add example - They do not mention the name of the file that has been changed by the commit
- Ideally, they follow the format
- [ ] The title of the PR matches the name of the branch
- [ ] The starting post of the PR briefly describes the content of the PR on a high level
- [ ] The issue related to the PR is mentioned in the starting post of the PR
- [ ] The PR is not linked to any issues under the
Developmentsection - [ ] At least one reviewer is assigned under
Reviewers - [ ] The PR author is listed under
Assignees - [ ] All the checks performed by GitHub Actions pass
- If they do not and it can't be fixed, explain why in a comment
- E.g., "The fast tests failure is also present in
masterand is unrelated to this PR"
- [ ] The branch is up to date with the master branch
- [ ] There are no conflicts with the master branch
- [ ] There are no files checked in by mistake (such as tmp and log files)
- [ ] All checked in files are checked and formatted by Linter in the latest commit
- [ ] No files larger than 500 KB are checked in
- [ ] Screenshots are not used in PR posts to describe the situation or report an error (if needed, copy-and-paste is used instead)
- [ ] Label
PR_for_reviewersis present if a review is requested - [ ] Fixes addressing a review comment are applied everywhere, not just where the reviewer pointed out the issue
- [ ] After addressing review comments, all corresponding conversations are
marked as
resolved - [ ] After all review comments are resolved,
re-request reviewbutton is used to request another round of review