A philosophy we would like to strongly encourage is

Before creating a PR, create an issue.

The purpose is to separate problem from possible solutions.

Bug fixes: If you’re only fixing a small bug, it’s fine to submit a pull request right away but we highly recommend to file an issue detailing what you’re fixing. This is helpful in case we don’t accept that specific fix but want to keep track of the issue. Please keep in mind that the project maintainers reserve the rights to accept or reject incoming PRs, so it is better to separate the issue and the code to fix it from each other. In some cases, project maintainers may request you to create a separate issue from PR before proceeding.

Refactor: For small refactors, it can be a standalone PR itself detailing what you are refactoring and why. If there are concerns, project maintainers may request you to create a #SIP for the PR before proceeding.

Feature/Large changes: If you intend to change the public API, or make any non-trivial changes to the implementation, we require you to file a new issue as #SIP (Superset Improvement Proposal). This lets us reach an agreement on your proposal before you put significant effort into it. You are welcome to submit a PR along with the SIP (sometimes necessary for demonstration), but we will not review/merge the code until the SIP is approved.

In general, small PRs are always easier to review than large PRs. The best practice is to break your work into smaller independent PRs and refer to the same issue. This will greatly reduce turnaround time.

If you wish to share your work which is not ready to merge yet, create a Draft PR. This will enable maintainers and the CI runner to prioritize mature PR’s.

Finally, never submit a PR that will put master branch in broken state. If the PR is part of multiple PRs to complete a large feature and cannot work on its own, you can create a feature branch and merge all related PRs into the feature branch before creating a PR from feature branch to master.

Protocol

Authoring

  • Fill in all sections of the PR template.
  • Title the PR with one of the following semantic prefixes (inspired by Karma):

    • feat (new feature)
    • fix (bug fix)
    • docs (changes to the documentation)
    • style (formatting, missing semi colons, etc; no application logic change)
    • refactor (refactoring code)
    • test (adding missing tests, refactoring tests; no application logic change)
    • chore (updating tasks etc; no application logic change)
    • perf (performance-related change)
    • build (build tooling, Docker configuration change)
    • ci (test runner, GitHub Actions workflow changes)
    • other (changes that don’t correspond to the above — should be rare!)
    • Examples:
      • feat: export charts as ZIP files
      • perf(api): improve API info performance
      • fix(chart-api): cached-indicator always shows value is cached
  • Add prefix [WIP] to title if not ready for review (WIP = work-in-progress). We recommend creating a PR with [WIP] first and remove it once you have passed CI test and read through your code changes at least once.

  • If you believe your PR contributes a potentially breaking change, put a ! after the semantic prefix but before the colon in the PR title, like so: feat!: Added foo functionality to bar
  • Screenshots/GIFs: Changes to user interface require before/after screenshots, or GIF for interactions
    • Recommended capture tools (Kap, LICEcap, Skitch)
    • If no screenshot is provided, the committers will mark the PR with need:screenshot label and will not review until screenshot is provided.
  • Dependencies: Be careful about adding new dependency and avoid unnecessary dependencies.
    • For Python, include it in pyproject.toml denoting any specific restrictions and in requirements.txt pinned to a specific version which ensures that the application build is deterministic.
    • For TypeScript/JavaScript, include new libraries in package.json
  • Tests: The pull request should include tests, either as doctests, unit tests, or both. Make sure to resolve all errors and test failures. See Testing for how to run tests.
  • Documentation: If the pull request adds functionality, the docs should be updated as part of the same PR.
  • CI: Reviewers will not review the code until all CI tests are passed. Sometimes there can be flaky tests. You can close and open PR to re-run CI test. Please report if the issue persists. After the CI fix has been deployed to master, please rebase your PR.
  • Code coverage: Please ensure that code coverage does not decrease.
  • Remove [WIP] when ready for review. Please note that it may be merged soon after approved so please make sure the PR is ready to merge and do not expect more time for post-approval edits.
  • If the PR was not ready for review and inactive for > 30 days, we will close it due to inactivity. The author is welcome to re-open and update.

Reviewing

  • Use constructive tone when writing reviews.
  • If there are changes required, state clearly what needs to be done before the PR can be approved.
  • If you are asked to update your pull request with some changes there’s no need to create a new one. Push your changes to the same branch.
  • The committers reserve the right to reject any PR and in some cases may request the author to file an issue.

Test Environments

| #feature | New feature request | New feature implementation | | #refine | Propose improvement such as adjusting padding or refining UI style, excluding new features, bug fixes, and refactoring. | Implementation of improvement such as adjusting padding or refining UI style, excluding new features, bug fixes, and refactoring. | | #doc | Documentation | Documentation | | #question | Troubleshooting: Installation, Running locally, Ask how to do something. Can be changed to #bug later. | N/A | | #SIP | Superset Improvement Proposal | N/A | | #ASF | Tasks related to Apache Software Foundation policy | Tasks related to Apache Software Foundation policy |

