Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Drop support for Python 3.8, update dependencies #1782

Merged
merged 48 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f156954
update tests, syrupy snapshots
MarquessV May 29, 2024
95c7009
save progress
MarquessV May 30, 2024
b0e62bc
automated replace of typing imports
MarquessV May 30, 2024
360ca18
automated replace of typing imports
MarquessV May 30, 2024
f272c2d
fix inverted conditions
MarquessV May 30, 2024
6e9e42e
ruff fixes
MarquessV May 30, 2024
aadeda7
checkpoint more lints and removal of Python 3.8 patterns.
MarquessV May 30, 2024
e8edc4a
more fixes
MarquessV May 30, 2024
2bcd05c
less than 100 to go
MarquessV May 30, 2024
2a54cb8
finally, the rest of the lints
MarquessV May 30, 2024
3f43ad6
replace recommonmark with myst-parser
MarquessV May 31, 2024
cadcd18
replace black with ruff
MarquessV May 31, 2024
6d777c3
update CONTRIBUTING
MarquessV May 31, 2024
be51189
fix typing issue
MarquessV May 31, 2024
f41f27b
remove nest-asyncio
MarquessV May 31, 2024
0b42d97
doc fixes
MarquessV May 31, 2024
21e7083
remove flake8 from lockfile
MarquessV May 31, 2024
6bab44d
update CI to use 3.9
MarquessV May 31, 2024
8194817
another mypy issue
MarquessV May 31, 2024
5817fe1
ruff format
MarquessV May 31, 2024
ff11779
update dockerfiles
MarquessV May 31, 2024
d56f6bc
fix typos in CONTRIBUTING.md
MarquessV May 31, 2024
23ccd60
Add values to error message
MarquessV May 31, 2024
020a293
add more info to error message
MarquessV May 31, 2024
65c2c9e
Update pyquil/latex/_diagram.py
MarquessV May 31, 2024
b0aad91
Update pyquil/wavefunction.py
MarquessV May 31, 2024
03dd6e5
Update pyquil/latex/_diagram.py
MarquessV May 31, 2024
ddaa6a0
better error handling for apidoc
MarquessV May 31, 2024
18c05d5
fix more mypy stuff
MarquessV May 31, 2024
ded1730
remove unsed type: ignore
MarquessV May 31, 2024
c42e197
fix doc conflicts
MarquessV May 31, 2024
efc6c3d
nevermind, that breaks links
MarquessV May 31, 2024
f30ab79
deprecated is not only a dev dep
MarquessV May 31, 2024
380e16c
fix min version check
MarquessV May 31, 2024
604a135
clarify error message
MarquessV May 31, 2024
8292742
that is a change for another day
MarquessV May 31, 2024
e07f181
add more info to error
MarquessV May 31, 2024
561b015
add security check to CI
MarquessV Jun 3, 2024
5d88996
specify container
MarquessV Jun 3, 2024
47fba33
osv-scanner is installed via go
MarquessV Jun 3, 2024
50983ad
fixes
MarquessV Jun 3, 2024
e531035
fix path?
MarquessV Jun 3, 2024
bebdf2e
checkout repo
MarquessV Jun 3, 2024
d4f26b1
update pkgs w/ vulnerabilities
MarquessV Jun 3, 2024
1dfe82e
relax python version constraint
MarquessV Jun 3, 2024
880f061
python < 3.14
MarquessV Jun 5, 2024
6b59167
add 3.13 to tested versions
MarquessV Jun 5, 2024
d21a837
have to specify beta version
MarquessV Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -33,10 +33,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -52,10 +52,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -71,10 +71,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -85,12 +85,27 @@ jobs:
. scripts/ci_install_deps
poetry run make check-types

check-dependencies:

name: Check dependencies for vulnerabilities
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v5
- name: Install OSV scanner
run: |
go install github.com/google/osv-scanner/cmd/osv-scanner@latest
- name: Run OSV scanner
run: |
osv-scanner --lockfile=./poetry.lock

test-doctest:
name: Run Doctests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-beta.1"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -118,7 +133,7 @@ jobs:
pull-requests: write # allows coverage bot to comment
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-beta.1"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -147,19 +162,19 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

check-docker-image:
name: Check types
name: Check docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
key: poetry-${{ hashFiles('poetry.lock') }}
- name: Check types
- name: Check wheel installation
run: |
sudo apt update
pip wheel . -w wheels
Expand All @@ -179,7 +194,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-beta.1"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
20 changes: 8 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,14 @@ poetry install

### Style Guidelines

