From a84b25b59ff9d9722f1b80ef22bad895e965d396 Mon Sep 17 00:00:00 2001 From: Hongbo Miao <3375461+hongbo-miao@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:15:53 -0800 Subject: [PATCH] feat(ruff): enable pydocstyle and flake8-async (#22398) --- .ruff.toml | 46 ++++++++++++------- api-python/routers/motor.py | 3 +- data-analytics/hm-networkx/src/main.py | 6 --- .../graph-neural-network/src/model/conv.py | 1 - .../graph-neural-network/src/model/gnn.py | 5 -- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index a8a4a7cc2d..b7aebe9a2d 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -171,28 +171,40 @@ exclude = [ # https://docs.astral.sh/ruff/rules/ [lint] select = [ - "AIR", # Airflow - "C90", # mccabe - "COM", # flake8-commas - "E", # pycodestyle - "F", # Pyflakes - "FAST", # FastAPI - "FLY", # flynt - "FURB", # Refurb - "I", # isort - "N", # pep8-naming - "NPY", # NumPy - "PERF", # Perflint - "PGH", # pygrep-hooks - "PL", # Pylint - "RUF", # Ruff - "TRY", # tryceratops - "UP", # pyupgrade + "AIR", # Airflow + "ASYNC", # flake8-async + "C90", # mccabe + "COM", # flake8-commas + "D", # pydocstyle + "E", # pycodestyle + "F", # Pyflakes + "FAST", # FastAPI + "FLY", # flynt + "FURB", # Refurb + "I", # isort + "N", # pep8-naming + "NPY", # NumPy + "PERF", # Perflint + "PGH", # pygrep-hooks + "PL", # Pylint + "RUF", # Ruff + "TRY", # tryceratops + "UP", # pyupgrade ] ignore = [ + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D107", + "D203", + "D212", "E501", "PLR0913", "PLR0915", "PLR2004", "TRY003", + "COM812", ] diff --git a/api-python/routers/motor.py b/api-python/routers/motor.py index cc2d2e0476..77076ef63f 100644 --- a/api-python/routers/motor.py +++ b/api-python/routers/motor.py @@ -1,3 +1,4 @@ +import asyncio import json import random import time @@ -37,5 +38,5 @@ async def generate_motor_data( json.dumps(data).encode("utf-8"), callback=delivery_report, ) - time.sleep(1) + await asyncio.sleep(1) return {"body": True} diff --git a/data-analytics/hm-networkx/src/main.py b/data-analytics/hm-networkx/src/main.py index 32a5393d15..e8f3210213 100644 --- a/data-analytics/hm-networkx/src/main.py +++ b/data-analytics/hm-networkx/src/main.py @@ -54,9 +54,6 @@ def analyze_network(graph: nx.Graph) -> None: def visualize_network(graph: nx.Graph) -> None: - """ - Create and display a visualization of the network. - """ plt.figure(figsize=(10, 8)) pos = nx.spring_layout(graph) @@ -79,9 +76,6 @@ def visualize_network(graph: nx.Graph) -> None: def main() -> None: - """ - Main function to execute the network analysis. - """ graph = create_network() analyze_network(graph) visualize_network(graph) diff --git a/machine-learning/graph-neural-network/src/model/conv.py b/machine-learning/graph-neural-network/src/model/conv.py index e34a796b0a..f2c5d58b05 100644 --- a/machine-learning/graph-neural-network/src/model/conv.py +++ b/machine-learning/graph-neural-network/src/model/conv.py @@ -146,7 +146,6 @@ def forward(self, batched_data): return node_representation -# Virtual GNN to generate node embedding class GNNVirtualNode(torch.nn.Module): def __init__( self, diff --git a/machine-learning/graph-neural-network/src/model/gnn.py b/machine-learning/graph-neural-network/src/model/gnn.py index 886a469c5d..0cd02ae27e 100644 --- a/machine-learning/graph-neural-network/src/model/gnn.py +++ b/machine-learning/graph-neural-network/src/model/gnn.py @@ -22,11 +22,6 @@ def __init__( jk="last", graph_pooling="mean", ): - """ - num_tasks (int): number of labels to be predicted - virtual_node (bool): whether to add virtual node or not - """ - super().__init__() self.num_layer = num_layer