Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 140bea8

Browse files
authored
Update pre-commit versions and run separate CI job for linting checks (#41)
1 parent 6eaab4c commit 140bea8

File tree

6 files changed

+59
-28
lines changed

6 files changed

+59
-28
lines changed

‎.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Lint via pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
pre-commit:
14+
name: pre-commit-hooks
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.10"
21+
- uses: pre-commit/action@v3.0.0

‎.github/workflows/test.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
run:
1313
shell: bash -l {0}
1414
strategy:
15-
fail-fast: false
15+
fail-fast: true
1616
matrix:
1717
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
1818
python-version: ["3.8", "3.9", "3.10"]
@@ -30,21 +30,16 @@ jobs:
3030
activate-environment: testing
3131
- name: Install dependencies
3232
run: |
33-
conda install -c conda-forge python-graphblas scipy pandas \
34-
pytest-cov pytest-randomly black flake8-comprehensions flake8-bugbear
33+
conda install -c conda-forge python-graphblas scipy pandas pytest-cov pytest-randomly
3534
# matplotlib lxml pygraphviz pydot sympy # Extra networkx deps we don't need yet
3635
pip install git+https://github.com/networkx/networkx.git@main --no-deps
3736
pip install -e . --no-deps
38-
- name: Style checks
39-
run: |
40-
flake8
41-
black . --check --diff
4237
- name: PyTest
4338
run: |
4439
python -c 'import sys, graphblas_algorithms; assert "networkx" not in sys.modules'
45-
coverage run --branch -m pytest -v --check-structure
40+
coverage run --branch -m pytest --color=yes -v --check-structure
4641
coverage report
47-
NETWORKX_GRAPH_CONVERT=graphblas pytest --pyargs networkx --cov --cov-append
42+
NETWORKX_GRAPH_CONVERT=graphblas pytest --color=yes --pyargs networkx --cov --cov-append
4843
coverage report
4944
coverage xml
5045
- name: Coverage

‎.pre-commit-config.yaml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
# To update: `pre-commit autoupdate`
66
# - &flake8_dependencies below needs updated manually
77
fail_fast: true
8+
default_language_version:
9+
python: python3
810
repos:
911
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v4.3.0
12+
rev: v4.4.0
1113
hooks:
1214
- id: check-added-large-files
1315
- id: check-ast
@@ -17,40 +19,45 @@ repos:
1719
- id: end-of-file-fixer
1820
- id: mixed-line-ending
1921
- id: trailing-whitespace
22+
- repo: https://github.com/abravalheri/validate-pyproject
23+
rev: v0.11
24+
hooks:
25+
- id: validate-pyproject
26+
name: Validate pyproject.toml
2027
- repo: https://github.com/myint/autoflake
21-
rev: v1.7.7
28+
rev: v2.0.0
2229
hooks:
2330
- id: autoflake
2431
args: [--in-place]
2532
- repo: https://github.com/pycqa/isort
26-
rev: 5.10.1
33+
rev: 5.12.0
2734
hooks:
2835
- id: isort
29-
language_version: python3
3036
- repo: https://github.com/asottile/pyupgrade
31-
rev: v3.2.2
37+
rev: v3.3.1
3238
hooks:
3339
- id: pyupgrade
3440
args: [--py38-plus]
3541
- repo: https://github.com/MarcoGorelli/auto-walrus
36-
rev: v0.2.1
42+
rev: v0.2.2
3743
hooks:
38-
- id: auto-walrus
44+
- id: auto-walrus
45+
args: [--line-length, "100"]
3946
- repo: https://github.com/psf/black
40-
rev: 22.10.0
47+
rev: 22.12.0
4148
hooks:
4249
- id: black
43-
language_version: python3
4450
args: [--target-version=py38]
4551
- repo: https://github.com/PyCQA/flake8
46-
rev: 5.0.4
52+
rev: 6.0.0
4753
hooks:
4854
- id: flake8
4955
additional_dependencies: &flake8_dependencies
5056
# These versions need updated manually
51-
- flake8==5.0.4
57+
- flake8==6.0.0
5258
- flake8-comprehensions==3.10.1
53-
- flake8-bugbear==22.10.27
59+
- flake8-bugbear==23.1.20
60+
- flake8-simplify==0.19.3
5461
- repo: https://github.com/asottile/yesqa
5562
rev: v1.4.0
5663
hooks:
@@ -62,9 +69,7 @@ repos:
6269
- id: codespell
6370
types_or: [python, rst, markdown]
6471
files: ^(graphblas_algorithms|docs)/
65-
# args: ["--ignore-words-list=coo,ba"]
6672
- repo: https://github.com/pre-commit/pre-commit-hooks
67-
rev: v4.3.0
73+
rev: v4.4.0
6874
hooks:
6975
- id: no-commit-to-branch # no commit directly to main
70-
# Maybe: black-jupyter, blacken-docs, blackdoc mypy, velin

‎pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ requires = ["setuptools", "wheel"]
33

44
[tool.black]
55
line-length = 100
6+
target-version = ["py38", "py39", "py310", "py311"]

‎scripts/bench.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,21 @@ def getfunction(functionname, backend):
132132
return getattr(nx, functionname)
133133

134134

135-
def main(dataname, backend, functionname, time=3.0, n=None, extra=None, display=True):
135+
def getgraph(dataname, backend="graphblas", functionname=None):
136136
filename = find_data(dataname)
137137
is_symmetric = get_symmetry(filename) == "symmetric"
138-
if not is_symmetric and functionname in undirected_only:
138+
if not is_symmetric and functionname isnotNoneandfunctionnamein undirected_only:
139139
# Should we automatically symmetrize?
140140
raise ValueError(
141141
f"Data {dataname!r} is not symmetric, but {functionname} only works on undirected"
142142
)
143143
if is_symmetric and functionname in directed_only:
144144
is_symmetric = False # Make into directed graph
145-
G = readfile(filename, is_symmetric, backend)
145+
return readfile(filename, is_symmetric, backend)
146+
147+
148+
def main(dataname, backend, functionname, time=3.0, n=None, extra=None, display=True):
149+
G = getgraph(dataname, backend, functionname)
146150
func = getfunction(functionname, backend)
147151
benchstring = functioncall.get(functionname, "func(G)")
148152
if extra is not None:

‎setup.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ max-line-length = 100
66
inline-quotes = "
77
exclude =
88
versioneer.py,
9+
graphblas_algorithms/_version.py,
910
graphblas_algorithms/*/tests/,
1011
graphblas_algorithms/*/*/tests/,
1112
build/
1213
extend-ignore =
1314
E203,
15+
SIM105,
16+
SIM401,
1417
# E203 whitespace before ':' (to be compatible with black)
1518
per-file-ignores =
1619
__init__.py:F401,F403, # allow unused and star imports
1720
test_*.py:F401,F403,
1821
graphblas_algorithms/nxapi/exception.py:F401,
22+
graphblas_algorithms/**/__init__.py:F401,F403
1923
2024
[isort]
2125
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
@@ -26,7 +30,8 @@ default_section = THIRDPARTY
2630
known_first_party = graphblas_algorithms
2731
line_length = 100
2832
skip =
29-
graphblas_algorithms/nxapi/__init__.py
33+
graphblas_algorithms/nxapi/__init__.py,
34+
scripts/bench.py
3035
3136
[coverage:run]
3237
source = graphblas_algorithms

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /