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

NEP-29 - enforce minimum Python version 3.10 #6591

Merged
merged 5 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cirq-aqt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires=('>=3.9.0'),
python_requires=('>=3.10.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
8 changes: 4 additions & 4 deletions cirq-core/cirq/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# limitations under the License.

"""Define version number here, read it from setup.py automatically,
and warn users that the latest version of cirq uses python 3.9+"""
and warn users that the latest version of cirq uses python 3.10+"""

import sys

if sys.version_info < (3, 9, 0): # pragma: no cover
if sys.version_info < (3, 10, 0): # pragma: no cover
raise SystemError(
"You installed the latest version of cirq but aren't on python 3.9+.\n"
"You installed the latest version of cirq but aren't on python 3.10+.\n"
'To fix this error, you need to either:\n'
'\n'
'A) Update to python 3.9 or later.\n'
'A) Update to python 3.10 or later.\n'
'- OR -\n'
'B) Explicitly install an older deprecated-but-compatible version '
'of cirq (e.g. "python -m pip install cirq==1.1.*")'
Expand Down
3 changes: 1 addition & 2 deletions cirq-core/cirq/ops/qid_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def q(*args: Union[int, str]) -> Union['cirq.LineQubit', 'cirq.GridQubit', 'cirq
>>> cirq.q("foo") == cirq.NamedQubit("foo")
True

Note that arguments should be treated as positional only, even
though this is only enforceable in python 3.8 or later.
Note that arguments should be treated as positional only.

Args:
*args: One or two ints, or a single str, as described above.
Expand Down
8 changes: 1 addition & 7 deletions cirq-core/cirq/protocols/json_serialization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import contextlib
import dataclasses
import datetime
Expand All @@ -19,7 +20,6 @@
import json
import os
import pathlib
import sys
import warnings
from typing import Dict, List, Optional, Tuple, Type
from unittest import mock
Expand Down Expand Up @@ -56,12 +56,6 @@ class _ModuleDeprecation:
}


# pyQuil 3.0, necessary for cirq_rigetti module requires
# python >= 3.9
if sys.version_info < (3, 9): # pragma: no cover
del TESTED_MODULES['cirq_rigetti']


def _get_testspecs_for_modules() -> List[ModuleJsonTestSpec]:
modules = []
for m in TESTED_MODULES.keys():
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ attrs
duet>=0.2.8
matplotlib~=3.0
networkx>=2.4
numpy~=1.16
numpy~=1.22
pandas
sortedcontainers~=2.0
scipy<1.13.0
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires=('>=3.9.0'),
python_requires=('>=3.10.0'),
install_requires=requirements,
extras_require={'contrib': contrib_requirements},
license='Apache 2',
Expand Down
2 changes: 1 addition & 1 deletion cirq-ft/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires='>=3.9.0',
python_requires='>=3.10.0',
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
8 changes: 4 additions & 4 deletions cirq-google/cirq_google/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# limitations under the License.

"""Define version number here, read it from setup.py automatically,
and warn users that the latest version of cirq uses python 3.9+"""
and warn users that the latest version of cirq uses python 3.10+"""

import sys

if sys.version_info < (3, 9, 0): # pragma: no cover
if sys.version_info < (3, 10, 0): # pragma: no cover
raise SystemError(
"You installed the latest version of cirq but aren't on python 3.9+.\n"
"You installed the latest version of cirq but aren't on python 3.10+.\n"
'To fix this error, you need to either:\n'
'\n'
'A) Update to python 3.9 or later.\n'
'A) Update to python 3.10 or later.\n'
'- OR -\n'
'B) Explicitly install an older deprecated-but-compatible version '
'of cirq (e.g. "python -m pip install cirq==1.1.*")'
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires=('>=3.9.0'),
python_requires=('>=3.10.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-ionq/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires=('>=3.9.0'),
python_requires=('>=3.10.0'),
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-pasqal/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires='>=3.9.0',
python_requires='>=3.10.0',
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-rigetti/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires='>=3.9.0',
python_requires='>=3.10.0',
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion cirq-web/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires='>=3.9.0',
python_requires='>=3.10.0',
install_requires=requirements,
license='Apache 2',
description=description,
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/modules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_modules():
'url': 'http://github.com/quantumlib/cirq',
'author': 'The Cirq Developers',
'author_email': 'cirq-dev@googlegroups.com',
'python_requires': '>=3.9.0',
'python_requires': '>=3.10.0',
'install_requires': ['req1', 'req2'],
'license': 'Apache 2',
'packages': ['pack1', 'pack1.sub'],
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/modules_test_data/mod1/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires=('>=3.9.0'),
python_requires=('>=3.10.0'),
install_requires=requirements,
license='Apache 2',
packages=pack1_packages,
Expand Down
13 changes: 6 additions & 7 deletions dev_tools/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
where pattern is the regex matching pattern (passed to re.compile) and
substitution is the replacement string.
"""

import inspect
import sys
from typing import Any, Dict, List, Optional, Pattern, Tuple, Iterator

import os
Expand Down Expand Up @@ -759,16 +759,15 @@ def test_assert_code_snippet_executes_correctly():
{},
)

if sys.version_info[0] >= 3: # Our print capture only works in python 3.
with pytest.raises(AssertionError):
assert_code_snippet_executes_correctly(
"""
with pytest.raises(AssertionError):
assert_code_snippet_executes_correctly(
"""
print("abc")
# prints
# def
""",
{},
)
{},
)

assert_code_snippet_executes_correctly(
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
url='http://github.com/quantumlib/cirq',
author='The Cirq Developers',
author_email='cirq-dev@googlegroups.com',
python_requires='>=3.9.0',
python_requires='>=3.10.0',
install_requires=requirements,
extras_require={'dev_env': dev_requirements},
license='Apache 2',
Expand Down