Skip to content

Commit 8e9139a

Browse files
authored
new: enable black, isort, flake8, mypy (#5)
* new: enable `black`, `isort`, `flake8` * checkpoint: `mypy` * cleanup: `build.yaml` * fix: `build.yaml` * fix: `uses` * add `type: ignore` * fix: flake * fix: `phenolrs` * fix: mypy * restructure class order in `dict.py` * bring back `__repr__` and `__str__` * cleanup * rename: `_to_nx_graph`
1 parent 5ea9d99 commit 8e9139a

File tree

21 files changed

+814
-949
lines changed

21 files changed

+814
-949
lines changed

.github/workflows/build.yaml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,49 @@ on:
44
pull_request:
55
push:
66
branches: [ main ]
7+
78
env:
89
PACKAGE_DIR: nx_arangodb
910
TESTS_DIR: tests
11+
1012
jobs:
11-
build:
13+
lint:
1214
runs-on: ubuntu-latest
13-
continue-on-error: true
1415
steps:
1516
- uses: actions/checkout@v4
1617

1718
- name: Setup Python 3.10
18-
uses: actions/setup-python@v4
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.10"
22+
cache: 'pip'
23+
cache-dependency-path: setup.py
24+
25+
- name: Setup pip
26+
run: python -m pip install --upgrade pip setuptools wheel
27+
28+
- name: Install packages
29+
run: pip install .[dev]
30+
31+
- name: Run black
32+
run: black --check --verbose --diff --color ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
33+
34+
- name: Run flake8
35+
run: flake8 ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
36+
37+
- name: Run isort
38+
run: isort --check --profile=black ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
39+
40+
- name: Run mypy
41+
run: mypy ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
42+
43+
test:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Setup Python 3.10
49+
uses: actions/setup-python@v5
1950
with:
2051
python-version: "3.10"
2152
cache: 'pip'
@@ -30,22 +61,10 @@ jobs:
3061
run: python -m pip install --upgrade pip setuptools wheel
3162

3263
- name: Install packages
33-
run: pip install .[test]
34-
35-
# - name: Run black
36-
# run: black --check --verbose --diff --color ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
37-
38-
# - name: Run flake8
39-
# run: flake8 ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
40-
41-
# - name: Run isort
42-
# run: isort --check --profile=black ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
43-
44-
# - name: Run mypy
45-
# run: mypy ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
64+
run: pip install .[dev]
4665

4766
- name: Run local tests
4867
run: pytest tests/test.py
4968

5069
- name: Run NetworkX tests
51-
run: ./run_nx_tests.sh
70+
run: ./run_nx_tests.sh

nx_arangodb/algorithms/centrality/betweenness.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# type: ignore
2+
# NOTE: NetworkX algorithms are not typed
3+
14
import networkx as nx
25

3-
from nx_arangodb.convert import _to_nxadb_graph, _to_nxcg_graph
6+
from nx_arangodb.convert import _to_nx_graph, _to_nxcg_graph
47
from nx_arangodb.logger import logger
58
from nx_arangodb.utils import networkx_algorithm
69

@@ -40,7 +43,7 @@ def betweenness_centrality(
4043
print("Running nxcg.betweenness_centrality()")
4144
return nxcg.betweenness_centrality(G, k=k, normalized=normalized, weight=weight)
4245

43-
G = _to_nxadb_graph(G, pull_graph=pull_graph_on_cpu)
46+
G = _to_nx_graph(G, pull_graph=pull_graph_on_cpu)
4447

4548
logger.debug("using nx.betweenness_centrality")
4649
return nx.betweenness_centrality.orig_func(

nx_arangodb/algorithms/community/louvain.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
# type: ignore
2+
# NOTE: NetworkX algorithms are not typed
3+
14
from collections import deque
25

36
import networkx as nx
47

5-
from nx_arangodb.convert import _to_nxadb_graph, _to_nxcg_graph
8+
from nx_arangodb.convert import _to_nx_graph, _to_nxcg_graph
69
from nx_arangodb.logger import logger
710
from nx_arangodb.utils import _dtype_param, networkx_algorithm
811

@@ -50,7 +53,7 @@ def louvain_communities(
5053
seed=seed,
5154
)
5255

53-
G = _to_nxadb_graph(G, pull_graph=pull_graph_on_cpu)
56+
G = _to_nx_graph(G, pull_graph=pull_graph_on_cpu)
5457

5558
logger.debug("using nx.louvain_communities")
5659
return nx.community.louvain_communities.orig_func(

nx_arangodb/algorithms/link_analysis/pagerank_alg.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# type: ignore
2+
# NOTE: NetworkX algorithms are not typed
3+
14
import networkx as nx
25

3-
from nx_arangodb.convert import _to_nxadb_graph, _to_nxcg_graph
6+
from nx_arangodb.convert import _to_nx_graph, _to_nxcg_graph
47
from nx_arangodb.logger import logger
58
from nx_arangodb.utils import _dtype_param, networkx_algorithm
69

@@ -51,7 +54,7 @@ def pagerank(
5154
dtype=dtype,
5255
)
5356

54-
G = _to_nxadb_graph(G, pull_graph=pull_graph_on_cpu)
57+
G = _to_nx_graph(G, pull_graph=pull_graph_on_cpu)
5558

5659
logger.debug("using nx.pagerank")
5760
return nx.algorithms.pagerank.orig_func(

nx_arangodb/algorithms/shortest_paths/generic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# type: ignore
2+
# NOTE: NetworkX algorithms are not typed
3+
14
import networkx as nx
25

36
import nx_arangodb as nxadb

0 commit comments

Comments
 (0)