Skip to content

Commit

Permalink
Add support for Python 3.11 (#263)
Browse files Browse the repository at this point in the history
* Add support for Python 3.11

* Add 3.11 jobs and use 3.11 as upper bound job for Mac and Win

* Lower upper job in Win to 3.10 (no cvxpy for 3.11)

* Add reno
  • Loading branch information
woodsp-ibm authored Aug 16, 2023
1 parent 8893f5a commit 682218f
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 74 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
setup.py
requirements.txt
requirements-dev.txt
- uses: ./.github/actions/install-main-dependencies
Expand Down Expand Up @@ -115,12 +116,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, '3.10.6']
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.6'
python-version: 3.11
- os: windows-2019
python-version: 3.8
- os: windows-2019
Expand All @@ -132,12 +133,13 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
setup.py
requirements.txt
requirements-dev.txt
- name: install Windows dependencies
run: |
source "$CONDA/etc/profile.d/conda.sh"
conda create -n scsenv python=${{ matrix.python-version }}
conda create -y -n scsenv python=${{ matrix.python-version }}
conda activate scsenv
conda install -y scs lapack cvxpy -c conda-forge
if: ${{ matrix.os == 'windows-2019' }}
Expand Down Expand Up @@ -167,15 +169,6 @@ jobs:
make mypy
if: ${{ !cancelled() }}
shell: bash
- name: Run lint latest version
run: |
if [ "${{ matrix.os }}" == "windows-2019" ]; then
source "$CONDA/etc/profile.d/conda.sh"
conda activate scsenv
fi
pip install -U -r requirements-dev.txt
make lint
shell: bash
- name: Finance Unit Tests under Python ${{ matrix.python-version }}
uses: ./.github/actions/run-tests
with:
Expand Down Expand Up @@ -214,7 +207,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, '3.10']
python-version: [3.8, 3.11]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -224,6 +217,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
setup.py
requirements.txt
requirements-dev.txt
- uses: ./.github/actions/install-main-dependencies
Expand Down Expand Up @@ -312,16 +306,20 @@ jobs:
path: /tmp/f39
- uses: actions/download-artifact@v3
with:
name: ubuntu-latest-3.10.6
name: ubuntu-latest-3.10
path: /tmp/f310
- uses: actions/download-artifact@v3
with:
name: ubuntu-latest-3.11
path: /tmp/f311
- 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.6
path: /tmp/m310
name: macos-latest-3.11
path: /tmp/m311
- uses: actions/download-artifact@v3
with:
name: windows-2019-3.8
Expand All @@ -335,7 +333,7 @@ jobs:
shell: bash
- name: Combined Deprecation Messages
run: |
sort -f -u /tmp/f37/fin.dep /tmp/f38/fin.dep /tmp/f39/fin.dep /tmp/f310/fin.dep /tmp/m38/fin.dep /tmp/m310/fin.dep /tmp/w38/fin.dep /tmp/w310/fin.dep || true
sort -f -u /tmp/f37/fin.dep /tmp/f38/fin.dep /tmp/f39/fin.dep /tmp/f310/fin.dep /tmp/f311/fin.dep /tmp/m38/fin.dep /tmp/m311/fin.dep /tmp/w38/fin.dep /tmp/w310/fin.dep || true
shell: bash
- name: Coverage combine
run: coverage3 combine /tmp/f37/fin.dat
Expand Down
50 changes: 2 additions & 48 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 Expand Up @@ -424,4 +378,4 @@ analyse-fallback-blocks=no

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
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
Expand Up @@ -4,4 +4,4 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 100
target-version = ['py37', 'py38', 'py39', 'py310']
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
4 changes: 4 additions & 0 deletions releasenotes/notes/py-3_11-fix-10b7c08bb56c89a8.yaml
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
@@ -1,7 +1,7 @@
coverage>=4.4.0
matplotlib>=2.1
black[jupyter]~=22.0
pylint>=2.8.3,<2.14.0
pylint>=2.16.2
pylatexenc>=1.4
stestr>=2.0.0
ddt>=1.2.0,!=1.4.0
Expand All @@ -12,7 +12,7 @@ sphinxcontrib-spelling
jupyter-sphinx
discover
qiskit-aer
mypy>=0.780
mypy>=0.981
mypy-extensions>=0.4.3
nbsphinx
qiskit_sphinx_theme~=1.12.0
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
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 finance',
Expand Down
7 changes: 4 additions & 3 deletions tools/check_copyright.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020, 2022.
# (C) Copyright IBM 2020, 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 All @@ -13,6 +13,7 @@
""" Fix copyright year in header """

from typing import Tuple, Union, List
import builtins
import sys
import os
import datetime
Expand Down Expand Up @@ -75,7 +76,7 @@ def _cmd_execute(self, args: List[str]) -> Tuple[str, Union[None, str]]:
def _get_changed_files(self) -> List[str]:
out_str, err_str = self._cmd_execute(["git", "diff", "--name-only", "HEAD"])
if err_str:
raise Exception(err_str)
raise builtins.Exception(err_str)

return out_str.splitlines()

Expand All @@ -89,7 +90,7 @@ def _get_file_last_year(self, relative_path: str) -> int:
last_year = CopyrightChecker._get_year_from_date(out_str)
if err_str:
errors.append(err_str)
except Exception as ex: # pylint: disable=broad-except
except builtins.Exception as ex: # pylint: disable=broad-except
errors.append(f"'{relative_path}' Last year: {str(ex)}")

if errors:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 3.3.0
envlist = py37, py38, py39, py310, lint
envlist = py37, py38, py39, py310, py311, lint
skipsdist = True

[testenv]
Expand Down

0 comments on commit 682218f

Please sign in to comment.