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

Add support for Python 3.11 #512

Merged
merged 16 commits into from
May 4, 2023
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
43 changes: 21 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
# (C) Copyright IBM 2021, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -63,22 +63,22 @@ jobs:
- uses: ./.github/actions/install-machine-learning
- name: Install Dependencies
run: |
pip install jupyter qiskit-terra[visualization] 'torchvision<0.10.0'
pip install torchvision
sudo apt-get -y install pandoc graphviz
sudo apt-get -y install python3-enchant
sudo apt-get -y install hunspell-en-us
pip install pyenchant
echo "earliest_version: 0.1.0" >> releasenotes/config.yaml
shell: bash
- run: pip check
- run: pip check
if: ${{ !cancelled() }}
shell: bash
- name: Copyright Check
run: |
python tools/check_copyright.py -check
if: ${{ !cancelled() }}
shell: bash
- run: make spell
- run: make spell
if: ${{ !cancelled() }}
shell: bash
- name: Style Check
Expand All @@ -88,7 +88,7 @@ jobs:
if: ${{ !cancelled() }}
shell: bash
- name: Run make html
run: |
run: |
make clean_sphinx
make html
cd docs/_build/html
Expand All @@ -102,7 +102,7 @@ jobs:
name: documentation
path: docs/_build/html/artifacts/documentation.tar.gz
if: ${{ !cancelled() }}
- run: make doctest
- run: make doctest
if: ${{ !cancelled() }}
shell: bash
MachineLearning:
Expand All @@ -111,16 +111,16 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
include:
- os: macos-latest
python-version: 3.8
- os: macos-latest
python-version: '3.10'
python-version: 3.11
- os: windows-2019
python-version: 3.8
- os: windows-2019
python-version: '3.10'
python-version: 3.11
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -140,12 +140,7 @@ jobs:
- run: make lint
shell: bash
- run: make mypy
if: ${{ !cancelled() && matrix.python-version != '3.10' }}
shell: bash
- name: Run make lint latest version
run: |
pip install -U -r requirements-dev.txt
make lint
if: ${{ !cancelled() && matrix.python-version != '3.10' && matrix.python-version != 3.11 }}
shell: bash
- name: Machine Learning Unit Tests under Python ${{ matrix.python-version }}
uses: ./.github/actions/run-tests
Expand Down Expand Up @@ -186,7 +181,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8]
python-version: [3.8, 3.11]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -207,7 +202,7 @@ jobs:
- uses: ./.github/actions/install-machine-learning
- name: Install Dependencies
run: |
pip install jupyter qiskit-terra[visualization] 'torchvision<0.10.0'
pip install torchvision
sudo apt-get install -y pandoc graphviz
shell: bash
- name: Run Machine Learning Tutorials
Expand Down Expand Up @@ -283,28 +278,32 @@ jobs:
with:
name: ubuntu-latest-3.10
path: /tmp/u310
- uses: actions/download-artifact@v3
with:
name: ubuntu-latest-3.11
path: /tmp/u311
- uses: actions/download-artifact@v3
with:
name: macos-latest-3.8
path: /tmp/m38
- uses: actions/download-artifact@v3
with:
name: macos-latest-3.10
path: /tmp/m310
name: macos-latest-3.11
path: /tmp/m311
- uses: actions/download-artifact@v3
with:
name: windows-2019-3.8
path: /tmp/w38
- uses: actions/download-artifact@v3
with:
name: windows-2019-3.10
path: /tmp/w310
name: windows-2019-3.11
path: /tmp/w311
- name: Install Dependencies
run: pip install -U coverage coveralls diff-cover
shell: bash
- name: Combined Deprecation Messages
run: |
sort -f -u /tmp/u37/ml.dep /tmp/u38/ml.dep /tmp/u39/ml.dep /tmp/u310/ml.dep /tmp/m38/ml.dep /tmp/m310/ml.dep /tmp/w38/ml.dep /tmp/w310/ml.dep || true
sort -f -u /tmp/u37/ml.dep /tmp/u38/ml.dep /tmp/u39/ml.dep /tmp/u310/ml.dep /tmp/u311/ml.dep /tmp/m38/ml.dep /tmp/m311/ml.dep /tmp/w38/ml.dep /tmp/w311/ml.dep || true
shell: bash
- name: Coverage combine
run: coverage3 combine /tmp/u37/ml.dat
Expand Down
48 changes: 1 addition & 47 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=no-self-use, # disabled as it is too verbose
fixme, # disabled as TODOs would show up as warnings
disable=fixme, # disabled as TODOs would show up as warnings
protected-access, # disabled as we don't follow the public vs private
# convention strictly
duplicate-code, # disabled as it is too verbose
Expand All @@ -72,9 +71,6 @@ disable=no-self-use, # disabled as it is too verbose
no-else-return, # relax "elif" after a clause with a return
docstring-first-line-empty, # relax docstring style
import-outside-toplevel,
bad-continuation, bad-whitespace, # differences of opinion with black