We use [Black](https://black.readthedocs.io/en/stable/index.html) and `flake8` to automatically
lint the code and enforce style requirements as part of the CI pipeline. You can run these style
tests yourself locally by running `make check-style` (to check for violations of the `flake8` rules)
and `make check-format` (to see if `black` would reformat the code) in the top-level directory of
the repository. If you aren't presented with any errors, then that means your code is good enough
for the linter (`flake8`) and formatter (`black`). If `make check-format` fails, it will present
you with a diff, which you can resolve by running `make format`. Black is very opinionated, but
saves a lot of time by removing the need for style nitpicks in PR review. We only deviate from its
default behavior in one category: we choose to use a line length of 100 rather than the Black
default of 88 (this is configured in the [`pyproject.toml`](pyproject.toml) file). As for `flake8`,
we ignore a couple of its rules (all for good reasons), and the specific configuration can be
found in the [`.flake8`](.flake8) file.
We use [ruff](https://docs.astral.sh/ruff/) to enforce lint and formatting requirements as part of CI. You can run these
tests yourself locally by running `make check-style` (to check for violations of the linting rules)
and `make check-format` (to see if `ruff` would reformat the code) in the top-level directory of
the repository. If you aren't presented with any errors, then that means your code satisfies all
the linting and formatting requirements. If `make check-format` fails, it will present you with a
diff, which you can resolve by running `make format`. The ruff formatter is opinionated, but
saves a lot of time by removing the need for style nitpicks in PR review. The configuration for
`ruff` can be found in `pyproject.toml`.

In addition to linting and formatting, we use type hints for all parameters and return values,
following the [PEP 484 syntax][pep-484]. This is enforced as part of the CI via the command
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use multi-stage builds to independently pull dependency versions
ARG quilc_version=1.20.0
ARG qvm_version=1.17.1
ARG python_version=3.8
ARG python_version=3.9

# use multi-stage builds to independently pull dependency versions
FROM rigetti/quilc:$quilc_version as quilc
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use multi-stage builds to independently pull dependency versions
ARG quilc_version=1.20.0
ARG qvm_version=1.17.1
ARG python_version=3.8
ARG python_version=3.9

# use multi-stage builds to independently pull dependency versions
FROM rigetti/quilc:$quilc_version as quilc
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ check-all: check-format check-types check-style

.PHONY: check-format
check-format:
black --check --diff pyquil
ruff format --check --diff pyquil

.PHONY: check-types
check-types:
mypy pyquil

.PHONY: check-style
check-style:
flake8 pyquil
ruff check pyquil

.PHONY: clean
clean:
Expand Down Expand Up @@ -55,7 +55,7 @@ docker: Dockerfile

.PHONY: format
format:
black $(if $(format_file), $(format_file), pyquil)
ruff format $(if $(format_file), $(format_file), pyquil)

.PHONY: info
info:
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS = -W # treat warnings as errors
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
Expand Down
24 changes: 17 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
import subprocess

import sphinx_rtd_theme
from sphinx.ext.doctest import doctest
from pyquil import __version__

import subprocess
import os
from pyquil import __version__

project = "pyQuil"
copyright = "2021, Rigetti Computing"
Expand All @@ -37,7 +38,7 @@
"sphinx.ext.viewcode",
"sphinxcontrib.jquery",
"nbsphinx",
"recommonmark",
"myst_parser",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommonmark is no longer maintained, myst_parser is the recommended alternative.

]

templates_path = ["_templates"]
Expand Down Expand Up @@ -119,7 +120,6 @@

dirname = os.path.dirname(__file__)


def builder_inited_handler(app):
import pandoc

Expand All @@ -129,16 +129,26 @@ def builder_inited_handler(app):
input = pandoc.read(source=None, file=infile, format="markdown")
pandoc.write(input, file=outfile, format="rst")

subprocess.call(
result = subprocess.run(
[
"sphinx-apidoc",
"--module-first",
"--force",
"--append-syspath",
"--separate",
f"--output-dir={dirname}/apidocs",
f"{dirname}/../../pyquil",
]
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
if result.returncode == 0:
print("sphinx-apidoc ran successfully.")
else:
print(f"sphinx-apidoc failed with return code {result.returncode}.")
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)


def setup(app):
Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If you would like to stay up to date with the latest changes and bug fixes, you

.. note::

pyQuil requires Python 3.8 or later.
pyQuil requires Python 3.9 or later.

.. testcode:: verify-min-version
:hide:
Expand All @@ -58,7 +58,7 @@ If you would like to stay up to date with the latest changes and bug fixes, you
.. testoutput:: verify-min-version
:hide:

^3.8...
^3.9...

.. note::

Expand Down
5 changes: 0 additions & 5 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,3 @@ ignore_errors = True
# Ignore errors in the conftest.py file
[mypy-conftest]
ignore_errors = True

# Ignore errors in the pyquil/parser.py file
# TODO(notmgsk): Add types
[mypy-pyquil.parser]
ignore_errors = True
Loading
Loading