瀏覽代碼

update pre-commit and ruff (#4052)

This PR updates ruff (0.3.5 to 0.8.1) and pre-commit. It also includes a
few sorting and linting fixes that resulted from the ruff update.

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>
Paula Kammler 5 月之前
父節點
當前提交
25a633450d

+ 2 - 2
.pre-commit-config.yaml

@@ -5,12 +5,12 @@ default_stages: [commit]
 
 repos:
   - repo: https://github.com/astral-sh/ruff-pre-commit
-    rev: v0.3.5
+    rev: v0.8.1
     hooks:
       - id: ruff
         args: [--fix]
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v4.6.0
+    rev: v5.0.0
     hooks:
       - id: trailing-whitespace
         exclude: &exclusions |

+ 2 - 2
examples/local_file_picker/local_file_picker.py

@@ -62,8 +62,8 @@ class local_file_picker(ui.dialog):
             }
             for p in paths
         ]
-        if self.upper_limit is None and self.path != self.path.parent or \
-                self.upper_limit is not None and self.path != self.upper_limit:
+        if (self.upper_limit is None and self.path != self.path.parent) or \
+                (self.upper_limit is not None and self.path != self.upper_limit):
             self.grid.options['rowData'].insert(0, {
                 'name': '📁 <strong>..</strong>',
                 'path': str(self.path.parent),

+ 4 - 4
nicegui/__init__.py

@@ -10,15 +10,15 @@ from .version import __version__
 
 __all__ = [
     'APIRouter',
-    'app',
     'App',
     'Client',
-    'context',
     'ElementFilter',
+    'Tailwind',
+    '__version__',
+    'app',
+    'context',
     'elements',
     'html',
     'run',
-    'Tailwind',
     'ui',
-    '__version__',
 ]

+ 1 - 1
nicegui/json/__init__.py

@@ -15,7 +15,7 @@ except ImportError:
 
 
 __all__ = [
+    'NiceGUIJSONResponse',
     'dumps',
     'loads',
-    'NiceGUIJSONResponse'
 ]

+ 2 - 2
nicegui/native/__init__.py

@@ -3,10 +3,10 @@ from .native_config import NativeConfig
 from .native_mode import activate, find_open_port
 
 __all__ = [
+    'NativeConfig',
+    'WindowProxy',
     'activate',
     'find_open_port',
     'method_queue',
-    'NativeConfig',
     'response_queue',
-    'WindowProxy',
 ]

+ 28 - 28
nicegui/ui.py

@@ -1,5 +1,9 @@
 __all__ = [
-    'element',
+    'add_body_html',
+    'add_css',
+    'add_head_html',
+    'add_sass',
+    'add_scss',
     'aggrid',
     'audio',
     'avatar',
@@ -14,6 +18,7 @@ __all__ = [
     'chat_message',
     'checkbox',
     'chip',
+    'circular_progress',
     'clipboard',
     'code',
     'codemirror',
@@ -26,11 +31,16 @@ __all__ = [
     'dark_mode',
     'date',
     'dialog',
+    'download',
+    'drawer',
     'dropdown_button',
     'echart',
     'editor',
+    'element',
     'expansion',
+    'footer',
     'grid',
+    'header',
     'highchart',
     'html',
     'icon',
@@ -46,7 +56,9 @@ __all__ = [
     'knob',
     'label',
     'leaflet',
+    'left_drawer',
     'line_plot',
+    'linear_progress',
     'link',
     'link_target',
     'list',
@@ -58,17 +70,26 @@ __all__ = [
     'mermaid',
     'navigate',
     'notification',
+    'notify',
     'number',
+    'on',
+    'page',
+    'page_sticky',
+    'page_title',
     'pagination',
     'plotly',
-    'circular_progress',
-    'linear_progress',
     'pyplot',
     'query',
     'radio',
     'range',
+    'refreshable',
+    'refreshable_method',
     'restructured_text',
+    'right_drawer',
     'row',
+    'run',
+    'run_javascript',
+    'run_with',
     'scene',
     'scene_view',
     'scroll_area',
@@ -79,49 +100,28 @@ __all__ = [
     'space',
     'spinner',
     'splitter',
+    'state',
     'step',
     'stepper',
     'stepper_navigation',
     'switch',
-    'table',
     'tab',
     'tab_panel',
     'tab_panels',
+    'table',
     'tabs',
     'teleport',
     'textarea',
     'time',
-    'timer',
     'timeline',
     'timeline_entry',
+    'timer',
     'toggle',
     'tooltip',
     'tree',
+    'update',
     'upload',
     'video',
-    'download',
-    'add_body_html',
-    'add_head_html',
-    'run_javascript',
-    'notify',
-    'page_title',
-    'refreshable',
-    'refreshable_method',
-    'state',
-    'add_css',
-    'add_sass',
-    'add_scss',
-    'update',
-    'page',
-    'drawer',
-    'footer',
-    'header',
-    'left_drawer',
-    'on',
-    'page_sticky',
-    'right_drawer',
-    'run',
-    'run_with',
 ]
 
 from .context import context

+ 38 - 20
poetry.lock

@@ -2254,6 +2254,24 @@ nodeenv = ">=0.11.1"
 pyyaml = ">=5.1"
 virtualenv = ">=20.10.0"
 
+[[package]]
+name = "pre-commit"
+version = "4.0.1"
+description = "A framework for managing and maintaining multi-language pre-commit hooks."
+optional = false
+python-versions = ">=3.9"
+files = [
+    {file = "pre_commit-4.0.1-py2.py3-none-any.whl", hash = "sha256:efde913840816312445dc98787724647c65473daefe420785f885e8ed9a06878"},
+    {file = "pre_commit-4.0.1.tar.gz", hash = "sha256:80905ac375958c0444c65e9cebebd948b3cdb518f335a091a670a89d652139d2"},
+]
+
+[package.dependencies]
+cfgv = ">=2.0.0"
+identify = ">=1.0.0"
+nodeenv = ">=0.11.1"
+pyyaml = ">=5.1"
+virtualenv = ">=20.10.0"
+
 [[package]]
 name = "prettytable"
 version = "3.11.0"
@@ -3160,29 +3178,29 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
 
 [[package]]
 name = "ruff"
-version = "0.8.0"
+version = "0.8.1"
 description = "An extremely fast Python linter and code formatter, written in Rust."
 optional = false
 python-versions = ">=3.7"
 files = [
-    {file = "ruff-0.8.0-py3-none-linux_armv6l.whl", hash = "sha256:fcb1bf2cc6706adae9d79c8d86478677e3bbd4ced796ccad106fd4776d395fea"},
-    {file = "ruff-0.8.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:295bb4c02d58ff2ef4378a1870c20af30723013f441c9d1637a008baaf928c8b"},
-    {file = "ruff-0.8.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7b1f1c76b47c18fa92ee78b60d2d20d7e866c55ee603e7d19c1e991fad933a9a"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eb0d4f250a7711b67ad513fde67e8870109e5ce590a801c3722580fe98c33a99"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e55cce9aa93c5d0d4e3937e47b169035c7e91c8655b0974e61bb79cf398d49c"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f4cd64916d8e732ce6b87f3f5296a8942d285bbbc161acee7fe561134af64f9"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c5c1466be2a2ebdf7c5450dd5d980cc87c8ba6976fb82582fea18823da6fa362"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2dabfd05b96b7b8f2da00d53c514eea842bff83e41e1cceb08ae1966254a51df"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:facebdfe5a5af6b1588a1d26d170635ead6892d0e314477e80256ef4a8470cf3"},
-    {file = "ruff-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87a8e86bae0dbd749c815211ca11e3a7bd559b9710746c559ed63106d382bd9c"},
-    {file = "ruff-0.8.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:85e654f0ded7befe2d61eeaf3d3b1e4ef3894469cd664ffa85006c7720f1e4a2"},
-    {file = "ruff-0.8.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:83a55679c4cb449fa527b8497cadf54f076603cc36779b2170b24f704171ce70"},
-    {file = "ruff-0.8.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:812e2052121634cf13cd6fddf0c1871d0ead1aad40a1a258753c04c18bb71bbd"},
-    {file = "ruff-0.8.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:780d5d8523c04202184405e60c98d7595bdb498c3c6abba3b6d4cdf2ca2af426"},
-    {file = "ruff-0.8.0-py3-none-win32.whl", hash = "sha256:5fdb6efecc3eb60bba5819679466471fd7d13c53487df7248d6e27146e985468"},
-    {file = "ruff-0.8.0-py3-none-win_amd64.whl", hash = "sha256:582891c57b96228d146725975fbb942e1f30a0c4ba19722e692ca3eb25cc9b4f"},
-    {file = "ruff-0.8.0-py3-none-win_arm64.whl", hash = "sha256:ba93e6294e9a737cd726b74b09a6972e36bb511f9a102f1d9a7e1ce94dd206a6"},
-    {file = "ruff-0.8.0.tar.gz", hash = "sha256:a7ccfe6331bf8c8dad715753e157457faf7351c2b69f62f32c165c2dbcbacd44"},
+    {file = "ruff-0.8.1-py3-none-linux_armv6l.whl", hash = "sha256:fae0805bd514066f20309f6742f6ee7904a773eb9e6c17c45d6b1600ca65c9b5"},
+    {file = "ruff-0.8.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b8a4f7385c2285c30f34b200ca5511fcc865f17578383db154e098150ce0a087"},
+    {file = "ruff-0.8.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:cd054486da0c53e41e0086e1730eb77d1f698154f910e0cd9e0d64274979a209"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2029b8c22da147c50ae577e621a5bfbc5d1fed75d86af53643d7a7aee1d23871"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2666520828dee7dfc7e47ee4ea0d928f40de72056d929a7c5292d95071d881d1"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:333c57013ef8c97a53892aa56042831c372e0bb1785ab7026187b7abd0135ad5"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:288326162804f34088ac007139488dcb43de590a5ccfec3166396530b58fb89d"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b12c39b9448632284561cbf4191aa1b005882acbc81900ffa9f9f471c8ff7e26"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:364e6674450cbac8e998f7b30639040c99d81dfb5bbc6dfad69bc7a8f916b3d1"},
+    {file = "ruff-0.8.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b22346f845fec132aa39cd29acb94451d030c10874408dbf776af3aaeb53284c"},
+    {file = "ruff-0.8.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b2f2f7a7e7648a2bfe6ead4e0a16745db956da0e3a231ad443d2a66a105c04fa"},
+    {file = "ruff-0.8.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:adf314fc458374c25c5c4a4a9270c3e8a6a807b1bec018cfa2813d6546215540"},
+    {file = "ruff-0.8.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a885d68342a231b5ba4d30b8c6e1b1ee3a65cf37e3d29b3c74069cdf1ee1e3c9"},
+    {file = "ruff-0.8.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d2c16e3508c8cc73e96aa5127d0df8913d2290098f776416a4b157657bee44c5"},
+    {file = "ruff-0.8.1-py3-none-win32.whl", hash = "sha256:93335cd7c0eaedb44882d75a7acb7df4b77cd7cd0d2255c93b28791716e81790"},
+    {file = "ruff-0.8.1-py3-none-win_amd64.whl", hash = "sha256:2954cdbe8dfd8ab359d4a30cd971b589d335a44d444b6ca2cb3d1da21b75e4b6"},
+    {file = "ruff-0.8.1-py3-none-win_arm64.whl", hash = "sha256:55873cc1a473e5ac129d15eccb3c008c096b94809d693fc7053f588b67822737"},
+    {file = "ruff-0.8.1.tar.gz", hash = "sha256:3583db9a6450364ed5ca3f3b4225958b24f78178908d5c4bc0f46251ccca898f"},
 ]
 
 [[package]]
@@ -4064,4 +4082,4 @@ sass = ["libsass"]
 [metadata]
 lock-version = "2.0"
 python-versions = "^3.8"
-content-hash = "5d716235e42701f6f4c2b27854990e77dcaf893f023d2cbb4fa2ca486f43637f"
+content-hash = "634ab173d302780c0b42cfd0ee3d69888f71bf24988774c251bb6a4f7a9b4695"

+ 7 - 2
pyproject.toml

@@ -63,8 +63,11 @@ numpy = [
 ]
 selenium = "^4.11.2"
 pyecharts = "^2.0.4"
-ruff = ">=0.3.5"
-pre-commit = ">=3.5.0"
+ruff = ">=0.8.1"
+pre-commit = [
+    {version = "<4.0.0", python = "<3.9"},
+    {version = ">=4.0.0", python = ">=3.9,<3.14"}
+]
 isort = "^5.11"
 polars = [
     {version = "^1.8.0", python = "~3.8"},
@@ -113,6 +116,7 @@ module = [
 ignore_missing_imports = true
 
 [tool.ruff]
+target-version = "py38"
 indent-width = 4
 line-length = 120
 
@@ -130,6 +134,7 @@ select = [
 ]
 fixable = [
     "I",  # isort
+    "RUF022", # `__all__` is not sorted
 ]
 ignore = [
     "E501", # line too long

+ 1 - 1
website/documentation/__init__.py

@@ -11,7 +11,7 @@ __all__ = [
     'create_intro',
     'overview',  # ensure documentation tree is built
     'python_window',
-    'registry',
     'redirects',
+    'registry',
     'render_page',
 ]