[REPORTS]
Expand All @@ -84,12 +80,6 @@ disable=no-self-use, # disabled as it is too verbose
# mypackage.mymodule.MyReporterClass.
output-format=text

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]". This option is deprecated
# and it will be removed in Pylint 2.0.
files-output=no

# Tells whether to display a full report or only the messages
reports=yes

Expand Down Expand Up @@ -138,63 +128,33 @@ property-classes=abc.abstractproperty
# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Regular expression matching correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$

# Naming hint for class names
class-name-hint=[A-Z_][a-zA-Z0-9]+$

# Regular expression matching correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for function names
function-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct method names
method-rgx=(([a-z_][a-z0-9_]{2,49})|(assert[A-Z][a-zA-Z0-9]{2,43})|(test_[_a-zA-Z0-9]{2,}))$

# Naming hint for method names
method-name-hint=[a-z_][a-z0-9_]{2,30}$ or camelCase `assert*` in tests.

# Regular expression matching correct attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for attribute names
attr-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,30}|ax|dt$

# Naming hint for argument names
argument-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct variable names
variable-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for variable names
variable-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$

# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$

# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
Expand Down Expand Up @@ -222,12 +182,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# else.
single-line-if-stmt=no

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator

# Maximum number of lines in a module
max-module-lines=1000

Expand Down
2 changes: 0 additions & 2 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
astroid==2.5.6
pylint==2.8.3
numpy>=1.20.0
ipython<8.13;python_version<'3.9'
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.black]
line-length = 100
target-version = ['py37', 'py38', 'py39', 'py310']
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Compatibility fix to support Python 3.11.
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ coverage>=4.4.0
matplotlib>=2.1
seaborn
black[jupyter]~=22.0
pylint>=2.8.3,<2.14.0
pylint>=2.15.0
pylatexenc>=1.4
stestr>=2.0.0
ddt>=1.2.0,!=1.4.0
Expand All @@ -13,7 +13,7 @@ sphinx-gallery
sphinxcontrib-spelling
jupyter-sphinx
discover
qiskit-aer>=0.11
qiskit-aer>=0.11.2
mypy>=0.981
mypy-extensions>=0.4.3
nbsphinx
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
qiskit-terra>=0.22
qiskit-terra>=0.22.2
scipy>=1.4
numpy>=1.17
psutil>=5
scikit-learn>=0.20.0
fastdtw
setuptools>=40.1.0
dill>=0.3.4,<0.3.6
dill>=0.3.4
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
# (C) Copyright IBM 2021, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -61,6 +61,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering"
],
keywords='qiskit sdk quantum machine learning ml',
Expand All @@ -69,7 +70,7 @@
include_package_data=True,
python_requires=">=3.7",
extras_require={
'torch': ["torch; python_version < '3.10'"],
'torch': ["torch"],
'sparse': ["sparse"],
},
zip_safe=False
Expand Down
19 changes: 10 additions & 9 deletions test/connectors/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""Test Torch Base."""

import unittest
import builtins
import warnings
from abc import ABC, abstractmethod
from qiskit.utils import QuantumInstance, algorithm_globals, optionals
Expand Down Expand Up @@ -62,44 +63,44 @@ def tear_down(self):
def subTest(self, msg, **kwargs):
# pylint: disable=invalid-name
"""Sub test."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertAlmostEqual(self, first, second, places=None, msg=None, delta=None):
"""Assert almost equal."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertEqual(self, first, second, msg=None):
"""Assert equal."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertTrue(self, expr, msg=None):
"""Assert true."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertFalse(self, expr, msg=None):
"""assert False"""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def skipTest(self, reason): # pylint: disable=invalid-name
"""Skip test."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertLogs(self, logger=None, level=None):
"""Assert logs."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertListEqual(self, list1, list2, msg=None):
"""Assert list equal."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")

@abstractmethod
def assertRaises(self, expected_exception):
"""Assert raises an exception."""
raise Exception("Abstract method")
raise builtins.Exception("Abstract method")
Loading