Skip to content

Commit d4a746d

Browse files
committed
Fix code style issues and update linting configuration
- Add noqa comments for intentional imports in __init__.py - Remove duplicate draw function definition in base.py - Remove unused 'os' import from draw.py - Replace lambda assignment with proper function definition in draw.py - Fix unused exception variables in hypergraph.py - Fix comparison operators (== None/True/False) in test files - Add .flake8 configuration file with max-line-length = 119 - Update isort configuration to use correct parameter name (line_length) - Format all files with black and isort
1 parent 5baca7a commit d4a746d

File tree

12 files changed

+42
-37
lines changed

12 files changed

+42
-37
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 119
3+
extend-ignore = E203, W503

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
uses: astral-sh/setup-uv@v5
2929
with:
3030
version: "latest"
31+
enable-cache: true
3132

3233
- name: Set up Python ${{ matrix.python-version }}
3334
run: uv python install ${{ matrix.python-version }}
@@ -65,6 +66,7 @@ jobs:
6566
uses: astral-sh/setup-uv@v5
6667
with:
6768
version: "latest"
69+
enable-cache: true
6870

6971
- name: Set up Python
7072
run: uv python install 3.11

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
uses: astral-sh/setup-uv@v5
3737
with:
3838
version: "latest"
39+
enable-cache: true
3940

4041
- name: Set up Python
4142
run: uv python install 3.11

.github/workflows/quality.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
with:
2525
version: "latest"
2626
enable-cache: true
27-
cache-dependency-glob: "**/uv.lock"
2827

2928
- name: Set up Python
3029
run: uv python install 3.11

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
uses: astral-sh/setup-uv@v5
2323
with:
2424
version: "latest"
25+
enable-cache: true
2526

2627
- name: Set up Python
2728
run: uv python install 3.11

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ __pycache__/
44
*$py.class
55
*.DS_Store
66
logs/
7+
.vscode/
78

89

910
# C extensions

hyperdb/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from ._global import AUTHOR_EMAIL
2-
from .base import BaseHypergraphDB
3-
from .hypergraph import HypergraphDB
1+
from ._global import AUTHOR_EMAIL # noqa: F401
2+
from .base import BaseHypergraphDB # noqa: F401
3+
from .hypergraph import HypergraphDB # noqa: F401
44

55
__version__ = "0.2.0"
66

7-
__all__ = {"AUTHOR_EMAIL", "BaseHypergraphDB", "HypergraphDB"}
7+
__all__ = ["AUTHOR_EMAIL", "BaseHypergraphDB", "HypergraphDB"]

hyperdb/base.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def save(self, file_path: Union[str, Path]):
1717
Save the hypergraph to a file.
1818
1919
Args:
20-
``file_path`` (``Union[str, Path]``): The file path to save the hypergraph.
20+
``file_path`` (``Union[str, Path]``): The file path to save the
21+
hypergraph.
2122
"""
2223
raise NotImplementedError
2324

@@ -233,14 +234,6 @@ def nbr_v(self, v_id: Any) -> list:
233234
"""
234235
raise NotImplementedError
235236

236-
def draw(
237-
self,
238-
):
239-
r"""
240-
Draw the hypergraph.
241-
"""
242-
raise NotImplementedError
243-
244237
def sub(self, v_name_list: List[str]):
245238
r"""
246239
Return the sub-hypergraph.

hyperdb/draw.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import http.server
22
import json
3-
import os
43
import socketserver
54
import threading
65
import webbrowser
@@ -233,7 +232,9 @@ def start_server(self, open_browser: bool = True):
233232
"""Start HTTP server with API endpoints"""
234233

235234
def run_server():
236-
handler = lambda *args, **kwargs: HypergraphAPIHandler(self.hypergraph_db, *args, **kwargs)
235+
def handler(*args, **kwargs):
236+
return HypergraphAPIHandler(self.hypergraph_db, *args, **kwargs)
237+
237238
self.httpd = socketserver.TCPServer(("127.0.0.1", self.port), handler)
238239
self.httpd.serve_forever()
239240

hyperdb/hypergraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def load(self, storage_file: Path) -> dict:
3838
self._v_inci = data.get("v_inci", {})
3939
self._e_data = data.get("e_data", {})
4040
return True
41-
except Exception as e:
41+
except Exception:
4242
return False
4343

4444
def save(self, storage_file: Path) -> dict:
@@ -54,7 +54,7 @@ def save(self, storage_file: Path) -> dict:
5454
with open(storage_file, "wb") as f:
5555
pkl.dump(data, f)
5656
return True
57-
except Exception as e:
57+
except Exception:
5858
return False
5959

6060
def _clear_cache(self):

0 commit comments

Comments
 (0)