Then add other types of labels as appropriate.

  • Descriptive labels (a.k.a. dot labels): These labels that begin with . describe the details of the issue/PR, such as .ui, .js, .install, .backend, etc. Each issue/PR can have zero or more dot labels.
  • Need labels: These labels have pattern need:xxx, which describe the work required to progress, such as need:rebase, need:update, need:screenshot.
  • Risk labels: These labels have pattern risk:xxx, which describe the potential risk on adopting the work, such as risk:db-migration. The intention was to better understand the impact and create awareness for PRs that need more rigorous testing.
  • Status labels: These labels describe the status (abandoned, wontfix, cant-reproduce, etc.) Issue/PRs that are rejected or closed without completion should have one or more status labels.
  • Version labels: These have the pattern vx.x such as v0.28. Version labels on issues describe the version the bug was reported on. Version labels on PR describe the first release that will include the PR.

Committers may also update title to reflect the issue/PR content if the author-provided title is not descriptive enough.

If the PR passes CI tests and does not have any need: labels, it is ready for review, add label review and/or design-review.

If an issue/PR has been inactive for >=30 days, it will be closed. If it does not have any status label, add inactive.

When creating a PR, if you’re aiming to have it included in a specific release, please tag it with the version label. For example, to have a PR considered for inclusion in Superset 1.1 use the label v1.1.

Revert Guidelines

Reverting changes that are causing issues in the master branch is a normal and expected part of the development process. In an open source community, the ramifications of a change cannot always be fully understood. With that in mind, here are some considerations to keep in mind when considering a revert:

  • Availability of the PR author: If the original PR author or the engineer who merged the code is highly available and can provide a fix in a reasonable time frame, this would counter-indicate reverting.
  • Severity of the issue: How severe is the problem on master? Is it keeping the project from moving forward? Is there user impact? What percentage of users will experience a problem?
  • Size of the change being reverted: Reverting a single small PR is a much lower-risk proposition than reverting a massive, multi-PR change.
  • Age of the change being reverted: Reverting a recently-merged PR will be more acceptable than reverting an older PR. A bug discovered in an older PR is unlikely to be causing widespread serious issues.
  • Risk inherent in reverting: Will the reversion break critical functionality? Is the medicine more dangerous than the disease?
  • Difficulty of crafting a fix: In the case of issues with a clear solution, it may be preferable to implement and merge a fix rather than a revert.

Should you decide that reverting is desirable, it is the responsibility of the Contributor performing the revert to:

  • Contact the interested parties: The PR’s author and the engineer who merged the work should both be contacted and informed of the revert.
  • Provide concise reproduction steps: Ensure that the issue can be clearly understood and duplicated by the original author of the PR.
  • Put the revert through code review: The revert must be approved by another committer.

Design Guidelines

Capitalization guidelines

Sentence case

Use sentence-case capitalization for everything in the UI (except these **).

Sentence case is predominantly lowercase. Capitalize only the initial character of the first word, and other words that require capitalization, like:

  • Proper nouns. Objects in the product are not considered proper nouns e.g. dashboards, charts, saved queries etc. Proprietary feature names eg. SQL Lab, Preset Manager are considered proper nouns
  • Acronyms (e.g. CSS, HTML)
  • When referring to UI labels that are themselves capitalized from sentence case (e.g. page titles - Dashboards page, Charts page, Saved queries page, etc.)
  • User input that is reflected in the UI. E.g. a user-named a dashboard tab

Sentence case vs. Title case: Title case: “A Dog Takes a Walk in Paris” Sentence case: “A dog takes a walk in Paris”

Why sentence case?

  • It’s generally accepted as the quickest to read
  • It’s the easiest form to distinguish between common and proper nouns

How to refer to UI elements

When writing about a UI element, use the same capitalization as used in the UI.

For example, if an input field is labeled “Name” then you refer to this as the “Name input field”. Similarly, if a button has the label “Save” in it, then it is correct to refer to the “Save button”.

Where a product page is titled “Settings”, you refer to this in writing as follows: “Edit your personal information on the Settings page”.

Often a product page will have the same title as the objects it contains. In this case, refer to the page as it appears in the UI, and the objects as common nouns:

  • Upload a dashboard on the Dashboards page
  • Go to Dashboards
  • View dashboard
  • View all dashboards
  • Upload CSS templates on the CSS templates page
  • Queries that you save will appear on the Saved queries page
  • Create custom queries in SQL Lab then create dashboards

**Exceptions to sentence case:

  • Input labels, buttons and UI tabs are all caps
  • User input values (e.g. column names, SQL Lab tab names) should be in their original case

Programming Language Conventions

Python

Parameters in the config.py (which are accessible via the Flask app.config dictionary) are assumed to always be defined and thus should be accessed directly via,

  1. blueprints = app.config["BLUEPRINTS"]

rather than,

  1. blueprints = app.config.get("BLUEPRINTS")

or similar as the later will cause typing issues. The former is of type List[Callable] whereas the later is of type Optional[List[Callable]].

Typing / Types Hints

To ensure clarity, consistency, all readability, all new functions should use type hints and include a docstring.

Note per PEP-484 no syntax for listing explicitly raised exceptions is proposed and thus the recommendation is to put this information in a docstring, i.e.,

  1. import math
  2. from typing import Union
  3. def sqrt(x: Union[float, int]) -> Union[float, int]:
  4. """
  5. Return the square root of x.
  6. :param x: A number
  7. :returns: The square root of the given number
  8. :raises ValueError: If the number is negative
  9. """
  10. return math.sqrt(x)

TypeScript

TypeScript is fully supported and is the recommended language for writing all new frontend components. When modifying existing functions/components, migrating to TypeScript is appreciated, but not required. Examples of migrating functions/components to TypeScript can be found in #9162 and #9180.