Skip to content

Commit

Permalink
Merge branch 'main' into fix-qasm-identifier-starts-with-keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
daxfohl authored Feb 2, 2025
2 parents f99b4e8 + 0e5db12 commit 00b08b3
Show file tree
Hide file tree
Showing 82 changed files with 2,923 additions and 1,876 deletions.
8 changes: 4 additions & 4 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ before the problem can be addressed. Instead, please use the GitHub ["Report
a Vulnerability"](https://github.com/quantumlib/cirq/security/advisories/new)
interface from the _Security_ tab of the Cirq repository.

Please security bugs in third-party modules to the person or team maintaining
the module rather than the Cirq project stewards, unless you believe that some
action needs to be taken with Cirq in order to guard against the effects of a
security vulnerability in a third-party module.
Please report security issues in third-party modules to the person or team
maintaining the module rather than the Cirq project stewards, unless you
believe that some action needs to be taken with Cirq in order to guard against
the effects of a security vulnerability in a third-party module.

## Responses to security reports

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ jobs:
architecture: 'x64'
- name: Install requirements
run: pip install -r dev_tools/requirements/dev.env.txt
- name: RST check
run: find . -type f -name "*.rst" | xargs rstcheck
- name: Doc check
run: check/doctest -q
nbformat:
Expand Down
173 changes: 152 additions & 21 deletions .markdownlintrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,152 @@
# Summary: markdownlint-cli config file for Cirq
#
# Note: there are multiple programs programs named "markdownlint". For Cirq,
# we use https://github.com/igorshubovych/markdownlint-cli/, which is the one
# you get with "brew install markdownlint" on MacOS.

# For a list of configuration options, see the following page:
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
# (Beware that the above looks similar but is NOT the same as the page
# https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md.)

# Make exception to the line-length limit of 80 chars in code blocks & tables.
[line-length]
code_blocks = false
tables = false

# Raw HTML is allowed in Markdown, and supported by GitHub.
no-inline-html = false

# Bare URLs are allowed in GitHub-flavored Markdown.
no-bare-urls = false
{ // Summary: markdownlint config file for Cirq -*- jsonc -*-
//
// Note: there are multiple programs programs named "markdownlint". For
// Cirq, we use https://github.com/igorshubovych/markdownlint-cli/, which is
// the one you get with "brew install markdownlint" on MacOS.
//
// These settings try to stay close to the Google Markdown Style as
// described at https://google.github.io/styleguide/docguide/style.html
//
// For a list of configuration options, see the following page:
// https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
// (Beware that the above looks similar but is NOT the same as the page
// https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md.)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json",

// Require ATX-style headings.
// https://google.github.io/styleguide/docguide/style.html#atx-style-headings
"headings": {
"style": "atx"
},

// Google style does not require that the first line of a file is a heading
// for the title; it only states that the first heading should be a level 1.
// https://google.github.io/styleguide/docguide/style.html#document-layout
"first-line-heading": false,

// The Google style does not define what to do about trailing punctuation in
// headings. The markdownlint default disallows exclamation points, which
// seems likely to be more annoying than useful – I have definitely seen
// people use exclamation points in headings in README files on GitHub.
// This setting removes exclamation point from the banned characters.
"no-trailing-punctuation": {
"punctuation": ".,;:。,;:"
},

// No trailing spaces.
// https://google.github.io/styleguide/docguide/style.html#trailing-whitespace
"whitespace": {
"br_spaces": 0
},

// Google style exempts some constructs from the line-length limit of 80 chars.
// https://google.github.io/styleguide/docguide/style.html#exceptions
"line-length": {
"code_blocks": false,
"headings": false,
"tables": false
},

// Google Markdown style specifies 2 spaces after item numbers, 3 spaces
// after bullets, so that the text itself is consistently indented 4 spaces.
// https://google.github.io/styleguide/docguide/style.html#nested-list-spacing
"list-marker-space": {
"ol_multi": 2,
"ol_single": 2,
"ul_multi": 3,
"ul_single": 3
},

"ul-indent": {
"indent": 4
},

// Bare URLs are allowed in GitHub-flavored Markdown and in Google’s style.
"no-bare-urls": false,

// Basic Markdown allows raw HTML. Both GitHub & PyPI support subsets of
// HTML, though it's unclear what subset PyPI supports. Google's style
// guide doesn't disallow using HTML, although it recommends against it. (C.f.
// the bottom of https://google.github.io/styleguide/docguide/style.html)
// It's worth noting, though, that Google's guidance has Google's internal
// documentation system in mind, and that system extends Markdown with
// constructs that make it possible to accomplish things you can't do in
// Markdown. Those extensions are also not available outside Google's system.
// Thus, although a goal of this markdownlint configuration is to match
// Google's style guide as closely as possible, these various factors suggest
// it's reasonable to relax the HTML limitation. The list below is based on
// https://github.com/github/markup/issues/245#issuecomment-682231577 plus
// some things found elsewhere after that was written.
"html": {
"allowed_elements": [
"a",
"abbr",
"b",
"bdo",
"blockquote",
"br",
"caption",
"cite",
"code",
"dd",
"del",
"details",
"dfn",
"div",
"dl",
"dt",
"em",
"figcaption",
"figure",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"h7",
"h8",
"hr",
"i",
"img",
"ins",
"kbd",
"li",
"mark",
"ol",
"p",
"picture",
"pre",
"q",
"rp",
"rt",
"ruby",
"s",
"samp",
"small",
"source",
"span",
"span",
"strike",
"strong",
"sub",
"summary",
"sup",
"table",
"tbody",
"td",
"tfoot",
"th",
"thead",
"time",
"tr",
"tt",
"ul",
"var",
"video",
"wbr"
]
}
}
106 changes: 61 additions & 45 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# How to Contribute

We'd love to accept your patches and contributions to this project.
We do have some guidelines to follow, covered in this document, but don't
worry about (or expect to) get everything right the first time!
Create a pull request and we'll nudge you in the right direction. Please also
note that we have a [code of conduct](CODE_OF_CONDUCT.md) to make Cirq an
open and welcoming community environment.
We'd love to accept your patches and contributions to this project. We do have
some guidelines to follow, covered in this document, but don't worry about –
or expect toget everything right the first time! Create a pull request
(discussed below) and we'll nudge you in the right direction. Please also note
that we have a [code of conduct](CODE_OF_CONDUCT.md) to make Cirq an open and
welcoming community environment.

## Contributor License Agreement

Expand All @@ -30,26 +30,32 @@ information on using pull requests.
The preferred manner for submitting pull requests is for developers to fork
the Cirq [repository](https://github.com/quantumlib/Cirq) and then use a [git
branch](https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell)
from this fork to create a pull request to the main Cirq repo. The basic process for setting
up a fork is as follows:

1. Fork the Cirq repository (you can use the _Fork_ button in upper right
corner of the [repository page](https://github.com/quantumlib/Cirq)).
Forking creates a new GitHub repo at the location
`https://github.com/USERNAME/Cirq`, where `USERNAME` is
your GitHub user name. Use the instructions on the
[development page](docs/dev/development.md) to download a copy to
your local machine. You need only do this once.
1. Check out the `main` branch and create a new branch from `main`:
from this fork to create a pull request to the main Cirq repo. The basic
process for setting up a fork is as follows:

1. Fork the Cirq repository (you can use the _Fork_ button in upper right
corner of the [repository page](https://github.com/quantumlib/Cirq)).
Forking creates a new GitHub repo at the location
`https://github.com/USERNAME/Cirq`, where `USERNAME` is
your GitHub user name. Use the instructions on the Cirq
[development page](docs/dev/development.md) to download a copy to
your local machine. You need only do this once.

1. Check out the `main` branch and create a new branch from `main`:

```shell
git checkout main -b new_branch_name
```

where `new_branch_name` is the name of your new branch.
1. Do your work and commit your changes to this branch.
1. If your local copy has drifted out of sync with the `main` branch of the
main Cirq repo, you may need to merge in the latest changes. To do this,
first update your local `main` and then merge your local `main`
into your branch:

1. Do your work and commit your changes to this branch.

1. If your local copy has drifted out of sync with the `main` branch of the
main Cirq repo, you may need to merge in the latest changes into your
branch. To do this, first update your local `main` and then merge your
local `main` into your branch:

```shell
# Track the upstream repo (if your local repo hasn't):
git remote add upstream https://github.com/quantumlib/Cirq.git
Expand All @@ -62,22 +68,26 @@ into your branch:
git checkout new_branch_name
git merge main
```

You may need to fix [merge conflicts](
https://docs.github.com/articles/about-merge-conflicts)
during one or both of these merge processes.
1. Finally, push your changes to your forked copy of the Cirq repo on GitHub:

1. Finally, push your changes to your forked copy of the Cirq repo on GitHub:

```shell
git push origin new_branch_name
```
1. Now when you navigate to the Cirq repository on GitHub
(https://github.com/quantumlib/Cirq),
you should see the option to create a new pull request from
your clone repository. Alternatively, you can create the pull request
by navigating to the "Pull requests" tab in the page, and selecting
the appropriate branches.
1. A reviewer will comment on your code and may ask for changes.
You can perform the necessary changes locally, and then push the new commit
following the same process as above.

1. Now when you navigate to the Cirq repository on GitHub
(https://github.com/quantumlib/Cirq), you should see the option to create a
new pull request from your clone repository. Alternatively, you can create
the pull request by navigating to the "Pull requests" tab near the top of
the page, and selecting the appropriate branches.

1. A reviewer will comment on your code and may ask for changes. You can
perform the necessary changes locally, and then push the new commit
following the same process as above.

## Development Environment Setup

Expand All @@ -97,28 +107,34 @@ integration checks locally.
Please be aware of the following coding standards that will be applied to any
new changes.

- **Tests**.
### Tests

Existing tests must continue to pass (or be updated) when new changes are
introduced. We use [pytest](https://docs.pytest.org) to run our
tests.
- **Coverage**.
Code should be covered by tests.
We use [pytest-cov](https://pytest-cov.readthedocs.io) to compute
coverage, and custom tooling to filter down the output to only include new or
changed code. We don't require 100% coverage, but any uncovered code must
be annotated with `# pragma: no cover`. To ignore coverage of a single line,
place `# pragma: no cover` at the end of the line. To ignore coverage for
an entire block, start the block with a `# pragma: no cover` comment on its
own line.
- **Lint**.

### Coverage

Code should be covered by tests. We use
[pytest-cov](https://pytest-cov.readthedocs.io) to compute coverage, and custom
tooling to filter down the output to only include new or changed code. We don't
require 100% coverage, but any uncovered code must be annotated with `# pragma:
no cover`. To ignore coverage of a single line, place `# pragma: no cover` at
the end of the line. To ignore coverage for an entire block, start the block
with a `# pragma: no cover` comment on its own line.
### Lint
Code should meet common style standards for Python and be free of error-prone
constructs. We use [Pylint](https://www.pylint.org/) to check for code lint.
To see which lint checks we enforce, see the
[dev_tools/conf/.pylintrc](dev_tools/conf/.pylintrc) file. When Pylint produces
a false positive, it can be silenced with annotations. For example, the
annotation `# pylint: disable=unused-import` would silence a warning about
an unused import.
- **Types**.
### Types
Code should have [type annotations](https://www.python.org/dev/peps/pep-0484/).
We use [mypy](http://mypy-lang.org/) to check that type annotations are correct.
When type checking produces a false positive, it can be silenced with
Expand All @@ -127,7 +143,7 @@ annotations such as `# type: ignore`.
## Request For Comment Process for New Major Features
For larger contributions that will benefit from design reviews, please use the Cirq
[Request for Comment](docs/dev/rfc_process.md) process.
[Request for Comment](docs/dev/rfc_process.md) (RFC) process.
## Developing notebooks
Expand Down
Loading

0 comments on commit 00b08b3

Please sign in to comment.