Skip to content

Commit ee0346a

Browse files
committed
Merge upstream/main and regenerate lockfiles with tensorflow-docs
2 parents 6c3d22a + 5a5e67a commit ee0346a

47 files changed

Lines changed: 333 additions & 306 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ jobs:
223223
- name: Run pytest
224224
run: |
225225
echo '::add-matcher::.github/problem-matchers/pytest.json'
226-
check/pytest -m "not slow"
226+
check/pytest -n auto -m "not slow"
227227
228228
pytest-extra:
229229
if: needs.changes.outputs.python == 'true'
@@ -258,7 +258,7 @@ jobs:
258258
- name: Run pytest
259259
run: |
260260
echo '::add-matcher::.github/problem-matchers/pytest.json'
261-
check/pytest -m "not slow" src/openfermion/resource_estimates
261+
check/pytest -n auto -m "not slow" src/openfermion/resource_estimates
262262
263263
pytest-compat:
264264
if: needs.changes.outputs.python == 'true'
@@ -287,7 +287,7 @@ jobs:
287287
- name: Run pytest
288288
run: |
289289
echo '::add-matcher::.github/problem-matchers/pytest.json'
290-
check/pytest -m "not slow"
290+
check/pytest -n auto -m "not slow"
291291
292292
coverage:
293293
if: needs.changes.outputs.python == 'true'

.github/workflows/scorecard-scanner.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070

7171
- name: Upload results to code-scanning dashboard
7272
# yamllint disable rule:line-length
73-
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
73+
uses: github/codeql-action/upload-sarif@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
7474
with:
7575
sarif_file: scorecard-results.sarif
7676

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
[MAIN]
2121

22-
# Analyse import fallback blocks. This can be used to support both Python 2 and
23-
# 3 compatible code, which means that the block might have code that exists
24-
# only in one or another interpreter, leading to false positives when analysed.
22+
# Analyse import fallback blocks.
2523
analyse-fallback-blocks=no
2624

2725
# Clear in-memory caches upon conclusion of linting. Useful if running pylint
@@ -1027,4 +1025,4 @@ init-import=yes
10271025

10281026
# List of qualified module names which can have objects that can redefine
10291027
# builtins.
1030-
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
1028+
redefining-builtins-modules=builtins,io

CONTRIBUTING.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ This project follows Google coding conventions, with a few changes that are most
7474
configuration files at the top level of the source tree and in `dev_tools/conf/`. The following
7575
files configure various tools to the project conventions:
7676

77-
* `dev_tools/conf/.pylintrc`: Python code
78-
7977
* `.editorconfig`: basic code editor configuration
8078

8179
* `.hadolint.yaml`: Dockerfiles
@@ -84,6 +82,10 @@ files configure various tools to the project conventions:
8482

8583
* `.markdownlintrc`: Markdown files
8684

85+
* `.pylintrc`: Python file lint
86+
87+
* `.pyproject.toml`: Python tools other than Pylint
88+
8789
* `.yamllint.yaml`: YAML files
8890

8991
#### Code comment conventions
@@ -210,16 +212,6 @@ pre-commit run --all-files
210212

211213
After that, the hooks will run automatically when triggered by the corresponding git operations.
212214

