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

ci: update pre-commit and fix ci #39

Merged
merged 4 commits into from
Nov 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
17 changes: 11 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ ilpy/wrapper.cpp

build
dist
.vscode
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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/"
6 changes: 4 additions & 2 deletions ilpy/expressions.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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: ">",
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/
Expand Down Expand Up @@ -48,6 +48,7 @@ target-version = "py38"
src = ["ilpy"]
select = [
"F", # pyflakes
"W", # pyflakes
"E", # pycodestyle
"I", # isort
"UP", # pyupgrade
Expand Down
Loading