opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
196 stars 11 forks source link

task: Activate ASYNC linter for ruff #1255

Open ogenstad opened 12 months ago

ogenstad commented 12 months ago

Component

API Server / GraphQL, Git Integration

Task Description

We should activate the ASYNC linter for ruff and fix any code that breaks the rules.

diff --git a/pyproject.toml b/pyproject.toml
index afed7aaf..95c12688 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -308,6 +308,7 @@ disallow_untyped_defs = false
 [tool.ruff]

 select = [
+    "ASYNC",
     "C90",
     "DTZ",
     "E",
❯ ruff .
backend/infrahub/git/repository.py:1514:18: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/infrahub/git/repository.py:1616:14: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/api/test_60_storage.py:36:21: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/conftest.py:201:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/conftest.py:230:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/conftest.py:261:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/conftest.py:272:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/conftest.py:315:14: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/conftest.py:333:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/test_git_repository.py:56:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/test_git_repository.py:71:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/test_git_repository.py:128:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/test_git_repository.py:176:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/test_git_repository.py:345:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
backend/tests/unit/git/test_git_repository.py:703:10: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
Found 15 errors.

Probably this would mostly mean to use aiofiles instead of plain open().

ogenstad commented 7 months ago

This rule has been added to the ruff config in #2448, however the failing sub rules has been added to the ignore section. The goal of this issue now is to remove those ignore lines.