213-
### Type annotation conventions
214-
215-
Code should have [type annotations](https://www.python.org/dev/peps/pep-0484/). We use
216-
[mypy](http://mypy-lang.org/) to check that type annotations are correct, and the following script
217-
to run it:
218-
219-
```shell
220-
check/mypy
221-
```
222-
223215
### Python setup
224216

225217
1. Create a Python virtual environment. To use Python's built-in `venv` package, run:
@@ -239,6 +231,20 @@ check/mypy
239231
Please refer to the section _Developer install_ of the [installation instructions](docs/install.md)
240232
for information about how to set up a local copy of the software for development.
241233
234+
### Type annotation conventions
235+
236+
Code should have [type annotations](https://www.python.org/dev/peps/pep-0484/). We use
237+
[mypy](http://mypy-lang.org/) to check that type annotations are correct, and the following script
238+
to run it:
239+
240+
```shell
241+
check/mypy
242+
```
243+
244+
If your computer has multiple processor cores, you can add the option `-j 0` to the command above to
245+
make Mypy run in parallel for a substantial speed increase.
246+
247+
242248
### Linting and formatting
243249
244250
Code should meet common style standards for Python and be free of error-prone constructs. We use
@@ -280,9 +286,11 @@ We use [pytest](https://docs.pytest.org) to run our tests and
280286
[pytest-cov](https://pytest-cov.readthedocs.io) to compute coverage.
281287
282288
* While developing, periodically check that changes do not break anything. For fast checks, use
283-
`pytest -c dev_tools/conf/pytest.ini PATH`, where `PATH` is a directory or pytest file to test.
289+
`pytest -m "not slow" PATH`, where `PATH` is a directory or pytest file to test.
284290
285-
* After finishing a task, run `check/pytest` to test all of the OpenFermion code.
291+
* After finishing a task, run `check/pytest` to test all of the OpenFermion code. If your system
292+
has multiple processor cores, you can add the option `-n auto` to make it run in parallel for a
293+
substantial speed increase. (Beware, though, that this is resource-intensive.)
286294
287295
We don't require 100% coverage, but coverage should be very high, and any uncovered code must be
288296
annotated with `# pragma: no cover`. To ignore coverage of a single line, place `# pragma: no cover`
@@ -294,9 +302,9 @@ cover` comment on its own line. Note, however, that these annotations should be
294302
After a task is finished, run each of the following to make sure everything passes all the tests:
295303

296304
* `check/format-incremental`
297-
* `check/pylint`
305+
* `check/pylint -j 0`
298306
* `check/mypy`
299-
* `check/pytest`
307+
* `check/pytest -n auto`
300308
* `check/pytest-and-incremental-coverage`
301309

302310
### Pull requests and code reviews

check/pylint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
################################################################################
17-
# Runs pylint on the repository using a preconfigured .pylintrc file.
17+
# Runs pylint from the top level of the project.
1818
#
1919
# Usage:
2020
# check/pylint [--flags]
@@ -24,4 +24,4 @@
2424
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" || exit 1
2525
cd "$(git rev-parse --show-toplevel)" || exit 1
2626

27-
pylint --rcfile=dev_tools/conf/.pylintrc "$@" src dev_tools
27+
pylint "$@" src dev_tools

check/pylint-changed-files

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# Summary: run pylint on changed files using a preconfigured .pylintrc file.
17+
# Summary: run pylint on changed files from the top level of the project.
1818
#
1919
# Usage:
2020
# check/pylint-changed-files [BASE_REVISION]
@@ -81,4 +81,4 @@ echo "Found ${num_changed} lintable files associated with changes." >&2
8181
if [ "${num_changed}" -eq 0 ]; then
8282
exit 0
8383
fi
84-
env PYTHONPATH=dev_tools pylint --jobs=0 --rcfile=dev_tools/conf/.pylintrc "${changed[@]}"
84+
env PYTHONPATH=dev_tools pylint --jobs=0 "${changed[@]}"

check/pytest

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ for arg in "$@"; do
4343
done
4444

4545
if [ -z "${ACTUALLY_QUIET}" ]; then
46-
pytest -c dev_tools/conf/pytest.ini --rootdir="$rootdir" "${PYTEST_ARGS[@]}"
46+
pytest --rootdir="$rootdir" "${PYTEST_ARGS[@]}"
4747
else
4848
# Filter out lines like "...F....x... [ 42%]", with coloring.
49-
pytest -c dev_tools/conf/pytest.ini \
50-
--rootdir="$rootdir" -q --color=yes "${PYTEST_ARGS[@]}" | \
49+
pytest --rootdir="$rootdir" -q --color=yes "${PYTEST_ARGS[@]}" | \
5150
grep -Ev '^(\x1B\[0m)?[\.FEsx]+(\x1B\[36m)?[[:space:]]+\[[[:space:]]*[0-9]+%\](\x1B\[0m)?$'
5251
exit "${PIPESTATUS[0]}"
5352
fi

check/pytest-and-incremental-coverage

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fi
6868

6969
# Run tests while producing coverage files.
7070
check/pytest . \
71+
-n auto \
7172
--actually-quiet \
7273
--cov \
7374
--cov-report=annotate

dev_tools/conf/pytest.ini

Lines changed: 0 additions & 20 deletions
This file was deleted.

dev_tools/requirements/deps/pytest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pytest
22
pytest-asyncio
33
pytest-cov
4+
pytest-randomly
45
pytest-retry
56
pytest-xdist
67

0 commit comments

Comments
 (0)