From 1f3414335d597d4162d294cbaa5f13cf84a7aa16 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 3 Nov 2023 19:56:33 -0400 Subject: [PATCH 1/4] ci: update pre-commit and fix ci --- .github/workflows/ci.yaml | 17 +++++++---- .pre-commit-config.yaml | 8 +++--- .vscode/settings.json | 60 +++++++++++++++++++++++++++++++++++++++ ilpy/expressions.py | 6 ++-- pyproject.toml | 1 + 5 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index db5f7b2..3652df8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,19 +11,23 @@ on: - master - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run pre-commit linting run: pipx run pre-commit run --all-files check-manifest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # this test ensures that the sdist contains all necessary files # if it fails, you need to either update MANIFEST.in, # or add an explicit "ignore" rule to pyproject.toml @@ -41,11 +45,12 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11"] platform: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v2 with: python-version: ${{ matrix.python-version }} - mamba-version: "*" + miniforge-version: latest + use-mamba: true channels: conda-forge,gurobi,defaults channel-priority: true @@ -66,7 +71,7 @@ jobs: python -m pip install -U pip python -m pip install -e .[dev] env: - CYTHON_TRACE: 1 # enable coverage of cython code + CYTHON_TRACE: 1 # enable coverage of cython code - name: run tests run: pytest --color yes -v --cov ilpy --cov-report=xml @@ -83,7 +88,7 @@ jobs: name: Build sdist, Publish to PyPI on tagged versions runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb9fd0f..e4355b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,8 +4,8 @@ ci: autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate" repos: - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.261 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.4 hooks: - id: ruff args: [--fix] @@ -17,12 +17,12 @@ repos: - id: double-quote-cython-strings - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.10.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.2.0 + rev: v1.6.1 hooks: - id: mypy files: "^ilpy/" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..68e3327 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,60 @@ +{ + "files.associations": { + "sstream": "cpp", + "iosfwd": "cpp", + "bitset": "cpp", + "__bit_reference": "cpp", + "__bits": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__tuple": "cpp", + "atomic": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "exception": "cpp", + "initializer_list": "cpp", + "ios": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "variant": "cpp", + "vector": "cpp" + } +} \ No newline at end of file diff --git a/ilpy/expressions.py b/ilpy/expressions.py index 0123cf0..4fdcb77 100644 --- a/ilpy/expressions.py +++ b/ilpy/expressions.py @@ -1,7 +1,7 @@ from __future__ import annotations import ast -from typing import Any, Sequence, Union +from typing import Any, ClassVar, Sequence, Union from ilpy.wrapper import Constraint, Objective, Relation, Sense @@ -412,7 +412,9 @@ class _ExprSerializer(ast.NodeVisitor): Used above in `Expression.__str__`. """ - OP_MAP: dict[type[ast.operator] | type[ast.cmpop] | type[ast.unaryop], str] = { + OP_MAP: ClassVar[ + dict[type[ast.operator] | type[ast.cmpop] | type[ast.unaryop], str] + ] = { # ast.cmpop ast.Eq: "==", ast.Gt: ">", diff --git a/pyproject.toml b/pyproject.toml index 13e768f..a98fa66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ target-version = "py38" src = ["ilpy"] select = [ "F", # pyflakes + "W", # pyflakes "E", # pycodestyle "I", # isort "UP", # pyupgrade From 20fb033350d0fd1b887c2621540890ad68d9ae97 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 3 Nov 2023 19:57:29 -0400 Subject: [PATCH 2/4] remove vscode --- .gitignore | 1 + .vscode/settings.json | 60 ------------------------------------------- 2 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 411da3b..ba78d26 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ ilpy/wrapper.cpp build dist +.vscode \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 68e3327..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "files.associations": { - "sstream": "cpp", - "iosfwd": "cpp", - "bitset": "cpp", - "__bit_reference": "cpp", - "__bits": "cpp", - "__config": "cpp", - "__debug": "cpp", - "__errc": "cpp", - "__locale": "cpp", - "__mutex_base": "cpp", - "__node_handle": "cpp", - "__nullptr": "cpp", - "__split_buffer": "cpp", - "__string": "cpp", - "__threading_support": "cpp", - "__tree": "cpp", - "__tuple": "cpp", - "atomic": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "clocale": "cpp", - "compare": "cpp", - "concepts": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "exception": "cpp", - "initializer_list": "cpp", - "ios": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "locale": "cpp", - "map": "cpp", - "memory": "cpp", - "mutex": "cpp", - "new": "cpp", - "optional": "cpp", - "ostream": "cpp", - "ratio": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "typeinfo": "cpp", - "variant": "cpp", - "vector": "cpp" - } -} \ No newline at end of file From 7306ed0b2f3eda24519e0e71ae5d94168f2579bc Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 3 Nov 2023 19:57:46 -0400 Subject: [PATCH 3/4] newline --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ba78d26..95ae813 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ ilpy/wrapper.cpp build dist -.vscode \ No newline at end of file +.vscode From 4e1ef991f30d7bd6a2bac76179da772c01cdfb87 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 3 Nov 2023 20:01:24 -0400 Subject: [PATCH 4/4] pin cython --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a98fa66..357ce2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ # https://peps.python.org/pep-0517 [build-system] -requires = ["setuptools", "Cython"] +requires = ["setuptools", "Cython<3"] build-backend = "setuptools.build_meta" # https://peps.python.org/pep-0621/