Browse Source

add pyflakes

Falko Schindler 1 năm trước cách đây
mục cha
commit
da6932894d

+ 2 - 1
examples/pytest/conftest.py

@@ -1 +1,2 @@
-from nicegui.testing.conftest import *
+# pylint: disable=wildcard-import,unused-wildcard-import
+from nicegui.testing.conftest import *  # noqa: F401,F403

+ 2 - 2
fetch_tailwind.py

@@ -162,12 +162,12 @@ def generate_tailwind_file(properties: List[Property]) -> None:
                         f"        self.element.classes('{prefix}' + value if value else '{prefix.rstrip('''-''')}')\n")
                 else:
                     f.write(f"        self.element.classes('{prefix}' + value)\n")
-                f.write(f'        return self\n')  # pylint: disable=f-string-without-interpolation
+                f.write('        return self\n')
             else:
                 f.write(f'    def {property_.snake_title}(self) -> Tailwind:\n')
                 f.write(f'        """{property_.description}"""\n')
                 f.write(f"        self.element.classes('{prefix}')\n")
-                f.write(f'        return self\n')  # pylint: disable=f-string-without-interpolation
+                f.write('        return self\n')
 
 
 def main() -> None:

+ 4 - 0
pyproject.toml

@@ -85,6 +85,7 @@ line-length = 120
 select = [
     "I",  # isort
     "E",  # pycodestyle
+    "F",  # pyflakes
     "UP", # pyupgrade
 ]
 fixable = [
@@ -95,3 +96,6 @@ ignore = [
     "UP006", # use pipe for union type annotation
     "UP007", # use pipe for union type annotation
 ]
+exclude = [
+    "website/documentation/content/*",
+]

+ 2 - 1
tests/conftest.py

@@ -1 +1,2 @@
-from nicegui.testing.conftest import *  # pylint: disable=wildcard-import,unused-wildcard-import
+# pylint: disable=wildcard-import,unused-wildcard-import
+from nicegui.testing.conftest import *  # noqa: F401,F403

+ 1 - 1
tests/test_json.py

@@ -12,7 +12,7 @@ import pytest
 
 try:
     # try to import module, only run test if succeeded
-    import orjson  # pylint: disable=unused-import
+    import orjson  # noqa: F401
 except ImportError:
     pass
 

+ 4 - 1
tests/test_page.py

@@ -1,5 +1,6 @@
 import asyncio
 import re
+from typing import Optional
 from uuid import uuid4
 
 from fastapi.responses import PlainTextResponse
@@ -102,15 +103,17 @@ def test_shared_and_private_pages(screen: Screen):
 
 
 def test_wait_for_connected(screen: Screen):
-    label: ui.label
+    label: Optional[ui.label] = None
 
     async def load() -> None:
+        assert label
         label.text = 'loading...'
         # NOTE we can not use asyncio.create_task() here because we are on a different thread than the NiceGUI event loop
         background_tasks.create(takes_a_while())
 
     async def takes_a_while() -> None:
         await asyncio.sleep(0.1)
+        assert label
         label.text = 'delayed data has been loaded'
 
     @ui.page('/')

+ 4 - 1
tests/test_scene.py

@@ -1,3 +1,5 @@
+from typing import Optional
+
 import numpy as np
 from selenium.common.exceptions import JavascriptException
 
@@ -43,7 +45,7 @@ def test_no_object_duplication_on_index_client(screen: Screen):
 
 
 def test_no_object_duplication_with_page_builder(screen: Screen):
-    scene: ui.scene
+    scene: Optional[ui.scene] = None
 
     @ui.page('/')
     def page():
@@ -58,6 +60,7 @@ def test_no_object_duplication_with_page_builder(screen: Screen):
     screen.open('/')
     screen.switch_to(0)
     screen.wait(0.2)
+    assert scene
     assert screen.selenium.execute_script(f'return scene_c{scene.id}.children.length') == 5
     screen.switch_to(1)
     assert screen.selenium.execute_script(f'return scene_c{scene.id}.children.length') == 5

+ 0 - 3
website/documentation/reference.py

@@ -1,9 +1,6 @@
 import inspect
-import re
 from typing import Callable, Optional
 
-import docutils.core
-
 from nicegui import binding, ui
 
 from ..style import create_anchor_name, subheading