Skip to content

Commit e763109

Browse files
committed
Fix Ruff lint errors
- Resolve undefined 'Odev' in run.py - Fix FBT003 and S108 in test_python_env.py
1 parent b80dbda commit e763109

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

odev/commands/database/run.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
"""Run an Odoo database locally."""
22

3+
from typing import TYPE_CHECKING
4+
35
from odev.common import args, progress
46
from odev.common.commands import OdoobinTemplateCommand
57
from odev.common.logging import logging
68
from odev.common.version import OdooVersion
79

810

11+
if TYPE_CHECKING:
12+
from odev.common.odev import Odev
13+
14+
915
logger = logging.getLogger(__name__)
1016

1117

tests/tests/commands/test_database.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ def test_14_run_empty_db_warning(self):
418418
# Logging goes to stdout in these tests
419419
combined_output = stdout + stderr
420420
self.assertIn(f"Database {empty_db!r} is not an Odoo database. Defaulting to 'master'.", combined_output)
421-
self.assertIn(f"Consider using 'odev create -V <version> {empty_db}' to initialize it properly.", combined_output)
421+
self.assertIn(
422+
f"Consider using 'odev create -V <version> {empty_db}' to initialize it properly.", combined_output
423+
)
422424
finally:
423425
LocalDatabase(empty_db).drop()
424426

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from subprocess import CalledProcessError, CompletedProcess
21
from pathlib import Path
2+
from subprocess import CalledProcessError, CompletedProcess
33
from unittest.mock import MagicMock, patch
44

5+
from odev.common import bash
56
from odev.common.python import PythonEnv
6-
from odev.common import odev, bash
77

88
from tests.fixtures import OdevTestCase
99

@@ -18,17 +18,17 @@ def setUpClass(cls):
1818

1919
def test_run_script_streaming_success(self):
2020
"""Test run_script with a streaming process that succeeds."""
21-
env = PythonEnv(path="/tmp/fake_venv", version="3.10")
22-
21+
env = PythonEnv(path="/tmp/fake_venv", version="3.10") # noqa: S108
22+
2323
with (
24-
self.patch(Path, "exists", True),
25-
self.patch(PythonEnv, "exists", True),
26-
self.patch(PythonEnv, "python", Path("/tmp/fake_venv/bin/python")),
27-
self.patch(bash, "stream", return_value=iter(["line 1", "line 2"]))
24+
self.patch(Path, "exists", return_value=True),
25+
self.patch(PythonEnv, "exists", return_value=True),
26+
self.patch(PythonEnv, "python", Path("/tmp/fake_venv/bin/python")), # noqa: S108
27+
self.patch(bash, "stream", return_value=iter(["line 1", "line 2"])),
2828
):
2929
progress_mock = MagicMock()
3030
result = env.run_script("fake_script.py", stream=True, progress=progress_mock)
31-
31+
3232
self.assertIsInstance(result, CompletedProcess)
3333
self.assertEqual(result.returncode, 0)
3434
self.assertEqual(progress_mock.call_count, 2)
@@ -37,21 +37,21 @@ def test_run_script_streaming_success(self):
3737

3838
def test_run_script_streaming_failure(self):
3939
"""Test run_script with a streaming process that fails."""
40-
env = PythonEnv(path="/tmp/fake_venv", version="3.10")
41-
40+
env = PythonEnv(path="/tmp/fake_venv", version="3.10") # noqa: S108
41+
4242
def streaming_failure(command):
4343
yield "line 1"
4444
raise CalledProcessError(1, command)
4545

4646
with (
47-
self.patch(Path, "exists", True),
48-
self.patch(PythonEnv, "exists", True),
49-
self.patch(PythonEnv, "python", Path("/tmp/fake_venv/bin/python")),
50-
self.patch(bash, "stream", side_effect=streaming_failure)
47+
self.patch(Path, "exists", return_value=True),
48+
self.patch(PythonEnv, "exists", return_value=True),
49+
self.patch(PythonEnv, "python", Path("/tmp/fake_venv/bin/python")), # noqa: S108
50+
self.patch(bash, "stream", side_effect=streaming_failure),
5151
):
5252
progress_mock = MagicMock()
5353
result = env.run_script("fake_script.py", stream=True, progress=progress_mock)
54-
54+
5555
self.assertIsInstance(result, CompletedProcess)
5656
self.assertEqual(result.returncode, 1)
5757
progress_mock.assert_called_once_with("line 1")

0 commit comments

Comments
 (0)