From deaf08b86f51fa2868dd60f1486e95d04f1c2a85 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Wed, 3 May 2023 18:10:56 -0400 Subject: [PATCH 1/4] Add support for Python 3.11 --- .pylintrc | 50 ++-------------------------------------- constraints.txt | 2 -- pyproject.toml | 2 +- requirements-dev.txt | 4 ++-- setup.py | 3 ++- tools/check_copyright.py | 7 +++--- tox.ini | 2 +- 7 files changed, 12 insertions(+), 58 deletions(-) diff --git a/.pylintrc b/.pylintrc index 286e526..a8565a6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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 @@ -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] @@ -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 @@ -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=^_ @@ -222,12 +182,6 @@ ignore-long-lines=^\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 @@ -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 diff --git a/constraints.txt b/constraints.txt index 54ee5dc..b1d2527 100644 --- a/constraints.txt +++ b/constraints.txt @@ -1,4 +1,2 @@ -astroid==2.5.6 -pylint==2.8.3 numpy>=1.20.0 ipython<8.13;python_version<'3.9' diff --git a/pyproject.toml b/pyproject.toml index 468dbfa..afa1ba6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.black] line-length = 100 -target-version = ['py37', 'py38', 'py39', 'py310'] +target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] diff --git a/requirements-dev.txt b/requirements-dev.txt index 87e4597..1e7c7bb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 @@ -13,7 +13,7 @@ sphinxcontrib-spelling jupyter-sphinx discover qiskit-aer -mypy>=0.780 +mypy>=0.981 mypy-extensions>=0.4.3 nbsphinx qiskit_sphinx_theme~=1.11.1 diff --git a/setup.py b/setup.py index 559768b..814dc65 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -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', diff --git a/tools/check_copyright.py b/tools/check_copyright.py index d3a50d3..003437e 100644 --- a/tools/check_copyright.py +++ b/tools/check_copyright.py @@ -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 @@ -13,6 +13,7 @@ """ Fix copyright year in header """ from typing import Tuple, Union, List +import builtins import sys import os import datetime @@ -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() @@ -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: diff --git a/tox.ini b/tox.ini index 15cc523..e65f7ba 100644 --- a/tox.ini +++ b/tox.ini @@ -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] From a57c3956e0f2827fa5a2575c7db712d5fb456032 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Thu, 4 May 2023 09:57:56 -0400 Subject: [PATCH 2/4] Add 3.11 jobs and use 3.11 as upper bound job for Mac and Win --- .github/workflows/main.yml | 40 ++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e744671..122e155 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -52,6 +52,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 @@ -112,16 +113,16 @@ 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 - python-version: '3.10' + python-version: 3.11 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -129,12 +130,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' }} @@ -164,15 +166,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: @@ -210,7 +203,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: @@ -220,6 +213,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 @@ -307,30 +301,34 @@ 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 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/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/w311/fin.dep || true shell: bash - name: Coverage combine run: coverage3 combine /tmp/f37/fin.dat From f587a1a4220bbc1269e47533ddcd49bfa6b4c1b5 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Thu, 4 May 2023 10:35:00 -0400 Subject: [PATCH 3/4] Lower upper job in Win to 3.10 (no cvxpy for 3.11) --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 122e155..93f93ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -122,7 +122,7 @@ jobs: - os: windows-2019 python-version: 3.8 - os: windows-2019 - python-version: 3.11 + python-version: '3.10' steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -321,14 +321,14 @@ jobs: path: /tmp/w38 - uses: actions/download-artifact@v3 with: - name: windows-2019-3.11 - path: /tmp/w311 + name: windows-2019-3.10 + path: /tmp/w310 - name: Install Dependencies run: pip install -U coverage coveralls diff-cover 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/f311/fin.dep /tmp/m38/fin.dep /tmp/m311/fin.dep /tmp/w38/fin.dep /tmp/w311/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 From 513d2612ae059f48157a18e48be04c29771f8438 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Thu, 4 May 2023 10:54:18 -0400 Subject: [PATCH 4/4] Add reno --- releasenotes/notes/py-3_11-fix-10b7c08bb56c89a8.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 releasenotes/notes/py-3_11-fix-10b7c08bb56c89a8.yaml diff --git a/releasenotes/notes/py-3_11-fix-10b7c08bb56c89a8.yaml b/releasenotes/notes/py-3_11-fix-10b7c08bb56c89a8.yaml new file mode 100644 index 0000000..4dd886b --- /dev/null +++ b/releasenotes/notes/py-3_11-fix-10b7c08bb56c89a8.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Compatibility fix to support Python 3.11.