Преглед на файлове

feat: remove explicit ignore T201 on tests and tools folder

trgiangdo преди 1 година
родител
ревизия
b612a995b8

+ 1 - 4
pyproject.toml

@@ -15,7 +15,6 @@ exclude = [
 ]
 line-length = 120
 indent-width = 4
-ignore-init-module-imports = true
 
 [tool.ruff.lint]
 select = [
@@ -28,7 +27,7 @@ select = [
     "B", # flake8-bugbear best practices checker
     "I001", # isort import order
 ]
-ignore = [
+ignore = [      # TODO: to be removed
     "E203",  # whitespace before ':'
     "E722",  # do not use bare except
     "C401",  # Unnecessary generator (rewrite as a `set` comprehension)
@@ -47,8 +46,6 @@ unfixable = []
 "_init.py" = ["F401", "F403"]  # unused import
 "taipy/config/stubs/pyi_header.py" = ["F401", "F403"]  # unused import
 "taipy/templates/*" = ["F401", "F403", "T201"]  # unused import, `print` found
-"tests/*" = ["T201"]  # `print` found
-"tools/*" = ["T201"]  # `print` found
 
 [tool.ruff.lint.mccabe]
 max-complexity = 18

+ 0 - 1
tests/core/config/test_config_serialization.py

@@ -35,7 +35,6 @@ def compare_function(*data_node_results):
         comparison_result[current_result_index] = {}
         next_result_index = 0
         for next_result in data_node_results:
-            print(f"comparing result {current_result_index} with result {next_result_index}")
             comparison_result[current_result_index][next_result_index] = next_result - current_result
             next_result_index += 1
         current_result_index += 1

+ 3 - 3
tests/core/data/test_data_node.py

@@ -33,17 +33,17 @@ from .utils import FakeDataNode
 
 
 def funct_a_b(input: str):
-    print("task_a_b")
+    print("task_a_b")  # noqa: T201
     return "B"
 
 
 def funct_b_c(input: str):
-    print("task_b_c")
+    print("task_b_c")  # noqa: T201
     return "C"
 
 
 def funct_b_d(input: str):
-    print("task_b_d")
+    print("task_b_d")  # noqa: T201
     return "D"
 
 

+ 0 - 1
tests/core/data/test_pickle_data_node.py

@@ -41,7 +41,6 @@ class TestPickleDataNodeEntity:
         import glob
 
         for f in glob.glob("*.p"):
-            print(f"deleting file {f}")
             os.remove(f)
 
     def test_create(self):

+ 1 - 1
tests/core/scenario/test_scenario_manager.py

@@ -1098,7 +1098,7 @@ def test_submit():
 
 
 def my_print(a, b):
-    print(a + b)
+    print(a + b)  # noqa: T201
 
 
 def test_submit_task_with_input_dn_wrong_file_path(caplog):

+ 1 - 1
tests/core/sequence/test_sequence_manager.py

@@ -908,7 +908,7 @@ def test_hard_delete_shared_entities():
 
 
 def my_print(a, b):
-    print(a + b)
+    print(a + b)  # noqa: T201
 
 
 def test_submit_task_with_input_dn_wrong_file_path(caplog):

+ 1 - 1
tests/core/task/test_task_manager.py

@@ -367,7 +367,7 @@ def test_submit_task():
 
 
 def my_print(a, b):
-    print(a + b)
+    print(a + b)  # noqa: T201
 
 
 def test_submit_task_with_input_dn_wrong_file_path(caplog):

+ 4 - 12
tests/core/test_taipy.py

@@ -50,6 +50,10 @@ from taipy.core.scenario._scenario_manager import _ScenarioManager
 from taipy.core.task._task_manager import _TaskManager
 
 
+def cb(s, j):
+    print()  # noqa: T201
+
+
 class TestTaipy:
     def test_set(self, scenario, cycle, sequence, data_node, task):
         with mock.patch("taipy.core.data._data_manager._DataManager._set") as mck:
@@ -431,9 +435,6 @@ class TestTaipy:
             mck.assert_called_once_with(scenario, scenario, data_node_config_id="dn")
 
     def test_subscribe_scenario(self, scenario):
-        def cb(s, j):
-            print()
-
         with mock.patch("taipy.core.scenario._scenario_manager._ScenarioManager._subscribe") as mck:
             tp.subscribe_scenario(cb)
             mck.assert_called_once_with(cb, [], None)
@@ -442,9 +443,6 @@ class TestTaipy:
             mck.assert_called_once_with(cb, [], scenario)
 
     def test_unsubscribe_scenario(self, scenario):
-        def cb(s, j):
-            print()
-
         with mock.patch("taipy.core.scenario._scenario_manager._ScenarioManager._unsubscribe") as mck:
             tp.unsubscribe_scenario(cb)
             mck.assert_called_once_with(cb, None, None)
@@ -453,9 +451,6 @@ class TestTaipy:
             mck.assert_called_once_with(cb, None, scenario)
 
     def test_subscribe_sequence(self, sequence):
-        def cb(s, j):
-            print()
-
         with mock.patch("taipy.core.sequence._sequence_manager._SequenceManager._subscribe") as mck:
             tp.subscribe_sequence(cb)
             mck.assert_called_once_with(cb, None, None)
@@ -464,9 +459,6 @@ class TestTaipy:
             mck.assert_called_once_with(cb, None, sequence)
 
     def test_unsubscribe_sequence(self, sequence):
-        def cb(s, j):
-            print()
-
         with mock.patch("taipy.core.sequence._sequence_manager._SequenceManager._unsubscribe") as mck:
             tp.unsubscribe_sequence(callback=cb)
             mck.assert_called_once_with(cb, None, None)

+ 2 - 2
tests/core/utils/__init__.py

@@ -22,9 +22,9 @@ def assert_true_after_time(assertion, msg=None, time=120):
             if assertion():
                 return
         except BaseException as e:
-            print("Raise : ", e)
+            print("Raise : ", e)  # noqa: T201
             loops += 1
             continue
     if msg:
-        print(msg)
+        print(msg)  # noqa: T201
     assert assertion()

+ 4 - 4
tests/rest/setup/shared/algorithms.py

@@ -49,7 +49,7 @@ if __name__ == "__main__":
     historical_temperature = pd.read_csv("../historical_temperature.csv")
     evaluation = evaluate(historical_temperature, forecasts, day)
 
-    print(evaluation["Dataframe"])
-    print()
-    print(f'Mean absolute error : {evaluation["Mean_absolute_error"]}')
-    print(f'Relative error in %: {evaluation["Relative_error"]}')
+    print(evaluation["Dataframe"])  # noqa: T201
+    print()  # noqa: T201
+    print(f'Mean absolute error : {evaluation["Mean_absolute_error"]}')  # noqa: T201
+    print(f'Relative error in %: {evaluation["Relative_error"]}')  # noqa: T201

+ 4 - 4
tools/frontend/bundle_build.py

@@ -18,10 +18,10 @@ with_shell = platform.system() == "Windows"
 
 
 def build_gui(root_path: Path):
-    print(f"Building taipy-gui frontend bundle in {root_path}.")
+    print(f"Building taipy-gui frontend bundle in {root_path}.")  # noqa: T201
     already_exists = (root_path / "taipy" / "gui" / "webapp" / "index.html").exists()
     if already_exists:
-        print(f'Found taipy-gui frontend bundle in {root_path  / "taipy" / "gui" / "webapp"}.')
+        print(f'Found taipy-gui frontend bundle in {root_path  / "taipy" / "gui" / "webapp"}.')  # noqa: T201
     else:
         subprocess.run(["npm", "ci"], cwd=root_path / "frontend" / "taipy-gui" / "dom", check=True, shell=with_shell)
         subprocess.run(
@@ -31,10 +31,10 @@ def build_gui(root_path: Path):
 
 
 def build_taipy(root_path: Path):
-    print(f"Building taipy frontend bundle in {root_path}.")
+    print(f"Building taipy frontend bundle in {root_path}.")  # noqa: T201
     already_exists = (root_path / "taipy" / "gui_core" / "lib" / "taipy-gui-core.js").exists()
     if already_exists:
-        print(f'Found taipy frontend bundle in {root_path / "taipy" / "gui_core" / "lib"}.')
+        print(f'Found taipy frontend bundle in {root_path / "taipy" / "gui_core" / "lib"}.')  # noqa: T201
     else:
         # Specify the correct path to taipy-gui in gui/.env file
         env_file_path = root_path / "frontend" / "taipy" / ".env"