瀏覽代碼

enable UP ruff rule (#5137)

* enable UP ruff rule

* fix tests
Khaleel Al-Adhami 1 月之前
父節點
當前提交
642233b141
共有 100 個文件被更改,包括 460 次插入541 次删除
  1. 23 23
      pyi_hashes.json
  2. 2 0
      pyproject.toml
  3. 1 1
      reflex/admin.py
  4. 6 17
      reflex/app.py
  5. 1 1
      reflex/app_mixins/lifespan.py
  6. 2 2
      reflex/base.py
  7. 8 7
      reflex/compiler/compiler.py
  8. 6 5
      reflex/compiler/utils.py
  9. 2 1
      reflex/components/base/bare.py
  10. 20 36
      reflex/components/component.py
  11. 1 1
      reflex/components/core/breakpoints.py
  12. 1 1
      reflex/components/core/clipboard.py
  13. 2 2
      reflex/components/core/cond.py
  14. 3 3
      reflex/components/core/debounce.py
  15. 2 1
      reflex/components/core/foreach.py
  16. 2 2
      reflex/components/core/match.py
  17. 2 1
      reflex/components/core/upload.py
  18. 3 2
      reflex/components/datadisplay/dataeditor.py
  19. 2 1
      reflex/components/el/elements/forms.py
  20. 3 2
      reflex/components/gridjs/datatable.py
  21. 2 1
      reflex/components/markdown/markdown.py
  22. 3 3
      reflex/components/plotly/plotly.py
  23. 2 1
      reflex/components/radix/primitives/accordion.py
  24. 2 1
      reflex/components/radix/primitives/drawer.py
  25. 2 1
      reflex/components/radix/primitives/slider.py
  26. 2 1
      reflex/components/radix/themes/components/checkbox_group.py
  27. 2 1
      reflex/components/radix/themes/components/radio_group.py
  28. 2 1
      reflex/components/radix/themes/components/segmented_control.py
  29. 2 1
      reflex/components/radix/themes/components/select.py
  30. 2 1
      reflex/components/radix/themes/components/slider.py
  31. 2 2
      reflex/components/radix/themes/components/tooltip.py
  32. 2 1
      reflex/components/radix/themes/layout/list.py
  33. 7 6
      reflex/components/recharts/cartesian.py
  34. 2 1
      reflex/components/recharts/charts.py
  35. 3 2
      reflex/components/recharts/general.py
  36. 9 8
      reflex/components/recharts/polar.py
  37. 22 24
      reflex/components/suneditor/editor.py
  38. 3 3
      reflex/components/tags/cond_tag.py
  39. 2 1
      reflex/components/tags/iter_tag.py
  40. 3 2
      reflex/components/tags/tag.py
  41. 2 2
      reflex/config.py
  42. 2 3
      reflex/constants/route.py
  43. 4 3
      reflex/constants/utils.py
  44. 6 8
      reflex/event.py
  45. 3 2
      reflex/experimental/client_state.py
  46. 1 1
      reflex/istate/data.py
  47. 2 2
      reflex/istate/storage.py
  48. 3 3
      reflex/model.py
  49. 3 2
      reflex/page.py
  50. 53 56
      reflex/state.py
  51. 3 2
      reflex/style.py
  52. 12 21
      reflex/testing.py
  53. 14 15
      reflex/utils/codespaces.py
  54. 2 1
      reflex/utils/decorator.py
  55. 1 1
      reflex/utils/exec.py
  56. 2 2
      reflex/utils/format.py
  57. 6 8
      reflex/utils/imports.py
  58. 2 1
      reflex/utils/misc.py
  59. 2 1
      reflex/utils/net.py
  60. 3 2
      reflex/utils/prerequisites.py
  61. 6 5
      reflex/utils/processes.py
  62. 6 5
      reflex/utils/pyi_generator.py
  63. 13 25
      reflex/utils/serializers.py
  64. 27 33
      reflex/utils/types.py
  65. 49 55
      reflex/vars/base.py
  66. 4 4
      reflex/vars/dep_tracking.py
  67. 3 13
      reflex/vars/function.py
  68. 5 17
      reflex/vars/number.py
  69. 7 15
      reflex/vars/object.py
  70. 11 23
      reflex/vars/sequence.py
  71. 1 1
      tests/benchmarks/test_evaluate.py
  72. 1 1
      tests/integration/test_background_task.py
  73. 3 8
      tests/integration/test_call_script.py
  74. 1 1
      tests/integration/test_client_storage.py
  75. 1 1
      tests/integration/test_component_state.py
  76. 1 1
      tests/integration/test_computed_vars.py
  77. 1 1
      tests/integration/test_connection_banner.py
  78. 1 1
      tests/integration/test_deploy_url.py
  79. 2 1
      tests/integration/test_dynamic_components.py
  80. 2 2
      tests/integration/test_dynamic_routes.py
  81. 1 1
      tests/integration/test_event_actions.py
  82. 1 1
      tests/integration/test_event_chain.py
  83. 2 2
      tests/integration/test_exception_handlers.py
  84. 1 1
      tests/integration/test_extra_overlay_function.py
  85. 1 1
      tests/integration/test_form_submit.py
  86. 1 1
      tests/integration/test_icon.py
  87. 1 1
      tests/integration/test_input.py
  88. 1 1
      tests/integration/test_lifespan.py
  89. 1 1
      tests/integration/test_login_flow.py
  90. 1 1
      tests/integration/test_media.py
  91. 1 1
      tests/integration/test_memo.py
  92. 1 1
      tests/integration/test_navigation.py
  93. 1 1
      tests/integration/test_server_side_event.py
  94. 1 1
      tests/integration/test_shared_state.py
  95. 1 1
      tests/integration/test_state_inheritance.py
  96. 1 1
      tests/integration/test_tailwind.py
  97. 1 1
      tests/integration/test_upload.py
  98. 1 1
      tests/integration/test_var_operations.py
  99. 1 1
      tests/integration/tests_playwright/test_appearance.py
  100. 1 1
      tests/integration/tests_playwright/test_datetime_operations.py

+ 23 - 23
pyi_hashes.json

@@ -16,20 +16,20 @@
   "reflex/components/core/auto_scroll.pyi": "d3012d2a4ccaab8dfebf9aa484020f59",
   "reflex/components/core/auto_scroll.pyi": "d3012d2a4ccaab8dfebf9aa484020f59",
   "reflex/components/core/banner.pyi": "48d0eb86ae09e806ebe20d0edcc3cdb3",
   "reflex/components/core/banner.pyi": "48d0eb86ae09e806ebe20d0edcc3cdb3",
   "reflex/components/core/client_side_routing.pyi": "9be638a2b0e00b8181697e5dd6b45e4e",
   "reflex/components/core/client_side_routing.pyi": "9be638a2b0e00b8181697e5dd6b45e4e",
-  "reflex/components/core/clipboard.pyi": "af76b623d593df3b16162033c597f920",
-  "reflex/components/core/debounce.pyi": "76d857eb814bc64625860a5f43e8b230",
+  "reflex/components/core/clipboard.pyi": "4098368af3c32dbde77fc74599f8799a",
+  "reflex/components/core/debounce.pyi": "affda049624c266c7d5620efa3b7041b",
   "reflex/components/core/html.pyi": "b12117b42ef79ee90b6b4dec50baeb86",
   "reflex/components/core/html.pyi": "b12117b42ef79ee90b6b4dec50baeb86",
   "reflex/components/core/sticky.pyi": "c65131cf7c2312c68e1fddaa0cc27150",
   "reflex/components/core/sticky.pyi": "c65131cf7c2312c68e1fddaa0cc27150",
-  "reflex/components/core/upload.pyi": "16bf18a95d830184a1ae6c177e91e529",
+  "reflex/components/core/upload.pyi": "53e06193fa23a603737bc49b1c6c2565",
   "reflex/components/datadisplay/__init__.pyi": "cf087efa8b3960decc6b231cc986cfa9",
   "reflex/components/datadisplay/__init__.pyi": "cf087efa8b3960decc6b231cc986cfa9",
   "reflex/components/datadisplay/code.pyi": "3d8f0ab4c2f123d7f80d15c7ebc553d9",
   "reflex/components/datadisplay/code.pyi": "3d8f0ab4c2f123d7f80d15c7ebc553d9",
-  "reflex/components/datadisplay/dataeditor.pyi": "1b762071001161e4fdd1285263c33bb3",
+  "reflex/components/datadisplay/dataeditor.pyi": "cb03d732e2fe771a8d46c7bcda671f92",
   "reflex/components/datadisplay/shiki_code_block.pyi": "87db7639bfa5cd53e1709e1363f93278",
   "reflex/components/datadisplay/shiki_code_block.pyi": "87db7639bfa5cd53e1709e1363f93278",
   "reflex/components/el/__init__.pyi": "09042a2db5e0637e99b5173430600522",
   "reflex/components/el/__init__.pyi": "09042a2db5e0637e99b5173430600522",
   "reflex/components/el/element.pyi": "06ac2213b062119323291fa66a1ac19e",
   "reflex/components/el/element.pyi": "06ac2213b062119323291fa66a1ac19e",
   "reflex/components/el/elements/__init__.pyi": "280ed457675f3720e34b560a3f617739",
   "reflex/components/el/elements/__init__.pyi": "280ed457675f3720e34b560a3f617739",
   "reflex/components/el/elements/base.pyi": "6e533348b5e1a88cf62fbb5a38dbd795",
   "reflex/components/el/elements/base.pyi": "6e533348b5e1a88cf62fbb5a38dbd795",
-  "reflex/components/el/elements/forms.pyi": "2e7ab39bc7295b8594f38a2aa59c9610",
+  "reflex/components/el/elements/forms.pyi": "161f1ef847e5da8755528a7977fdcf53",
   "reflex/components/el/elements/inline.pyi": "33d9d860e75dd8c4769825127ed363bb",
   "reflex/components/el/elements/inline.pyi": "33d9d860e75dd8c4769825127ed363bb",
   "reflex/components/el/elements/media.pyi": "addd6872281d65d44a484358b895432f",
   "reflex/components/el/elements/media.pyi": "addd6872281d65d44a484358b895432f",
   "reflex/components/el/elements/metadata.pyi": "974a86d9f0662f6fc15a5bb4b3a87862",
   "reflex/components/el/elements/metadata.pyi": "974a86d9f0662f6fc15a5bb4b3a87862",
@@ -38,23 +38,23 @@
   "reflex/components/el/elements/sectioning.pyi": "65aa53b1372598ec1785616cb7016032",
   "reflex/components/el/elements/sectioning.pyi": "65aa53b1372598ec1785616cb7016032",
   "reflex/components/el/elements/tables.pyi": "e1282d8ddf4efa4c911ca104a907ee88",
   "reflex/components/el/elements/tables.pyi": "e1282d8ddf4efa4c911ca104a907ee88",
   "reflex/components/el/elements/typography.pyi": "00088c9c1b68a14e5a41d837e8fdf542",
   "reflex/components/el/elements/typography.pyi": "00088c9c1b68a14e5a41d837e8fdf542",
-  "reflex/components/gridjs/datatable.pyi": "7fd1dd65ba143d60b7d42d1bb90a179d",
+  "reflex/components/gridjs/datatable.pyi": "3db3f994640c19be5c3fa2983f71de56",
   "reflex/components/lucide/icon.pyi": "a5521a8baf8d2d7281e3fdfe6ce7073b",
   "reflex/components/lucide/icon.pyi": "a5521a8baf8d2d7281e3fdfe6ce7073b",
-  "reflex/components/markdown/markdown.pyi": "f2d0cbff02e0a26f201287fabe6fb738",
+  "reflex/components/markdown/markdown.pyi": "6b268afa879e33abf651bda56be5065e",
   "reflex/components/moment/moment.pyi": "6dd0c7cee5f0f29bc11d830c697d7f92",
   "reflex/components/moment/moment.pyi": "6dd0c7cee5f0f29bc11d830c697d7f92",
   "reflex/components/next/base.pyi": "14aafd5b018a4bc9748a3c9980fcfe3e",
   "reflex/components/next/base.pyi": "14aafd5b018a4bc9748a3c9980fcfe3e",
   "reflex/components/next/image.pyi": "3a0d1970e69144e9c6806e68ab99f181",
   "reflex/components/next/image.pyi": "3a0d1970e69144e9c6806e68ab99f181",
   "reflex/components/next/link.pyi": "cd913e10205314afe67101d9640e05cb",
   "reflex/components/next/link.pyi": "cd913e10205314afe67101d9640e05cb",
   "reflex/components/next/video.pyi": "09698418db651917630a7fefeb573fc2",
   "reflex/components/next/video.pyi": "09698418db651917630a7fefeb573fc2",
-  "reflex/components/plotly/plotly.pyi": "77afe88b405c3eae7058994d53a27946",
+  "reflex/components/plotly/plotly.pyi": "b1f0bbcaf4706d0a373c99395ba50118",
   "reflex/components/radix/__init__.pyi": "8d586cbff1d7130d09476ac72ee73400",
   "reflex/components/radix/__init__.pyi": "8d586cbff1d7130d09476ac72ee73400",
   "reflex/components/radix/primitives/__init__.pyi": "fe8715decf3e9ae471b56bba14e42cb3",
   "reflex/components/radix/primitives/__init__.pyi": "fe8715decf3e9ae471b56bba14e42cb3",
-  "reflex/components/radix/primitives/accordion.pyi": "b1482766c3c99ab40c2f446598fdb6a7",
+  "reflex/components/radix/primitives/accordion.pyi": "54427d58c5e1498ad2c6189214bba28a",
   "reflex/components/radix/primitives/base.pyi": "8b1dbf0b75cb29e873d611b83c9e4156",
   "reflex/components/radix/primitives/base.pyi": "8b1dbf0b75cb29e873d611b83c9e4156",
-  "reflex/components/radix/primitives/drawer.pyi": "b6f8b17e1d0064d5609915546c722a81",
+  "reflex/components/radix/primitives/drawer.pyi": "95cc7c2fdc5407f8ceca06199d4503fa",
   "reflex/components/radix/primitives/form.pyi": "79ddb679e0b3df814439ce993fcf355e",
   "reflex/components/radix/primitives/form.pyi": "79ddb679e0b3df814439ce993fcf355e",
   "reflex/components/radix/primitives/progress.pyi": "c62a0c44e0d440701174fcca93bf8fbe",
   "reflex/components/radix/primitives/progress.pyi": "c62a0c44e0d440701174fcca93bf8fbe",
-  "reflex/components/radix/primitives/slider.pyi": "c27e1a1180442e2e6e9d727560e8068c",
+  "reflex/components/radix/primitives/slider.pyi": "10196fb967c9cde3860a930a526b6c51",
   "reflex/components/radix/themes/__init__.pyi": "a15f9464ad99f248249ffa8e6deea4cf",
   "reflex/components/radix/themes/__init__.pyi": "a15f9464ad99f248249ffa8e6deea4cf",
   "reflex/components/radix/themes/base.pyi": "a3c3c3b72fd3d8f1e38990e5c461b682",
   "reflex/components/radix/themes/base.pyi": "a3c3c3b72fd3d8f1e38990e5c461b682",
   "reflex/components/radix/themes/color_mode.pyi": "435a51382eab6111aae1b26e79e9a473",
   "reflex/components/radix/themes/color_mode.pyi": "435a51382eab6111aae1b26e79e9a473",
@@ -68,7 +68,7 @@
   "reflex/components/radix/themes/components/card.pyi": "fe42e0cbdf9eb34341f4bbba8a586b34",
   "reflex/components/radix/themes/components/card.pyi": "fe42e0cbdf9eb34341f4bbba8a586b34",
   "reflex/components/radix/themes/components/checkbox.pyi": "78bc26eabd6468a44f5139449a2c6208",
   "reflex/components/radix/themes/components/checkbox.pyi": "78bc26eabd6468a44f5139449a2c6208",
   "reflex/components/radix/themes/components/checkbox_cards.pyi": "cc43c568aa42ffa3e693e5cd1acba156",
   "reflex/components/radix/themes/components/checkbox_cards.pyi": "cc43c568aa42ffa3e693e5cd1acba156",
-  "reflex/components/radix/themes/components/checkbox_group.pyi": "e36603b9ea5f161070c5a0235c4411fa",
+  "reflex/components/radix/themes/components/checkbox_group.pyi": "b798c7cca10f4493484dc1621c0eed9c",
   "reflex/components/radix/themes/components/context_menu.pyi": "cdf546723a84c99412d91ca63d4bb2df",
   "reflex/components/radix/themes/components/context_menu.pyi": "cdf546723a84c99412d91ca63d4bb2df",
   "reflex/components/radix/themes/components/data_list.pyi": "768e4c9222d37d90228309166a1c6ab3",
   "reflex/components/radix/themes/components/data_list.pyi": "768e4c9222d37d90228309166a1c6ab3",
   "reflex/components/radix/themes/components/dialog.pyi": "b51cb34dc6c90ccd07a2f9fc97eaf1c1",
   "reflex/components/radix/themes/components/dialog.pyi": "b51cb34dc6c90ccd07a2f9fc97eaf1c1",
@@ -80,20 +80,20 @@
   "reflex/components/radix/themes/components/progress.pyi": "c880c6bb9803d47048f656dfa66a7c15",
   "reflex/components/radix/themes/components/progress.pyi": "c880c6bb9803d47048f656dfa66a7c15",
   "reflex/components/radix/themes/components/radio.pyi": "36fa5585440685a7d2dff40b50502840",
   "reflex/components/radix/themes/components/radio.pyi": "36fa5585440685a7d2dff40b50502840",
   "reflex/components/radix/themes/components/radio_cards.pyi": "e9a0f27119322e6148946ae178edb7a9",
   "reflex/components/radix/themes/components/radio_cards.pyi": "e9a0f27119322e6148946ae178edb7a9",
-  "reflex/components/radix/themes/components/radio_group.pyi": "ea3180940390e4b6eaf10670be5bc2fe",
+  "reflex/components/radix/themes/components/radio_group.pyi": "510e2ac6aebec248c275f4ddb25940a9",
   "reflex/components/radix/themes/components/scroll_area.pyi": "83892be0b2c902d2147cbdb5e19310ab",
   "reflex/components/radix/themes/components/scroll_area.pyi": "83892be0b2c902d2147cbdb5e19310ab",
-  "reflex/components/radix/themes/components/segmented_control.pyi": "7be200991becc54cd885465656e2dfef",
-  "reflex/components/radix/themes/components/select.pyi": "655a5c2182a16121440e5ddbba2079d8",
+  "reflex/components/radix/themes/components/segmented_control.pyi": "ee1b8cb2cada89459d17a186206f3c3a",
+  "reflex/components/radix/themes/components/select.pyi": "869d36f7a20b466bc15c634c7c0ee0dd",
   "reflex/components/radix/themes/components/separator.pyi": "58a95aca75a556d349eb56f898bde680",
   "reflex/components/radix/themes/components/separator.pyi": "58a95aca75a556d349eb56f898bde680",
   "reflex/components/radix/themes/components/skeleton.pyi": "d91615706e5efb81d97755decbbf5ae3",
   "reflex/components/radix/themes/components/skeleton.pyi": "d91615706e5efb81d97755decbbf5ae3",
-  "reflex/components/radix/themes/components/slider.pyi": "b87ee08b7edfe41eddf3d3c1cb71124e",
+  "reflex/components/radix/themes/components/slider.pyi": "8caaea62efdd0b4b9878a63620c97632",
   "reflex/components/radix/themes/components/spinner.pyi": "80766a7324b582221edb66ec46da0acb",
   "reflex/components/radix/themes/components/spinner.pyi": "80766a7324b582221edb66ec46da0acb",
   "reflex/components/radix/themes/components/switch.pyi": "f8256d2b50d15ab163649cfb05229750",
   "reflex/components/radix/themes/components/switch.pyi": "f8256d2b50d15ab163649cfb05229750",
   "reflex/components/radix/themes/components/table.pyi": "560ce8d920e03b450fe6b938f5f0fea0",
   "reflex/components/radix/themes/components/table.pyi": "560ce8d920e03b450fe6b938f5f0fea0",
   "reflex/components/radix/themes/components/tabs.pyi": "96ac1082651d2adc2a60a3af6e90c17f",
   "reflex/components/radix/themes/components/tabs.pyi": "96ac1082651d2adc2a60a3af6e90c17f",
   "reflex/components/radix/themes/components/text_area.pyi": "418d3df53eeca0723d83a93d81f16b12",
   "reflex/components/radix/themes/components/text_area.pyi": "418d3df53eeca0723d83a93d81f16b12",
   "reflex/components/radix/themes/components/text_field.pyi": "cdf0e08f5af0a5fce6b31787001f1dc3",
   "reflex/components/radix/themes/components/text_field.pyi": "cdf0e08f5af0a5fce6b31787001f1dc3",
-  "reflex/components/radix/themes/components/tooltip.pyi": "6cd225ba10140e925752c74404336f27",
+  "reflex/components/radix/themes/components/tooltip.pyi": "c37fb988ec52da25be83083c3a85524a",
   "reflex/components/radix/themes/layout/__init__.pyi": "9a52c5b283c864be70b51a8fd6120392",
   "reflex/components/radix/themes/layout/__init__.pyi": "9a52c5b283c864be70b51a8fd6120392",
   "reflex/components/radix/themes/layout/base.pyi": "e9a5c1f376e66653ebcf5d2315f990f8",
   "reflex/components/radix/themes/layout/base.pyi": "e9a5c1f376e66653ebcf5d2315f990f8",
   "reflex/components/radix/themes/layout/box.pyi": "5a3c2339d74cc062358ec32b2c2c138c",
   "reflex/components/radix/themes/layout/box.pyi": "5a3c2339d74cc062358ec32b2c2c138c",
@@ -101,7 +101,7 @@
   "reflex/components/radix/themes/layout/container.pyi": "4020c3dca660027b84d11cc4198393c4",
   "reflex/components/radix/themes/layout/container.pyi": "4020c3dca660027b84d11cc4198393c4",
   "reflex/components/radix/themes/layout/flex.pyi": "f814281a5635ad43dd1df23f8e356c66",
   "reflex/components/radix/themes/layout/flex.pyi": "f814281a5635ad43dd1df23f8e356c66",
   "reflex/components/radix/themes/layout/grid.pyi": "6062188367a2c253f014f916197c963d",
   "reflex/components/radix/themes/layout/grid.pyi": "6062188367a2c253f014f916197c963d",
-  "reflex/components/radix/themes/layout/list.pyi": "804f7a36c103cd7a3e362d40a58e8d39",
+  "reflex/components/radix/themes/layout/list.pyi": "0e91d3f1c82c9094f328e5b8ecd2f60a",
   "reflex/components/radix/themes/layout/section.pyi": "41895910072e023ed0fef6a8ad956046",
   "reflex/components/radix/themes/layout/section.pyi": "41895910072e023ed0fef6a8ad956046",
   "reflex/components/radix/themes/layout/spacer.pyi": "029eb0eaa731bcdff7c496e0437e22b1",
   "reflex/components/radix/themes/layout/spacer.pyi": "029eb0eaa731bcdff7c496e0437e22b1",
   "reflex/components/radix/themes/layout/stack.pyi": "3b0da99b00c826d087ed89fc67c595c1",
   "reflex/components/radix/themes/layout/stack.pyi": "3b0da99b00c826d087ed89fc67c595c1",
@@ -115,12 +115,12 @@
   "reflex/components/react_player/react_player.pyi": "63ffffbc24907103f797dcfd85894107",
   "reflex/components/react_player/react_player.pyi": "63ffffbc24907103f797dcfd85894107",
   "reflex/components/react_player/video.pyi": "35ce5ad62e8bff17d9c09d27c362f8dc",
   "reflex/components/react_player/video.pyi": "35ce5ad62e8bff17d9c09d27c362f8dc",
   "reflex/components/recharts/__init__.pyi": "a52c9055e37c6ee25ded15688d45e8a5",
   "reflex/components/recharts/__init__.pyi": "a52c9055e37c6ee25ded15688d45e8a5",
-  "reflex/components/recharts/cartesian.pyi": "34b15e8f5125b5a8145e3e04ed6418e4",
-  "reflex/components/recharts/charts.pyi": "b3d35de9cea86307ad2ab7d69ff2d06b",
-  "reflex/components/recharts/general.pyi": "5548fc494c29063c262ca7a7ef51dce8",
-  "reflex/components/recharts/polar.pyi": "8fb87fd69c9edf55998f11ea8ada76fb",
+  "reflex/components/recharts/cartesian.pyi": "9dd16c08abe5205c6c414474e2de2f79",
+  "reflex/components/recharts/charts.pyi": "3570af4627c601d10ee37033f1b2329c",
+  "reflex/components/recharts/general.pyi": "a1b846d5f2fd0a8b1969b472c5cab2e7",
+  "reflex/components/recharts/polar.pyi": "973c3e6aa253914c4c5fd18ed32196fb",
   "reflex/components/recharts/recharts.pyi": "157acc830323075ffaf4f68d495d1787",
   "reflex/components/recharts/recharts.pyi": "157acc830323075ffaf4f68d495d1787",
   "reflex/components/sonner/toast.pyi": "0b6dc33413f30fdd043b89ec3c8c3f39",
   "reflex/components/sonner/toast.pyi": "0b6dc33413f30fdd043b89ec3c8c3f39",
-  "reflex/components/suneditor/editor.pyi": "284aa914b9bffe840db67ee68192eaf7",
+  "reflex/components/suneditor/editor.pyi": "7d94c3587f9ee15e4ab68aca8c3a6d8b",
   "reflex/experimental/layout.pyi": "6398e779743963ef3e03396696b8ddfb"
   "reflex/experimental/layout.pyi": "6398e779743963ef3e03396696b8ddfb"
 }
 }

+ 2 - 0
pyproject.toml

@@ -103,6 +103,7 @@ lint.select = [
   "SIM",
   "SIM",
   "T",
   "T",
   "TRY",
   "TRY",
+  "UP",
   "W",
   "W",
 ]
 ]
 lint.ignore = [
 lint.ignore = [
@@ -115,6 +116,7 @@ lint.ignore = [
   "RUF008",
   "RUF008",
   "RUF012",
   "RUF012",
   "TRY0",
   "TRY0",
+  "UP038",
 ]
 ]
 lint.pydocstyle.convention = "google"
 lint.pydocstyle.convention = "google"
 
 

+ 1 - 1
reflex/admin.py

@@ -15,4 +15,4 @@ class AdminDash:
 
 
     models: list = field(default_factory=list)
     models: list = field(default_factory=list)
     view_overrides: dict = field(default_factory=dict)
     view_overrides: dict = field(default_factory=dict)
-    admin: "Admin | None" = None
+    admin: Admin | None = None

+ 6 - 17
reflex/app.py

@@ -13,23 +13,12 @@ import io
 import json
 import json
 import sys
 import sys
 import traceback
 import traceback
+from collections.abc import AsyncIterator, Callable, Coroutine, MutableMapping
 from datetime import datetime
 from datetime import datetime
 from pathlib import Path
 from pathlib import Path
 from timeit import default_timer as timer
 from timeit import default_timer as timer
 from types import SimpleNamespace
 from types import SimpleNamespace
-from typing import (
-    TYPE_CHECKING,
-    Any,
-    AsyncIterator,
-    BinaryIO,
-    Callable,
-    Coroutine,
-    Dict,
-    MutableMapping,
-    Type,
-    get_args,
-    get_type_hints,
-)
+from typing import TYPE_CHECKING, Any, BinaryIO, get_args, get_type_hints
 
 
 from fastapi import FastAPI, HTTPException, Request
 from fastapi import FastAPI, HTTPException, Request
 from fastapi import UploadFile as FastAPIUploadFile
 from fastapi import UploadFile as FastAPIUploadFile
@@ -373,13 +362,13 @@ class App(MiddlewareMixin, LifespanMixin):
     _pages: dict[str, Component] = dataclasses.field(default_factory=dict)
     _pages: dict[str, Component] = dataclasses.field(default_factory=dict)
 
 
     # A mapping of pages which created states as they were being evaluated.
     # A mapping of pages which created states as they were being evaluated.
-    _stateful_pages: Dict[str, None] = dataclasses.field(default_factory=dict)
+    _stateful_pages: dict[str, None] = dataclasses.field(default_factory=dict)
 
 
     # The backend API object.
     # The backend API object.
     _api: FastAPI | None = None
     _api: FastAPI | None = None
 
 
     # The state class to use for the app.
     # The state class to use for the app.
-    _state: Type[BaseState] | None = None
+    _state: type[BaseState] | None = None
 
 
     # Class to manage many client states.
     # Class to manage many client states.
     _state_manager: StateManager | None = None
     _state_manager: StateManager | None = None
@@ -1036,7 +1025,7 @@ class App(MiddlewareMixin, LifespanMixin):
         for render, kwargs in DECORATED_PAGES[get_config().app_name]:
         for render, kwargs in DECORATED_PAGES[get_config().app_name]:
             self.add_page(render, **kwargs)
             self.add_page(render, **kwargs)
 
 
-    def _validate_var_dependencies(self, state: Type[BaseState] | None = None) -> None:
+    def _validate_var_dependencies(self, state: type[BaseState] | None = None) -> None:
         """Validate the dependencies of the vars in the app.
         """Validate the dependencies of the vars in the app.
 
 
         Args:
         Args:
@@ -1591,7 +1580,7 @@ class App(MiddlewareMixin, LifespanMixin):
 
 
 
 
 async def process(
 async def process(
-    app: App, event: Event, sid: str, headers: Dict, client_ip: str
+    app: App, event: Event, sid: str, headers: dict, client_ip: str
 ) -> AsyncIterator[StateUpdate]:
 ) -> AsyncIterator[StateUpdate]:
     """Process an event.
     """Process an event.
 
 

+ 1 - 1
reflex/app_mixins/lifespan.py

@@ -7,7 +7,7 @@ import contextlib
 import dataclasses
 import dataclasses
 import functools
 import functools
 import inspect
 import inspect
-from typing import Callable, Coroutine
+from collections.abc import Callable, Coroutine
 
 
 from fastapi import FastAPI
 from fastapi import FastAPI
 
 

+ 2 - 2
reflex/base.py

@@ -3,14 +3,14 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import os
 import os
-from typing import TYPE_CHECKING, Any, Type
+from typing import TYPE_CHECKING, Any
 
 
 import pydantic.v1.main as pydantic_main
 import pydantic.v1.main as pydantic_main
 from pydantic.v1 import BaseModel
 from pydantic.v1 import BaseModel
 from pydantic.v1.fields import ModelField
 from pydantic.v1.fields import ModelField
 
 
 
 
-def validate_field_name(bases: list[Type["BaseModel"]], field_name: str) -> None:
+def validate_field_name(bases: list[type[BaseModel]], field_name: str) -> None:
     """Ensure that the field's name does not shadow an existing attribute of the model.
     """Ensure that the field's name does not shadow an existing attribute of the model.
 
 
     Args:
     Args:

+ 8 - 7
reflex/compiler/compiler.py

@@ -2,9 +2,10 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from collections.abc import Iterable, Sequence
 from datetime import datetime
 from datetime import datetime
 from pathlib import Path
 from pathlib import Path
-from typing import TYPE_CHECKING, Iterable, Sequence, Type
+from typing import TYPE_CHECKING
 
 
 from reflex import constants
 from reflex import constants
 from reflex.compiler import templates, utils
 from reflex.compiler import templates, utils
@@ -97,7 +98,7 @@ def _compile_theme(theme: str) -> str:
     return templates.THEME.render(theme=theme)
     return templates.THEME.render(theme=theme)
 
 
 
 
-def _compile_contexts(state: Type[BaseState] | None, theme: Component | None) -> str:
+def _compile_contexts(state: type[BaseState] | None, theme: Component | None) -> str:
     """Compile the initial state and contexts.
     """Compile the initial state and contexts.
 
 
     Args:
     Args:
@@ -132,7 +133,7 @@ def _compile_contexts(state: Type[BaseState] | None, theme: Component | None) ->
 
 
 def _compile_page(
 def _compile_page(
     component: BaseComponent,
     component: BaseComponent,
-    state: Type[BaseState] | None,
+    state: type[BaseState] | None,
 ) -> str:
 ) -> str:
     """Compile the component given the app state.
     """Compile the component given the app state.
 
 
@@ -516,7 +517,7 @@ def compile_theme(style: ComponentStyle) -> tuple[str, str]:
 
 
 
 
 def compile_contexts(
 def compile_contexts(
-    state: Type[BaseState] | None,
+    state: type[BaseState] | None,
     theme: Component | None,
     theme: Component | None,
 ) -> tuple[str, str]:
 ) -> tuple[str, str]:
     """Compile the initial state / context.
     """Compile the initial state / context.
@@ -535,7 +536,7 @@ def compile_contexts(
 
 
 
 
 def compile_page(
 def compile_page(
-    path: str, component: BaseComponent, state: Type[BaseState] | None
+    path: str, component: BaseComponent, state: type[BaseState] | None
 ) -> tuple[str, str]:
 ) -> tuple[str, str]:
     """Compile a single page.
     """Compile a single page.
 
 
@@ -739,7 +740,7 @@ def into_component(component: Component | ComponentCallable) -> Component:
 def compile_unevaluated_page(
 def compile_unevaluated_page(
     route: str,
     route: str,
     page: UnevaluatedPage,
     page: UnevaluatedPage,
-    state: Type[BaseState] | None = None,
+    state: type[BaseState] | None = None,
     style: ComponentStyle | None = None,
     style: ComponentStyle | None = None,
     theme: Component | None = None,
     theme: Component | None = None,
 ) -> tuple[Component, bool]:
 ) -> tuple[Component, bool]:
@@ -829,7 +830,7 @@ class ExecutorSafeFunctions:
 
 
     COMPONENTS: dict[str, BaseComponent] = {}
     COMPONENTS: dict[str, BaseComponent] = {}
     UNCOMPILED_PAGES: dict[str, UnevaluatedPage] = {}
     UNCOMPILED_PAGES: dict[str, UnevaluatedPage] = {}
-    STATE: Type[BaseState] | None = None
+    STATE: type[BaseState] | None = None
 
 
     @classmethod
     @classmethod
     def compile_page(cls, route: str) -> tuple[str, str]:
     def compile_page(cls, route: str) -> tuple[str, str]:

+ 6 - 5
reflex/compiler/utils.py

@@ -5,9 +5,10 @@ from __future__ import annotations
 import asyncio
 import asyncio
 import concurrent.futures
 import concurrent.futures
 import traceback
 import traceback
+from collections.abc import Sequence
 from datetime import datetime
 from datetime import datetime
 from pathlib import Path
 from pathlib import Path
-from typing import Any, Sequence, Type
+from typing import Any
 from urllib.parse import urlparse
 from urllib.parse import urlparse
 
 
 from pydantic.v1.fields import ModelField
 from pydantic.v1.fields import ModelField
@@ -178,7 +179,7 @@ def save_error(error: Exception) -> str:
     return str(log_path)
     return str(log_path)
 
 
 
 
-def compile_state(state: Type[BaseState]) -> dict:
+def compile_state(state: type[BaseState]) -> dict:
     """Compile the state of the app.
     """Compile the state of the app.
 
 
     Args:
     Args:
@@ -211,7 +212,7 @@ def compile_state(state: Type[BaseState]) -> dict:
 def _compile_client_storage_field(
 def _compile_client_storage_field(
     field: ModelField,
     field: ModelField,
 ) -> tuple[
 ) -> tuple[
-    Type[Cookie] | Type[LocalStorage] | Type[SessionStorage] | None,
+    type[Cookie] | type[LocalStorage] | type[SessionStorage] | None,
     dict[str, Any] | None,
     dict[str, Any] | None,
 ]:
 ]:
     """Compile the given cookie, local_storage or session_storage field.
     """Compile the given cookie, local_storage or session_storage field.
@@ -234,7 +235,7 @@ def _compile_client_storage_field(
 
 
 
 
 def _compile_client_storage_recursive(
 def _compile_client_storage_recursive(
-    state: Type[BaseState],
+    state: type[BaseState],
 ) -> tuple[dict[str, dict], dict[str, dict], dict[str, dict]]:
 ) -> tuple[dict[str, dict], dict[str, dict], dict[str, dict]]:
     """Compile the client-side storage for the given state recursively.
     """Compile the client-side storage for the given state recursively.
 
 
@@ -279,7 +280,7 @@ def _compile_client_storage_recursive(
     return cookies, local_storage, session_storage
     return cookies, local_storage, session_storage
 
 
 
 
-def compile_client_storage(state: Type[BaseState]) -> dict[str, dict]:
+def compile_client_storage(state: type[BaseState]) -> dict[str, dict]:
     """Compile the client-side storage for the given state.
     """Compile the client-side storage for the given state.
 
 
     Args:
     Args:

+ 2 - 1
reflex/components/base/bare.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Iterator, Sequence
+from collections.abc import Iterator, Sequence
+from typing import Any
 
 
 from reflex.components.component import BaseComponent, Component, ComponentStyle
 from reflex.components.component import BaseComponent, Component, ComponentStyle
 from reflex.components.tags import Tag
 from reflex.components.tags import Tag

+ 20 - 36
reflex/components/component.py

@@ -9,25 +9,11 @@ import functools
 import inspect
 import inspect
 import typing
 import typing
 from abc import ABC, abstractmethod
 from abc import ABC, abstractmethod
-from functools import lru_cache, wraps
+from collections.abc import Callable, Iterator, Mapping, Sequence
+from functools import wraps
 from hashlib import md5
 from hashlib import md5
 from types import SimpleNamespace
 from types import SimpleNamespace
-from typing import (
-    Any,
-    Callable,
-    ClassVar,
-    Iterator,
-    List,
-    Mapping,
-    Sequence,
-    Set,
-    Type,
-    TypeVar,
-    Union,
-    cast,
-    get_args,
-    get_origin,
-)
+from typing import Any, ClassVar, TypeVar, cast, get_args, get_origin
 
 
 import pydantic.v1
 import pydantic.v1
 from rich.markup import escape
 from rich.markup import escape
@@ -180,7 +166,7 @@ def evaluate_style_namespaces(style: ComponentStyle) -> dict:
 
 
 
 
 # Map from component to styling.
 # Map from component to styling.
-ComponentStyle = dict[str | Type[BaseComponent] | Callable | ComponentNamespace, Any]
+ComponentStyle = dict[str | type[BaseComponent] | Callable | ComponentNamespace, Any]
 ComponentChild = types.PrimitiveType | Var | BaseComponent
 ComponentChild = types.PrimitiveType | Var | BaseComponent
 ComponentChildTypes = (*types.PrimitiveTypes, Var, BaseComponent, type(None))
 ComponentChildTypes = (*types.PrimitiveTypes, Var, BaseComponent, type(None))
 
 
@@ -227,7 +213,7 @@ def satisfies_type_hint(obj: Any, type_hint: Any) -> bool:
 
 
 
 
 def _components_from(
 def _components_from(
-    component_or_var: Union[BaseComponent, Var],
+    component_or_var: BaseComponent | Var,
 ) -> tuple[BaseComponent, ...]:
 ) -> tuple[BaseComponent, ...]:
     """Get the components from a component or Var.
     """Get the components from a component or Var.
 
 
@@ -317,7 +303,7 @@ class Component(BaseComponent, ABC):
     _memoization_mode: MemoizationMode = MemoizationMode()
     _memoization_mode: MemoizationMode = MemoizationMode()
 
 
     # State class associated with this component instance
     # State class associated with this component instance
-    State: Type[reflex.state.State] | None = pydantic.v1.Field(
+    State: type[reflex.state.State] | None = pydantic.v1.Field(
         default_factory=lambda: None
         default_factory=lambda: None
     )
     )
 
 
@@ -611,7 +597,7 @@ class Component(BaseComponent, ABC):
 
 
         # Convert class_name to str if it's list
         # Convert class_name to str if it's list
         class_name = kwargs.get("class_name", "")
         class_name = kwargs.get("class_name", "")
-        if isinstance(class_name, (List, tuple)):
+        if isinstance(class_name, (list, tuple)):
             if any(isinstance(c, Var) for c in class_name):
             if any(isinstance(c, Var) for c in class_name):
                 kwargs["class_name"] = LiteralArrayVar.create(
                 kwargs["class_name"] = LiteralArrayVar.create(
                     class_name, _var_type=list[str]
                     class_name, _var_type=list[str]
@@ -717,7 +703,7 @@ class Component(BaseComponent, ABC):
         return tag.add_props(**props)
         return tag.add_props(**props)
 
 
     @classmethod
     @classmethod
-    @lru_cache(maxsize=None)
+    @functools.cache
     def get_props(cls) -> set[str]:
     def get_props(cls) -> set[str]:
         """Get the unique fields for the component.
         """Get the unique fields for the component.
 
 
@@ -727,7 +713,7 @@ class Component(BaseComponent, ABC):
         return set(cls.get_fields()) - set(Component.get_fields())
         return set(cls.get_fields()) - set(Component.get_fields())
 
 
     @classmethod
     @classmethod
-    @lru_cache(maxsize=None)
+    @functools.cache
     def get_initial_props(cls) -> set[str]:
     def get_initial_props(cls) -> set[str]:
         """Get the initial props to set for the component.
         """Get the initial props to set for the component.
 
 
@@ -746,8 +732,8 @@ class Component(BaseComponent, ABC):
         return True
         return True
 
 
     @classmethod
     @classmethod
-    @lru_cache(maxsize=None)
-    def _get_component_prop_names(cls) -> Set[str]:
+    @functools.cache
+    def _get_component_prop_names(cls) -> set[str]:
         """Get the names of the component props. NOTE: This assumes all fields are known.
         """Get the names of the component props. NOTE: This assumes all fields are known.
 
 
         Returns:
         Returns:
@@ -783,7 +769,7 @@ class Component(BaseComponent, ABC):
         ]
         ]
 
 
     @classmethod
     @classmethod
-    def create(cls: Type[T], *children, **props) -> T:
+    def create(cls: type[T], *children, **props) -> T:
         """Create the component.
         """Create the component.
 
 
         Args:
         Args:
@@ -831,7 +817,7 @@ class Component(BaseComponent, ABC):
         return cls._create(children_normalized, **props)
         return cls._create(children_normalized, **props)
 
 
     @classmethod
     @classmethod
-    def _create(cls: Type[T], children: Sequence[BaseComponent], **props: Any) -> T:
+    def _create(cls: type[T], children: Sequence[BaseComponent], **props: Any) -> T:
         """Create the component.
         """Create the component.
 
 
         Args:
         Args:
@@ -847,7 +833,7 @@ class Component(BaseComponent, ABC):
 
 
     @classmethod
     @classmethod
     def _unsafe_create(
     def _unsafe_create(
-        cls: Type[T], children: Sequence[BaseComponent], **props: Any
+        cls: type[T], children: Sequence[BaseComponent], **props: Any
     ) -> T:
     ) -> T:
         """Create the component without running post_init.
         """Create the component without running post_init.
 
 
@@ -1226,7 +1212,7 @@ class Component(BaseComponent, ABC):
             yield clz.__name__
             yield clz.__name__
 
 
     @classmethod
     @classmethod
-    def _iter_parent_classes_with_method(cls, method: str) -> Iterator[Type[Component]]:
+    def _iter_parent_classes_with_method(cls, method: str) -> Iterator[type[Component]]:
         """Iterate through parent classes that define a given method.
         """Iterate through parent classes that define a given method.
 
 
         Used for handling the `add_*` API functions that internally simulate a super() call chain.
         Used for handling the `add_*` API functions that internally simulate a super() call chain.
@@ -1779,11 +1765,9 @@ class CustomComponent(Component):
                 else (
                 else (
                     annotation_args[1]
                     annotation_args[1]
                     if get_origin(
                     if get_origin(
-                        (
-                            annotation := inspect.getfullargspec(
-                                component_fn
-                            ).annotations[key]
-                        )
+                        annotation := inspect.getfullargspec(component_fn).annotations[
+                            key
+                        ]
                     )
                     )
                     is typing.Annotated
                     is typing.Annotated
                     and (annotation_args := get_args(annotation))
                     and (annotation_args := get_args(annotation))
@@ -1941,7 +1925,7 @@ class CustomComponent(Component):
 
 
         return fn
         return fn
 
 
-    def get_prop_vars(self) -> List[Var | Callable]:
+    def get_prop_vars(self) -> list[Var | Callable]:
         """Get the prop vars.
         """Get the prop vars.
 
 
         Returns:
         Returns:
@@ -1957,7 +1941,7 @@ class CustomComponent(Component):
             for name, prop in self.props.items()
             for name, prop in self.props.items()
         ]
         ]
 
 
-    @lru_cache(maxsize=None)  # noqa: B019
+    @functools.cache  # noqa: B019
     def get_component(self) -> Component:
     def get_component(self) -> Component:
         """Render the component.
         """Render the component.
 
 

+ 1 - 1
reflex/components/core/breakpoints.py

@@ -74,7 +74,7 @@ class Breakpoints(dict[K, V]):
         thresholds = [initial, xs, sm, md, lg, xl]
         thresholds = [initial, xs, sm, md, lg, xl]
 
 
         if custom is not None:
         if custom is not None:
-            if any((threshold is not None for threshold in thresholds)):
+            if any(threshold is not None for threshold in thresholds):
                 raise ValueError("Named props cannot be used with custom thresholds")
                 raise ValueError("Named props cannot be used with custom thresholds")
 
 
             return Breakpoints(custom)
             return Breakpoints(custom)

+ 1 - 1
reflex/components/core/clipboard.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Sequence
+from collections.abc import Sequence
 
 
 from reflex.components.base.fragment import Fragment
 from reflex.components.base.fragment import Fragment
 from reflex.components.tags.tag import Tag
 from reflex.components.tags.tag import Tag

+ 2 - 2
reflex/components/core/cond.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Dict, overload
+from typing import Any, overload
 
 
 from reflex.components.base.fragment import Fragment
 from reflex.components.base.fragment import Fragment
 from reflex.components.component import BaseComponent, Component, MemoizationLeaf
 from reflex.components.component import BaseComponent, Component, MemoizationLeaf
@@ -66,7 +66,7 @@ class Cond(MemoizationLeaf):
             false_value=self.children[1].render(),
             false_value=self.children[1].render(),
         )
         )
 
 
-    def render(self) -> Dict:
+    def render(self) -> dict:
         """Render the component.
         """Render the component.
 
 
         Returns:
         Returns:

+ 3 - 3
reflex/components/core/debounce.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Type
+from typing import Any
 
 
 from reflex.components.component import Component
 from reflex.components.component import Component
 from reflex.constants import EventTriggers
 from reflex.constants import EventTriggers
@@ -43,7 +43,7 @@ class DebounceInput(Component):
     input_ref: Var[str]
     input_ref: Var[str]
 
 
     # The element to wrap
     # The element to wrap
-    element: Var[Type[Component]]
+    element: Var[type[Component]]
 
 
     # Fired when the input value changes
     # Fired when the input value changes
     on_change: EventHandler[no_args_event_spec]
     on_change: EventHandler[no_args_event_spec]
@@ -115,7 +115,7 @@ class DebounceInput(Component):
             "element",
             "element",
             Var(
             Var(
                 _js_expr=str(child.alias or child.tag),
                 _js_expr=str(child.alias or child.tag),
-                _var_type=Type[Component],
+                _var_type=type[Component],
                 _var_data=VarData(
                 _var_data=VarData(
                     imports=child._get_imports(),
                     imports=child._get_imports(),
                     hooks=child._get_all_hooks(),
                     hooks=child._get_all_hooks(),

+ 2 - 1
reflex/components/core/foreach.py

@@ -4,7 +4,8 @@ from __future__ import annotations
 
 
 import functools
 import functools
 import inspect
 import inspect
-from typing import Any, Callable, Iterable
+from collections.abc import Callable, Iterable
+from typing import Any
 
 
 from reflex.components.base.fragment import Fragment
 from reflex.components.base.fragment import Fragment
 from reflex.components.component import Component
 from reflex.components.component import Component

+ 2 - 2
reflex/components/core/match.py

@@ -1,7 +1,7 @@
 """rx.match."""
 """rx.match."""
 
 
 import textwrap
 import textwrap
-from typing import Any, Dict
+from typing import Any
 
 
 from reflex.components.base import Fragment
 from reflex.components.base import Fragment
 from reflex.components.component import BaseComponent, Component, MemoizationLeaf
 from reflex.components.component import BaseComponent, Component, MemoizationLeaf
@@ -247,7 +247,7 @@ class Match(MemoizationLeaf):
             cond=self.cond, match_cases=self.match_cases, default=self.default
             cond=self.cond, match_cases=self.match_cases, default=self.default
         )
         )
 
 
-    def render(self) -> Dict:
+    def render(self) -> dict:
         """Render the component.
         """Render the component.
 
 
         Returns:
         Returns:

+ 2 - 1
reflex/components/core/upload.py

@@ -2,8 +2,9 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from collections.abc import Callable, Sequence
 from pathlib import Path
 from pathlib import Path
-from typing import Any, Callable, ClassVar, Sequence
+from typing import Any, ClassVar
 
 
 from reflex.components.base.fragment import Fragment
 from reflex.components.base.fragment import Fragment
 from reflex.components.component import (
 from reflex.components.component import (

+ 3 - 2
reflex/components/datadisplay/dataeditor.py

@@ -2,8 +2,9 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from collections.abc import Mapping, Sequence
 from enum import Enum
 from enum import Enum
-from typing import Any, Dict, Literal, Mapping, Sequence, TypedDict
+from typing import Any, Literal, TypedDict
 
 
 from reflex.base import Base
 from reflex.base import Base
 from reflex.components.component import Component, NoSSRComponent
 from reflex.components.component import Component, NoSSRComponent
@@ -257,7 +258,7 @@ class DataEditor(NoSSRComponent):
     scroll_offset_y: Var[int]
     scroll_offset_y: Var[int]
 
 
     # global theme
     # global theme
-    theme: Var[DataEditorTheme | Dict]
+    theme: Var[DataEditorTheme | dict]
 
 
     # Fired when a cell is activated.
     # Fired when a cell is activated.
     on_cell_activated: EventHandler[passthrough_event_spec(tuple[int, int])]
     on_cell_activated: EventHandler[passthrough_event_spec(tuple[int, int])]

+ 2 - 1
reflex/components/el/elements/forms.py

@@ -2,8 +2,9 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from collections.abc import Iterator
 from hashlib import md5
 from hashlib import md5
-from typing import Any, Iterator, Literal
+from typing import Any, Literal
 
 
 from jinja2 import Environment
 from jinja2 import Environment
 
 

+ 3 - 2
reflex/components/gridjs/datatable.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Dict, Sequence
+from collections.abc import Sequence
+from typing import Any
 
 
 from reflex.components.component import Component
 from reflex.components.component import Component
 from reflex.components.tags import Tag
 from reflex.components.tags import Tag
@@ -44,7 +45,7 @@ class DataTable(Gridjs):
     resizable: Var[bool]
     resizable: Var[bool]
 
 
     # Enable pagination.
     # Enable pagination.
-    pagination: Var[bool | Dict]
+    pagination: Var[bool | dict]
 
 
     @classmethod
     @classmethod
     def create(cls, *children, **props):
     def create(cls, *children, **props):

+ 2 - 1
reflex/components/markdown/markdown.py

@@ -4,9 +4,10 @@ from __future__ import annotations
 
 
 import dataclasses
 import dataclasses
 import textwrap
 import textwrap
+from collections.abc import Callable, Sequence
 from functools import lru_cache
 from functools import lru_cache
 from hashlib import md5
 from hashlib import md5
-from typing import Any, Callable, Sequence
+from typing import Any
 
 
 from reflex.components.component import BaseComponent, Component, CustomComponent
 from reflex.components.component import BaseComponent, Component, CustomComponent
 from reflex.components.tags.tag import Tag
 from reflex.components.tags.tag import Tag

+ 3 - 3
reflex/components/plotly/plotly.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Dict, TypedDict, TypeVar
+from typing import Any, TypedDict, TypeVar
 
 
 from reflex.components.component import Component, NoSSRComponent
 from reflex.components.component import Component, NoSSRComponent
 from reflex.components.core.cond import color_mode_cond
 from reflex.components.core.cond import color_mode_cond
@@ -81,13 +81,13 @@ class Plotly(NoSSRComponent):
     data: Var[Figure]  # pyright: ignore [reportInvalidTypeForm]
     data: Var[Figure]  # pyright: ignore [reportInvalidTypeForm]
 
 
     # The layout of the graph.
     # The layout of the graph.
-    layout: Var[Dict]
+    layout: Var[dict]
 
 
     # The template for visual appearance of the graph.
     # The template for visual appearance of the graph.
     template: Var[Template]  # pyright: ignore [reportInvalidTypeForm]
     template: Var[Template]  # pyright: ignore [reportInvalidTypeForm]
 
 
     # The config of the graph.
     # The config of the graph.
-    config: Var[Dict]
+    config: Var[dict]
 
 
     # If true, the graph will resize when the window is resized.
     # If true, the graph will resize when the window is resized.
     use_resize_handler: Var[bool] = LiteralVar.create(True)
     use_resize_handler: Var[bool] = LiteralVar.create(True)

+ 2 - 1
reflex/components/radix/primitives/accordion.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, ClassVar, Literal, Sequence
+from collections.abc import Sequence
+from typing import Any, ClassVar, Literal
 
 
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.core.colors import color
 from reflex.components.core.colors import color

+ 2 - 1
reflex/components/radix/primitives/drawer.py

@@ -4,7 +4,8 @@
 # Style based on https://ui.shadcn.com/docs/components/drawer
 # Style based on https://ui.shadcn.com/docs/components/drawer
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Literal, Sequence
+from collections.abc import Sequence
+from typing import Any, Literal
 
 
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.radix.primitives.base import RadixPrimitiveComponent
 from reflex.components.radix.primitives.base import RadixPrimitiveComponent

+ 2 - 1
reflex/components/radix/primitives/slider.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Literal, Sequence
+from collections.abc import Sequence
+from typing import Any, Literal
 
 
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
 from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName

+ 2 - 1
reflex/components/radix/themes/components/checkbox_group.py

@@ -1,7 +1,8 @@
 """Components for the CheckboxGroup component of Radix Themes."""
 """Components for the CheckboxGroup component of Radix Themes."""
 
 
+from collections.abc import Sequence
 from types import SimpleNamespace
 from types import SimpleNamespace
-from typing import Literal, Sequence
+from typing import Literal
 
 
 from reflex.components.core.breakpoints import Responsive
 from reflex.components.core.breakpoints import Responsive
 from reflex.vars.base import Var
 from reflex.vars.base import Var

+ 2 - 1
reflex/components/radix/themes/components/radio_group.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Literal, Sequence
+from collections.abc import Sequence
+from typing import Literal
 
 
 import reflex as rx
 import reflex as rx
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.component import Component, ComponentNamespace

+ 2 - 1
reflex/components/radix/themes/components/segmented_control.py

@@ -2,8 +2,9 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from collections.abc import Sequence
 from types import SimpleNamespace
 from types import SimpleNamespace
-from typing import ClassVar, Literal, Sequence
+from typing import ClassVar, Literal
 
 
 from reflex.components.core.breakpoints import Responsive
 from reflex.components.core.breakpoints import Responsive
 from reflex.event import EventHandler
 from reflex.event import EventHandler

+ 2 - 1
reflex/components/radix/themes/components/select.py

@@ -1,6 +1,7 @@
 """Interactive components provided by @radix-ui/themes."""
 """Interactive components provided by @radix-ui/themes."""
 
 
-from typing import ClassVar, Literal, Sequence
+from collections.abc import Sequence
+from typing import ClassVar, Literal
 
 
 import reflex as rx
 import reflex as rx
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.component import Component, ComponentNamespace

+ 2 - 1
reflex/components/radix/themes/components/slider.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Literal, Sequence
+from collections.abc import Sequence
+from typing import Literal
 
 
 from reflex.components.component import Component
 from reflex.components.component import Component
 from reflex.components.core.breakpoints import Responsive
 from reflex.components.core.breakpoints import Responsive

+ 2 - 2
reflex/components/radix/themes/components/tooltip.py

@@ -1,6 +1,6 @@
 """Interactive components provided by @radix-ui/themes."""
 """Interactive components provided by @radix-ui/themes."""
 
 
-from typing import Literal, Union
+from typing import Literal
 
 
 from reflex.components.component import Component
 from reflex.components.component import Component
 from reflex.constants.compiler import MemoizationMode
 from reflex.constants.compiler import MemoizationMode
@@ -63,7 +63,7 @@ class Tooltip(RadixThemesComponent):
     avoid_collisions: Var[bool]
     avoid_collisions: Var[bool]
 
 
     # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
     # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
-    collision_padding: Var[Union[float, int, dict[str, float | int]]]
+    collision_padding: Var[float | int | dict[str, float | int]]
 
 
     # The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
     # The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
     arrow_padding: Var[float | int]
     arrow_padding: Var[float | int]

+ 2 - 1
reflex/components/radix/themes/layout/list.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Iterable, Literal
+from collections.abc import Iterable
+from typing import Any, Literal
 
 
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.component import Component, ComponentNamespace
 from reflex.components.core.foreach import Foreach
 from reflex.components.core.foreach import Foreach

+ 7 - 6
reflex/components/recharts/cartesian.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, ClassVar, Sequence, Union
+from collections.abc import Sequence
+from typing import Any, ClassVar
 
 
 from reflex.constants import EventTriggers
 from reflex.constants import EventTriggers
 from reflex.constants.colors import Color
 from reflex.constants.colors import Color
@@ -73,7 +74,7 @@ class Axis(Recharts):
     reversed: Var[bool]
     reversed: Var[bool]
 
 
     # The label of axis, which appears next to the axis.
     # The label of axis, which appears next to the axis.
-    label: Var[Union[str, int, dict[str, Any]]]
+    label: Var[str | int | dict[str, Any]]
 
 
     # If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
     # If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
     scale: Var[LiteralScale]
     scale: Var[LiteralScale]
@@ -343,10 +344,10 @@ class Area(Cartesian):
     type_: Var[LiteralAreaType] = LiteralVar.create("monotone")
     type_: Var[LiteralAreaType] = LiteralVar.create("monotone")
 
 
     # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False
     # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False
-    dot: Var[Union[bool, dict[str, Any]]]
+    dot: Var[bool | dict[str, Any]]
 
 
     # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)}
     # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)}
-    active_dot: Var[Union[bool, dict[str, Any]]] = LiteralVar.create(
+    active_dot: Var[bool | dict[str, Any]] = LiteralVar.create(
         {
         {
             "stroke": Color("accent", 2),
             "stroke": Color("accent", 2),
             "fill": Color("accent", 10),
             "fill": Color("accent", 10),
@@ -439,7 +440,7 @@ class Line(Cartesian):
     stroke_width: Var[int]
     stroke_width: Var[int]
 
 
     # The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)}
     # The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)}
-    dot: Var[Union[bool, dict[str, Any]]] = LiteralVar.create(
+    dot: Var[bool | dict[str, Any]] = LiteralVar.create(
         {
         {
             "stroke": Color("accent", 10),
             "stroke": Color("accent", 10),
             "fill": Color("accent", 4),
             "fill": Color("accent", 4),
@@ -447,7 +448,7 @@ class Line(Cartesian):
     )
     )
 
 
     # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)}
     # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)}
-    active_dot: Var[Union[bool, dict[str, Any]]] = LiteralVar.create(
+    active_dot: Var[bool | dict[str, Any]] = LiteralVar.create(
         {
         {
             "stroke": Color("accent", 2),
             "stroke": Color("accent", 2),
             "fill": Color("accent", 10),
             "fill": Color("accent", 10),

+ 2 - 1
reflex/components/recharts/charts.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, ClassVar, Sequence
+from collections.abc import Sequence
+from typing import Any, ClassVar
 
 
 from reflex.components.component import Component
 from reflex.components.component import Component
 from reflex.components.recharts.general import ResponsiveContainer
 from reflex.components.recharts.general import ResponsiveContainer

+ 3 - 2
reflex/components/recharts/general.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, ClassVar, Sequence, Union
+from collections.abc import Sequence
+from typing import Any, ClassVar
 
 
 from reflex.components.component import MemoizationLeaf
 from reflex.components.component import MemoizationLeaf
 from reflex.constants.colors import Color
 from reflex.constants.colors import Color
@@ -146,7 +147,7 @@ class GraphingTooltip(Recharts):
     filter_null: Var[bool]
     filter_null: Var[bool]
 
 
     # If set false, no cursor will be drawn when tooltip is active. Default: {"strokeWidth": 1, "fill": rx.color("gray", 3)}
     # If set false, no cursor will be drawn when tooltip is active. Default: {"strokeWidth": 1, "fill": rx.color("gray", 3)}
-    cursor: Var[Union[dict[str, Any], bool]] = LiteralVar.create(
+    cursor: Var[dict[str, Any] | bool] = LiteralVar.create(
         {
         {
             "strokeWidth": 1,
             "strokeWidth": 1,
             "fill": Color("gray", 3),
             "fill": Color("gray", 3),

+ 9 - 8
reflex/components/recharts/polar.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, ClassVar, Sequence, Union
+from collections.abc import Sequence
+from typing import Any, ClassVar
 
 
 from reflex.constants import EventTriggers
 from reflex.constants import EventTriggers
 from reflex.constants.colors import Color
 from reflex.constants.colors import Color
@@ -189,10 +190,10 @@ class RadialBar(Recharts):
     legend_type: Var[LiteralLegendType]
     legend_type: Var[LiteralLegendType]
 
 
     # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
     # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
-    label: Var[Union[bool, dict[str, Any]]]
+    label: Var[bool | dict[str, Any]]
 
 
     # If false set, background sector will not be drawn. Default: False
     # If false set, background sector will not be drawn. Default: False
-    background: Var[Union[bool, dict[str, Any]]]
+    background: Var[bool | dict[str, Any]]
 
 
     # If set false, animation of radial bars will be disabled. Default: True
     # If set false, animation of radial bars will be disabled. Default: True
     is_animation_active: Var[bool]
     is_animation_active: Var[bool]
@@ -247,16 +248,16 @@ class PolarAngleAxis(Recharts):
     radius: Var[int | str]
     radius: Var[int | str]
 
 
     # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
     # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
-    axis_line: Var[Union[bool, dict[str, Any]]]
+    axis_line: Var[bool | dict[str, Any]]
 
 
     # The type of axis line. Default: "polygon"
     # The type of axis line. Default: "polygon"
     axis_line_type: Var[LiteralGridType]
     axis_line_type: Var[LiteralGridType]
 
 
     # If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. Default: False
     # If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. Default: False
-    tick_line: Var[Union[bool, dict[str, Any]]] = LiteralVar.create(False)
+    tick_line: Var[bool | dict[str, Any]] = LiteralVar.create(False)
 
 
     # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
     # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
-    tick: Var[Union[bool, dict[str, Any]]]
+    tick: Var[bool | dict[str, Any]]
 
 
     # The array of every tick's value and angle.
     # The array of every tick's value and angle.
     ticks: Var[Sequence[dict[str, Any]]]
     ticks: Var[Sequence[dict[str, Any]]]
@@ -362,10 +363,10 @@ class PolarRadiusAxis(Recharts):
     orientation: Var[LiteralOrientationLeftRightMiddle]
     orientation: Var[LiteralOrientationLeftRightMiddle]
 
 
     # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
     # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
-    axis_line: Var[Union[bool, dict[str, Any]]]
+    axis_line: Var[bool | dict[str, Any]]
 
 
     # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
     # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
-    tick: Var[Union[bool, dict[str, Any]]]
+    tick: Var[bool | dict[str, Any]]
 
 
     # The count of axis ticks. Not used if 'type' is 'category'. Default: 5
     # The count of axis ticks. Not used if 'type' is 'category'. Default: 5
     tick_count: Var[int]
     tick_count: Var[int]

+ 22 - 24
reflex/components/suneditor/editor.py

@@ -3,7 +3,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import enum
 import enum
-from typing import Any, Dict, Literal, Union
+from typing import Any, Literal
 
 
 from reflex.base import Base
 from reflex.base import Base
 from reflex.components.component import Component, NoSSRComponent
 from reflex.components.component import Component, NoSSRComponent
@@ -118,29 +118,27 @@ class Editor(NoSSRComponent):
     # "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it"
     # "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it"
     # default: "en".
     # default: "en".
     lang: Var[
     lang: Var[
-        Union[
-            Literal[
-                "en",
-                "da",
-                "de",
-                "es",
-                "fr",
-                "ja",
-                "ko",
-                "pt_br",
-                "ru",
-                "zh_cn",
-                "ro",
-                "pl",
-                "ckb",
-                "lv",
-                "se",
-                "ua",
-                "he",
-                "it",
-            ],
-            dict,
+        Literal[
+            "en",
+            "da",
+            "de",
+            "es",
+            "fr",
+            "ja",
+            "ko",
+            "pt_br",
+            "ru",
+            "zh_cn",
+            "ro",
+            "pl",
+            "ckb",
+            "lv",
+            "se",
+            "ua",
+            "he",
+            "it",
         ]
         ]
+        | dict
     ]
     ]
 
 
     # This is used to set the HTML form name of the editor.
     # This is used to set the HTML form name of the editor.
@@ -169,7 +167,7 @@ class Editor(NoSSRComponent):
     auto_focus: Var[bool]
     auto_focus: Var[bool]
 
 
     # Pass an EditorOptions instance to modify the behaviour of Editor even more.
     # Pass an EditorOptions instance to modify the behaviour of Editor even more.
-    set_options: Var[Dict]
+    set_options: Var[dict]
 
 
     # Whether all SunEditor plugins should be loaded.
     # Whether all SunEditor plugins should be loaded.
     # default: True.
     # default: True.

+ 3 - 3
reflex/components/tags/cond_tag.py

@@ -1,7 +1,7 @@
 """Tag to conditionally render components."""
 """Tag to conditionally render components."""
 
 
 import dataclasses
 import dataclasses
-from typing import Any, Dict
+from typing import Any
 
 
 from reflex.components.tags.tag import Tag
 from reflex.components.tags.tag import Tag
 from reflex.vars.base import Var
 from reflex.vars.base import Var
@@ -15,7 +15,7 @@ class CondTag(Tag):
     cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True))
     cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True))
 
 
     # The code to render if the condition is true.
     # The code to render if the condition is true.
-    true_value: Dict = dataclasses.field(default_factory=dict)
+    true_value: dict = dataclasses.field(default_factory=dict)
 
 
     # The code to render if the condition is false.
     # The code to render if the condition is false.
-    false_value: Dict | None = None
+    false_value: dict | None = None

+ 2 - 1
reflex/components/tags/iter_tag.py

@@ -4,7 +4,8 @@ from __future__ import annotations
 
 
 import dataclasses
 import dataclasses
 import inspect
 import inspect
-from typing import TYPE_CHECKING, Callable, Iterable
+from collections.abc import Callable, Iterable
+from typing import TYPE_CHECKING
 
 
 from reflex.components.tags.tag import Tag
 from reflex.components.tags.tag import Tag
 from reflex.utils.types import GenericType
 from reflex.utils.types import GenericType

+ 3 - 2
reflex/components/tags/tag.py

@@ -3,7 +3,8 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import dataclasses
 import dataclasses
-from typing import Any, List, Mapping, Sequence
+from collections.abc import Mapping, Sequence
+from typing import Any
 
 
 from reflex.event import EventChain
 from reflex.event import EventChain
 from reflex.utils import format
 from reflex.utils import format
@@ -57,7 +58,7 @@ class Tag:
             {name: LiteralVar.create(value) for name, value in self.props.items()},
             {name: LiteralVar.create(value) for name, value in self.props.items()},
         )
         )
 
 
-    def format_props(self) -> List:
+    def format_props(self) -> list:
         """Format the tag's props.
         """Format the tag's props.
 
 
         Returns:
         Returns:

+ 2 - 2
reflex/config.py

@@ -13,6 +13,7 @@ import platform
 import sys
 import sys
 import threading
 import threading
 import urllib.parse
 import urllib.parse
+from collections.abc import Callable
 from functools import lru_cache
 from functools import lru_cache
 from importlib.util import find_spec
 from importlib.util import find_spec
 from pathlib import Path
 from pathlib import Path
@@ -21,7 +22,6 @@ from typing import (
     TYPE_CHECKING,
     TYPE_CHECKING,
     Annotated,
     Annotated,
     Any,
     Any,
-    Callable,
     Generic,
     Generic,
     TypeVar,
     TypeVar,
     get_args,
     get_args,
@@ -433,7 +433,7 @@ class EnvVar(Generic[T]):
             os.environ[self.name] = str_value
             os.environ[self.name] = str_value
 
 
 
 
-@lru_cache()
+@lru_cache
 def get_type_hints_environment(cls: type) -> dict[str, Any]:
 def get_type_hints_environment(cls: type) -> dict[str, Any]:
     """Get the type hints for the environment variables.
     """Get the type hints for the environment variables.
 
 

+ 2 - 3
reflex/constants/route.py

@@ -7,9 +7,8 @@ from types import SimpleNamespace
 class RouteArgType(SimpleNamespace):
 class RouteArgType(SimpleNamespace):
     """Type of dynamic route arg extracted from URI route."""
     """Type of dynamic route arg extracted from URI route."""
 
 
-    # Typecast to str is needed for Enum to work.
-    SINGLE = str("arg_single")
-    LIST = str("arg_list")
+    SINGLE = "arg_single"
+    LIST = "arg_list"
 
 
 
 
 # the name of the backend var containing path and client information
 # the name of the backend var containing path and client information

+ 4 - 3
reflex/constants/utils.py

@@ -1,6 +1,7 @@
 """Utility functions for constants."""
 """Utility functions for constants."""
 
 
-from typing import Any, Callable, Generic, Type, TypeVar
+from collections.abc import Callable
+from typing import Any, Generic, TypeVar
 
 
 T = TypeVar("T")
 T = TypeVar("T")
 V = TypeVar("V")
 V = TypeVar("V")
@@ -9,7 +10,7 @@ V = TypeVar("V")
 class classproperty(Generic[T, V]):
 class classproperty(Generic[T, V]):
     """A class property decorator."""
     """A class property decorator."""
 
 
-    def __init__(self, getter: Callable[[Type[T]], V]) -> None:
+    def __init__(self, getter: Callable[[type[T]], V]) -> None:
         """Initialize the class property.
         """Initialize the class property.
 
 
         Args:
         Args:
@@ -17,7 +18,7 @@ class classproperty(Generic[T, V]):
         """
         """
         self.getter = getattr(getter, "__func__", getter)
         self.getter = getattr(getter, "__func__", getter)
 
 
-    def __get__(self, instance: Any, owner: Type[T]) -> V:
+    def __get__(self, instance: Any, owner: type[T]) -> V:
         """Get the value of the class property.
         """Get the value of the class property.
 
 
         Args:
         Args:

+ 6 - 8
reflex/event.py

@@ -7,16 +7,14 @@ import inspect
 import types
 import types
 import urllib.parse
 import urllib.parse
 from base64 import b64encode
 from base64 import b64encode
+from collections.abc import Callable, Sequence
 from functools import partial
 from functools import partial
 from typing import (
 from typing import (
     TYPE_CHECKING,
     TYPE_CHECKING,
     Annotated,
     Annotated,
     Any,
     Any,
-    Callable,
     Generic,
     Generic,
     Protocol,
     Protocol,
-    Sequence,
-    Type,
     TypedDict,
     TypedDict,
     TypeVar,
     TypeVar,
     get_args,
     get_args,
@@ -670,21 +668,21 @@ class IdentityEventReturn(Generic[T], Protocol):
 
 
 @overload
 @overload
 def passthrough_event_spec(  # pyright: ignore [reportOverlappingOverload]
 def passthrough_event_spec(  # pyright: ignore [reportOverlappingOverload]
-    event_type: Type[T], /
+    event_type: type[T], /
 ) -> Callable[[Var[T]], tuple[Var[T]]]: ...
 ) -> Callable[[Var[T]], tuple[Var[T]]]: ...
 
 
 
 
 @overload
 @overload
 def passthrough_event_spec(
 def passthrough_event_spec(
-    event_type_1: Type[T], event_type2: Type[U], /
+    event_type_1: type[T], event_type2: type[U], /
 ) -> Callable[[Var[T], Var[U]], tuple[Var[T], Var[U]]]: ...
 ) -> Callable[[Var[T], Var[U]], tuple[Var[T], Var[U]]]: ...
 
 
 
 
 @overload
 @overload
-def passthrough_event_spec(*event_types: Type[T]) -> IdentityEventReturn[T]: ...
+def passthrough_event_spec(*event_types: type[T]) -> IdentityEventReturn[T]: ...
 
 
 
 
-def passthrough_event_spec(*event_types: Type[T]) -> IdentityEventReturn[T]:  # pyright: ignore [reportInconsistentOverload]
+def passthrough_event_spec(*event_types: type[T]) -> IdentityEventReturn[T]:  # pyright: ignore [reportInconsistentOverload]
     """A helper function that returns the input event as output.
     """A helper function that returns the input event as output.
 
 
     Args:
     Args:
@@ -1808,7 +1806,7 @@ class LiteralEventChainVar(ArgsFunctionOperationBuilder, LiteralVar, EventChainV
         )
         )
         sig = inspect.signature(arg_spec)  # pyright: ignore [reportArgumentType]
         sig = inspect.signature(arg_spec)  # pyright: ignore [reportArgumentType]
         if sig.parameters:
         if sig.parameters:
-            arg_def = tuple((f"_{p}" for p in sig.parameters))
+            arg_def = tuple(f"_{p}" for p in sig.parameters)
             arg_def_expr = LiteralVar.create([Var(_js_expr=arg) for arg in arg_def])
             arg_def_expr = LiteralVar.create([Var(_js_expr=arg) for arg in arg_def])
         else:
         else:
             # add a default argument for addEvents if none were specified in value.args_spec
             # add a default argument for addEvents if none were specified in value.args_spec

+ 3 - 2
reflex/experimental/client_state.py

@@ -4,7 +4,8 @@ from __future__ import annotations
 
 
 import dataclasses
 import dataclasses
 import re
 import re
-from typing import Any, Callable
+from collections.abc import Callable
+from typing import Any
 
 
 from reflex import constants
 from reflex import constants
 from reflex.event import EventChain, EventHandler, EventSpec, run_script
 from reflex.event import EventChain, EventHandler, EventSpec, run_script
@@ -77,7 +78,7 @@ class ClientStateVar(Var):
         var_name: str | None = None,
         var_name: str | None = None,
         default: Any = NoValue,
         default: Any = NoValue,
         global_ref: bool = True,
         global_ref: bool = True,
-    ) -> "ClientStateVar":
+    ) -> ClientStateVar:
         """Create a local_state Var that can be accessed and updated on the client.
         """Create a local_state Var that can be accessed and updated on the client.
 
 
         The `ClientStateVar` should be included in the highest parent component
         The `ClientStateVar` should be included in the highest parent component

+ 1 - 1
reflex/istate/data.py

@@ -1,7 +1,7 @@
 """This module contains the dataclasses representing the router object."""
 """This module contains the dataclasses representing the router object."""
 
 
 import dataclasses
 import dataclasses
-from typing import Mapping
+from collections.abc import Mapping
 
 
 from reflex import constants
 from reflex import constants
 from reflex.utils import format
 from reflex.utils import format

+ 2 - 2
reflex/istate/storage.py

@@ -90,7 +90,7 @@ class LocalStorage(ClientStorageBase, str):
         /,
         /,
         name: str | None = None,
         name: str | None = None,
         sync: bool = False,
         sync: bool = False,
-    ) -> "LocalStorage":
+    ) -> LocalStorage:
         """Create a client-side localStorage (str).
         """Create a client-side localStorage (str).
 
 
         Args:
         Args:
@@ -124,7 +124,7 @@ class SessionStorage(ClientStorageBase, str):
         errors: str | None = None,
         errors: str | None = None,
         /,
         /,
         name: str | None = None,
         name: str | None = None,
-    ) -> "SessionStorage":
+    ) -> SessionStorage:
         """Create a client-side sessionStorage (str).
         """Create a client-side sessionStorage (str).
 
 
         Args:
         Args:

+ 3 - 3
reflex/model.py

@@ -5,7 +5,7 @@ from __future__ import annotations
 import re
 import re
 from collections import defaultdict
 from collections import defaultdict
 from contextlib import suppress
 from contextlib import suppress
-from typing import Any, ClassVar, Type
+from typing import Any, ClassVar
 
 
 import alembic.autogenerate
 import alembic.autogenerate
 import alembic.command
 import alembic.command
@@ -161,7 +161,7 @@ async def get_db_status() -> dict[str, bool]:
     return {"db": status}
     return {"db": status}
 
 
 
 
-SQLModelOrSqlAlchemy = Type[sqlmodel.SQLModel] | Type[sqlalchemy.orm.DeclarativeBase]
+SQLModelOrSqlAlchemy = type[sqlmodel.SQLModel] | type[sqlalchemy.orm.DeclarativeBase]
 
 
 
 
 class ModelRegistry:
 class ModelRegistry:
@@ -328,7 +328,7 @@ class Model(Base, sqlmodel.SQLModel):  # pyright: ignore [reportGeneralTypeIssue
     def _alembic_render_item(
     def _alembic_render_item(
         type_: str,
         type_: str,
         obj: Any,
         obj: Any,
-        autogen_context: "alembic.autogenerate.api.AutogenContext",
+        autogen_context: alembic.autogenerate.api.AutogenContext,
     ):
     ):
         """Alembic render_item hook call.
         """Alembic render_item hook call.
 
 

+ 3 - 2
reflex/page.py

@@ -3,12 +3,13 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 from collections import defaultdict
 from collections import defaultdict
-from typing import Any, Callable, List
+from collections.abc import Callable
+from typing import Any
 
 
 from reflex.config import get_config
 from reflex.config import get_config
 from reflex.event import EventType
 from reflex.event import EventType
 
 
-DECORATED_PAGES: dict[str, List] = defaultdict(list)
+DECORATED_PAGES: dict[str, list] = defaultdict(list)
 
 
 
 
 def page(
 def page(

+ 53 - 56
reflex/state.py

@@ -3,6 +3,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import asyncio
 import asyncio
+import builtins
 import contextlib
 import contextlib
 import copy
 import copy
 import dataclasses
 import dataclasses
@@ -16,23 +17,16 @@ import typing
 import uuid
 import uuid
 import warnings
 import warnings
 from abc import ABC, abstractmethod
 from abc import ABC, abstractmethod
+from collections.abc import AsyncIterator, Callable, Sequence
 from hashlib import md5
 from hashlib import md5
 from pathlib import Path
 from pathlib import Path
 from types import FunctionType, MethodType
 from types import FunctionType, MethodType
 from typing import (
 from typing import (
     TYPE_CHECKING,
     TYPE_CHECKING,
     Any,
     Any,
-    AsyncIterator,
     BinaryIO,
     BinaryIO,
-    Callable,
     ClassVar,
     ClassVar,
-    Dict,
-    Optional,
-    Sequence,
-    Set,
     SupportsIndex,
     SupportsIndex,
-    Tuple,
-    Type,
     TypeVar,
     TypeVar,
     cast,
     cast,
     get_args,
     get_args,
@@ -134,7 +128,7 @@ VAR_TYPE = TypeVar("VAR_TYPE")
 
 
 
 
 def _no_chain_background_task(
 def _no_chain_background_task(
-    state_cls: Type["BaseState"], name: str, fn: Callable
+    state_cls: type[BaseState], name: str, fn: Callable
 ) -> Callable:
 ) -> Callable:
     """Protect against directly chaining a background task from another event handler.
     """Protect against directly chaining a background task from another event handler.
 
 
@@ -173,7 +167,7 @@ def _no_chain_background_task(
 
 
 def _substate_key(
 def _substate_key(
     token: str,
     token: str,
-    state_cls_or_name: BaseState | Type[BaseState] | str | Sequence[str],
+    state_cls_or_name: BaseState | type[BaseState] | str | Sequence[str],
 ) -> str:
 ) -> str:
     """Get the substate key.
     """Get the substate key.
 
 
@@ -210,9 +204,9 @@ def _split_substate_key(substate_key: str) -> tuple[str, str]:
 class EventHandlerSetVar(EventHandler):
 class EventHandlerSetVar(EventHandler):
     """A special event handler to wrap setvar functionality."""
     """A special event handler to wrap setvar functionality."""
 
 
-    state_cls: Type[BaseState] = dataclasses.field(init=False)
+    state_cls: type[BaseState] = dataclasses.field(init=False)
 
 
-    def __init__(self, state_cls: Type[BaseState]):
+    def __init__(self, state_cls: type[BaseState]):
         """Initialize the EventHandlerSetVar.
         """Initialize the EventHandlerSetVar.
 
 
         Args:
         Args:
@@ -277,7 +271,7 @@ if TYPE_CHECKING:
     from pydantic.v1.fields import ModelField
     from pydantic.v1.fields import ModelField
 
 
 
 
-def _unwrap_field_type(type_: types.GenericType) -> Type:
+def _unwrap_field_type(type_: types.GenericType) -> type:
     """Unwrap rx.Field type annotations.
     """Unwrap rx.Field type annotations.
 
 
     Args:
     Args:
@@ -293,7 +287,7 @@ def _unwrap_field_type(type_: types.GenericType) -> Type:
     return type_
     return type_
 
 
 
 
-def get_var_for_field(cls: Type[BaseState], f: ModelField):
+def get_var_for_field(cls: type[BaseState], f: ModelField):
     """Get a Var instance for a Pydantic field.
     """Get a Var instance for a Pydantic field.
 
 
     Args:
     Args:
@@ -338,31 +332,31 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
     """The state of the app."""
     """The state of the app."""
 
 
     # A map from the var name to the var.
     # A map from the var name to the var.
-    vars: ClassVar[Dict[str, Var]] = {}
+    vars: ClassVar[builtins.dict[str, Var]] = {}
 
 
     # The base vars of the class.
     # The base vars of the class.
-    base_vars: ClassVar[Dict[str, Var]] = {}
+    base_vars: ClassVar[builtins.dict[str, Var]] = {}
 
 
     # The computed vars of the class.
     # The computed vars of the class.
-    computed_vars: ClassVar[Dict[str, ComputedVar]] = {}
+    computed_vars: ClassVar[builtins.dict[str, ComputedVar]] = {}
 
 
     # Vars inherited by the parent state.
     # Vars inherited by the parent state.
-    inherited_vars: ClassVar[Dict[str, Var]] = {}
+    inherited_vars: ClassVar[builtins.dict[str, Var]] = {}
 
 
     # Backend base vars that are never sent to the client.
     # Backend base vars that are never sent to the client.
-    backend_vars: ClassVar[Dict[str, Any]] = {}
+    backend_vars: ClassVar[builtins.dict[str, Any]] = {}
 
 
     # Backend base vars inherited
     # Backend base vars inherited
-    inherited_backend_vars: ClassVar[Dict[str, Any]] = {}
+    inherited_backend_vars: ClassVar[builtins.dict[str, Any]] = {}
 
 
     # The event handlers.
     # The event handlers.
-    event_handlers: ClassVar[Dict[str, EventHandler]] = {}
+    event_handlers: ClassVar[builtins.dict[str, EventHandler]] = {}
 
 
     # A set of subclassses of this class.
     # A set of subclassses of this class.
-    class_subclasses: ClassVar[set[Type[BaseState]]] = set()
+    class_subclasses: ClassVar[set[type[BaseState]]] = set()
 
 
     # Mapping of var name to set of (state_full_name, var_name) that depend on it.
     # Mapping of var name to set of (state_full_name, var_name) that depend on it.
-    _var_dependencies: ClassVar[Dict[str, set[tuple[str, str]]]] = {}
+    _var_dependencies: ClassVar[builtins.dict[str, set[tuple[str, str]]]] = {}
 
 
     # Set of vars which always need to be recomputed
     # Set of vars which always need to be recomputed
     _always_dirty_computed_vars: ClassVar[set[str]] = set()
     _always_dirty_computed_vars: ClassVar[set[str]] = set()
@@ -377,7 +371,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
     parent_state: BaseState | None = None
     parent_state: BaseState | None = None
 
 
     # The substates of the state.
     # The substates of the state.
-    substates: Dict[str, BaseState] = {}
+    substates: builtins.dict[str, BaseState] = {}
 
 
     # The set of dirty vars.
     # The set of dirty vars.
     dirty_vars: set[str] = set()
     dirty_vars: set[str] = set()
@@ -386,10 +380,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
     dirty_substates: set[str] = set()
     dirty_substates: set[str] = set()
 
 
     # The routing path that triggered the state
     # The routing path that triggered the state
-    router_data: Dict[str, Any] = {}
+    router_data: builtins.dict[str, Any] = {}
 
 
     # Per-instance copy of backend base variable values
     # Per-instance copy of backend base variable values
-    _backend_vars: Dict[str, Any] = {}
+    _backend_vars: builtins.dict[str, Any] = {}
 
 
     # The router data for the current page
     # The router data for the current page
     router: RouterData = RouterData()
     router: RouterData = RouterData()
@@ -714,7 +708,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         return getattr(cls, unique_var_name)
         return getattr(cls, unique_var_name)
 
 
     @classmethod
     @classmethod
-    def _mixins(cls) -> list[Type]:
+    def _mixins(cls) -> list[type]:
         """Get the mixin classes of the state.
         """Get the mixin classes of the state.
 
 
         Returns:
         Returns:
@@ -889,8 +883,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         )
         )
 
 
     @classmethod
     @classmethod
-    @functools.lru_cache()
-    def get_parent_state(cls) -> Type[BaseState] | None:
+    @functools.lru_cache
+    def get_parent_state(cls) -> type[BaseState] | None:
         """Get the parent state.
         """Get the parent state.
 
 
         Raises:
         Raises:
@@ -916,8 +910,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         return None  # No known parent
         return None  # No known parent
 
 
     @classmethod
     @classmethod
-    @functools.lru_cache()
-    def get_root_state(cls) -> Type[BaseState]:
+    @functools.lru_cache
+    def get_root_state(cls) -> type[BaseState]:
         """Get the root state.
         """Get the root state.
 
 
         Returns:
         Returns:
@@ -927,7 +921,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         return cls if parent_state is None else parent_state.get_root_state()
         return cls if parent_state is None else parent_state.get_root_state()
 
 
     @classmethod
     @classmethod
-    def get_substates(cls) -> set[Type[BaseState]]:
+    def get_substates(cls) -> set[type[BaseState]]:
         """Get the substates of the state.
         """Get the substates of the state.
 
 
         Returns:
         Returns:
@@ -936,7 +930,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         return cls.class_subclasses
         return cls.class_subclasses
 
 
     @classmethod
     @classmethod
-    @functools.lru_cache()
+    @functools.lru_cache
     def get_name(cls) -> str:
     def get_name(cls) -> str:
         """Get the name of the state.
         """Get the name of the state.
 
 
@@ -947,7 +941,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         return format.to_snake_case(f"{module}___{cls.__name__}")
         return format.to_snake_case(f"{module}___{cls.__name__}")
 
 
     @classmethod
     @classmethod
-    @functools.lru_cache()
+    @functools.lru_cache
     def get_full_name(cls) -> str:
     def get_full_name(cls) -> str:
         """Get the full name of the state.
         """Get the full name of the state.
 
 
@@ -961,8 +955,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         return name
         return name
 
 
     @classmethod
     @classmethod
-    @functools.lru_cache()
-    def get_class_substate(cls, path: Sequence[str] | str) -> Type[BaseState]:
+    @functools.lru_cache
+    def get_class_substate(cls, path: Sequence[str] | str) -> type[BaseState]:
         """Get the class substate.
         """Get the class substate.
 
 
         Args:
         Args:
@@ -1133,7 +1127,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
             and not types.is_optional(prop._var_type)
             and not types.is_optional(prop._var_type)
         ):
         ):
             # Ensure frontend uses null coalescing when accessing.
             # Ensure frontend uses null coalescing when accessing.
-            object.__setattr__(prop, "_var_type", Optional[prop._var_type])
+            object.__setattr__(prop, "_var_type", prop._var_type | None)
 
 
     @classmethod
     @classmethod
     def _get_var_default(cls, name: str, annotation_value: Any) -> Any:
     def _get_var_default(cls, name: str, annotation_value: Any) -> Any:
@@ -1471,7 +1465,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
             parent_state = parent_state.parent_state
             parent_state = parent_state.parent_state
         return parent_state
         return parent_state
 
 
-    async def _get_state_from_redis(self, state_cls: Type[T_STATE]) -> T_STATE:
+    async def _get_state_from_redis(self, state_cls: type[T_STATE]) -> T_STATE:
         """Get a state instance from redis.
         """Get a state instance from redis.
 
 
         Args:
         Args:
@@ -1504,7 +1498,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
 
 
         return state_in_redis
         return state_in_redis
 
 
-    def _get_state_from_cache(self, state_cls: Type[T_STATE]) -> T_STATE:
+    def _get_state_from_cache(self, state_cls: type[T_STATE]) -> T_STATE:
         """Get a state instance from the cache.
         """Get a state instance from the cache.
 
 
         Args:
         Args:
@@ -1524,7 +1518,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
             )
             )
         return substate
         return substate
 
 
-    async def get_state(self, state_cls: Type[T_STATE]) -> T_STATE:
+    async def get_state(self, state_cls: type[T_STATE]) -> T_STATE:
         """Get an instance of the state associated with this token.
         """Get an instance of the state associated with this token.
 
 
         Allows for arbitrary access to sibling states from within an event handler.
         Allows for arbitrary access to sibling states from within an event handler.
@@ -1738,7 +1732,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
             )
             )
 
 
     async def _process_event(
     async def _process_event(
-        self, handler: EventHandler, state: BaseState | StateProxy, payload: Dict
+        self,
+        handler: EventHandler,
+        state: BaseState | StateProxy,
+        payload: builtins.dict,
     ) -> AsyncIterator[StateUpdate]:
     ) -> AsyncIterator[StateUpdate]:
         """Process event.
         """Process event.
 
 
@@ -1789,10 +1786,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
                     hinted_args, (Base, BaseModelV1, BaseModelV2)
                     hinted_args, (Base, BaseModelV1, BaseModelV2)
                 ):
                 ):
                     payload[arg] = hinted_args(**value)
                     payload[arg] = hinted_args(**value)
-            elif isinstance(value, list) and (hinted_args is set or hinted_args is Set):
+            elif isinstance(value, list) and (hinted_args is set or hinted_args is set):
                 payload[arg] = set(value)
                 payload[arg] = set(value)
             elif isinstance(value, list) and (
             elif isinstance(value, list) and (
-                hinted_args is tuple or hinted_args is Tuple
+                hinted_args is tuple or hinted_args is tuple
             ):
             ):
                 payload[arg] = tuple(value)
                 payload[arg] = tuple(value)
             elif isinstance(value, str) and (
             elif isinstance(value, str) and (
@@ -2172,7 +2169,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
             _WARNED_ABOUT_STATE_SIZE.add(state_full_name)
             _WARNED_ABOUT_STATE_SIZE.add(state_full_name)
 
 
     @classmethod
     @classmethod
-    @functools.lru_cache()
+    @functools.lru_cache
     def _to_schema(cls) -> str:
     def _to_schema(cls) -> str:
         """Convert a state to a schema.
         """Convert a state to a schema.
 
 
@@ -2315,7 +2312,7 @@ def dynamic(func: Callable[[T], Component]):
             "You must provide a type hint for the state class in the function."
             "You must provide a type hint for the state class in the function."
         )
         )
 
 
-    state_class: Type[T] = values[0]
+    state_class: type[T] = values[0]
 
 
     def wrapper() -> Component:
     def wrapper() -> Component:
         from reflex.components.base.fragment import fragment
         from reflex.components.base.fragment import fragment
@@ -2467,7 +2464,7 @@ class ComponentState(State, mixin=True):
         super().__init_subclass__(mixin=mixin, **kwargs)
         super().__init_subclass__(mixin=mixin, **kwargs)
 
 
     @classmethod
     @classmethod
-    def get_component(cls, *children, **props) -> "Component":
+    def get_component(cls, *children, **props) -> Component:
         """Get the component instance.
         """Get the component instance.
 
 
         Args:
         Args:
@@ -2482,7 +2479,7 @@ class ComponentState(State, mixin=True):
         )
         )
 
 
     @classmethod
     @classmethod
-    def create(cls, *children, **props) -> "Component":
+    def create(cls, *children, **props) -> Component:
         """Create a new instance of the Component.
         """Create a new instance of the Component.
 
 
         Args:
         Args:
@@ -2539,7 +2536,7 @@ class StateProxy(wrapt.ObjectProxy):
     def __init__(
     def __init__(
         self,
         self,
         state_instance: BaseState,
         state_instance: BaseState,
-        parent_state_proxy: Optional["StateProxy"] = None,
+        parent_state_proxy: StateProxy | None = None,
     ):
     ):
         """Create a proxy for a state instance.
         """Create a proxy for a state instance.
 
 
@@ -2743,7 +2740,7 @@ class StateProxy(wrapt.ObjectProxy):
             )
             )
         return self.__wrapped__.get_substate(path)
         return self.__wrapped__.get_substate(path)
 
 
-    async def get_state(self, state_cls: Type[BaseState]) -> BaseState:
+    async def get_state(self, state_cls: type[BaseState]) -> BaseState:
         """Get an instance of the state associated with this token.
         """Get an instance of the state associated with this token.
 
 
         Args:
         Args:
@@ -2810,10 +2807,10 @@ class StateManager(Base, ABC):
     """A class to manage many client states."""
     """A class to manage many client states."""
 
 
     # The state class to use.
     # The state class to use.
-    state: Type[BaseState]
+    state: type[BaseState]
 
 
     @classmethod
     @classmethod
-    def create(cls, state: Type[BaseState]):
+    def create(cls, state: type[BaseState]):
         """Create a new state manager.
         """Create a new state manager.
 
 
         Args:
         Args:
@@ -3021,7 +3018,7 @@ class StateManagerDisk(StateManager):
         }
         }
         keep_untouched = (functools.cached_property,)
         keep_untouched = (functools.cached_property,)
 
 
-    def __init__(self, state: Type[BaseState]):
+    def __init__(self, state: type[BaseState]):
         """Create a new state manager.
         """Create a new state manager.
 
 
         Args:
         Args:
@@ -3261,10 +3258,10 @@ class StateManagerRedis(StateManager):
 
 
     def _get_required_state_classes(
     def _get_required_state_classes(
         self,
         self,
-        target_state_cls: Type[BaseState],
+        target_state_cls: type[BaseState],
         subclasses: bool = False,
         subclasses: bool = False,
-        required_state_classes: set[Type[BaseState]] | None = None,
-    ) -> set[Type[BaseState]]:
+        required_state_classes: set[type[BaseState]] | None = None,
+    ) -> set[type[BaseState]]:
         """Recursively determine which states are required to fetch the target state.
         """Recursively determine which states are required to fetch the target state.
 
 
         This will always include potentially dirty substates that depend on vars
         This will always include potentially dirty substates that depend on vars
@@ -4121,7 +4118,7 @@ def code_uses_state_contexts(javascript_code: str) -> bool:
 
 
 def reload_state_module(
 def reload_state_module(
     module: str,
     module: str,
-    state: Type[BaseState] = State,
+    state: type[BaseState] = State,
 ) -> None:
 ) -> None:
     """Reset rx.State subclasses to avoid conflict when reloading.
     """Reset rx.State subclasses to avoid conflict when reloading.
 
 

+ 3 - 2
reflex/style.py

@@ -2,7 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Any, Literal, Mapping, Type
+from collections.abc import Mapping
+from typing import Any, Literal
 
 
 from reflex import constants
 from reflex import constants
 from reflex.components.core.breakpoints import Breakpoints, breakpoints_values
 from reflex.components.core.breakpoints import Breakpoints, breakpoints_values
@@ -28,7 +29,7 @@ color_mode_imports = {
 }
 }
 
 
 
 
-def _color_mode_var(_js_expr: str, _var_type: Type = str) -> Var:
+def _color_mode_var(_js_expr: str, _var_type: type = str) -> Var:
     """Create a Var that destructs the _js_expr from ColorModeContext.
     """Create a Var that destructs the _js_expr from ColorModeContext.
 
 
     Args:
     Args:

+ 12 - 21
reflex/testing.py

@@ -18,19 +18,10 @@ import textwrap
 import threading
 import threading
 import time
 import time
 import types
 import types
+from collections.abc import AsyncIterator, Callable, Coroutine, Sequence
 from http.server import SimpleHTTPRequestHandler
 from http.server import SimpleHTTPRequestHandler
 from pathlib import Path
 from pathlib import Path
-from typing import (
-    TYPE_CHECKING,
-    Any,
-    AsyncIterator,
-    Callable,
-    Coroutine,
-    Optional,
-    Sequence,
-    Type,
-    TypeVar,
-)
+from typing import TYPE_CHECKING, Any, TypeVar
 
 
 import psutil
 import psutil
 import uvicorn
 import uvicorn
@@ -124,7 +115,7 @@ class AppHarness:
     backend_thread: threading.Thread | None = None
     backend_thread: threading.Thread | None = None
     backend: uvicorn.Server | None = None
     backend: uvicorn.Server | None = None
     state_manager: StateManager | None = None
     state_manager: StateManager | None = None
-    _frontends: list["WebDriver"] = dataclasses.field(default_factory=list)
+    _frontends: list[WebDriver] = dataclasses.field(default_factory=list)
     _decorated_pages: list = dataclasses.field(default_factory=list)
     _decorated_pages: list = dataclasses.field(default_factory=list)
 
 
     @classmethod
     @classmethod
@@ -135,7 +126,7 @@ class AppHarness:
             Callable[[], None] | types.ModuleType | str | functools.partial[Any] | None
             Callable[[], None] | types.ModuleType | str | functools.partial[Any] | None
         ) = None,
         ) = None,
         app_name: str | None = None,
         app_name: str | None = None,
-    ) -> "AppHarness":
+    ) -> AppHarness:
         """Create an AppHarness instance at root.
         """Create an AppHarness instance at root.
 
 
         Args:
         Args:
@@ -371,7 +362,7 @@ class AppHarness:
         # Set up the frontend.
         # Set up the frontend.
         with chdir(self.app_path):
         with chdir(self.app_path):
             config = reflex.config.get_config()
             config = reflex.config.get_config()
-            config.api_url = "http://{0}:{1}".format(
+            config.api_url = "http://{}:{}".format(
                 *self._poll_for_servers().getsockname(),
                 *self._poll_for_servers().getsockname(),
             )
             )
             reflex.utils.build.setup_frontend(self.app_path)
             reflex.utils.build.setup_frontend(self.app_path)
@@ -423,7 +414,7 @@ class AppHarness:
         self.frontend_output_thread = threading.Thread(target=consume_frontend_output)
         self.frontend_output_thread = threading.Thread(target=consume_frontend_output)
         self.frontend_output_thread.start()
         self.frontend_output_thread.start()
 
 
-    def start(self) -> "AppHarness":
+    def start(self) -> AppHarness:
         """Start the backend in a new thread and dev frontend as a separate process.
         """Start the backend in a new thread and dev frontend as a separate process.
 
 
         Returns:
         Returns:
@@ -452,7 +443,7 @@ class AppHarness:
             return f"{key} = {value!r}"
             return f"{key} = {value!r}"
         return inspect.getsource(value)
         return inspect.getsource(value)
 
 
-    def __enter__(self) -> "AppHarness":
+    def __enter__(self) -> AppHarness:
         """Contextmanager protocol for `start()`.
         """Contextmanager protocol for `start()`.
 
 
         Returns:
         Returns:
@@ -599,12 +590,12 @@ class AppHarness:
 
 
     def frontend(
     def frontend(
         self,
         self,
-        driver_clz: Optional[Type["WebDriver"]] = None,
+        driver_clz: type[WebDriver] | None = None,
         driver_kwargs: dict[str, Any] | None = None,
         driver_kwargs: dict[str, Any] | None = None,
         driver_options: ArgOptions | None = None,
         driver_options: ArgOptions | None = None,
         driver_option_args: list[str] | None = None,
         driver_option_args: list[str] | None = None,
         driver_option_capabilities: dict[str, Any] | None = None,
         driver_option_capabilities: dict[str, Any] | None = None,
-    ) -> "WebDriver":
+    ) -> WebDriver:
         """Get a selenium webdriver instance pointed at the app.
         """Get a selenium webdriver instance pointed at the app.
 
 
         Args:
         Args:
@@ -743,7 +734,7 @@ class AppHarness:
 
 
     def poll_for_content(
     def poll_for_content(
         self,
         self,
-        element: "WebElement",
+        element: WebElement,
         timeout: TimeoutType = None,
         timeout: TimeoutType = None,
         exp_not_equal: str = "",
         exp_not_equal: str = "",
     ) -> str:
     ) -> str:
@@ -771,7 +762,7 @@ class AppHarness:
 
 
     def poll_for_value(
     def poll_for_value(
         self,
         self,
-        element: "WebElement",
+        element: WebElement,
         timeout: TimeoutType = None,
         timeout: TimeoutType = None,
         exp_not_equal: str | Sequence[str] = "",
         exp_not_equal: str | Sequence[str] = "",
     ) -> str | None:
     ) -> str | None:
@@ -940,7 +931,7 @@ class AppHarnessProd(AppHarness):
         # Set up the frontend.
         # Set up the frontend.
         with chdir(self.app_path):
         with chdir(self.app_path):
             config = reflex.config.get_config()
             config = reflex.config.get_config()
-            config.api_url = "http://{0}:{1}".format(
+            config.api_url = "http://{}:{}".format(
                 *self._poll_for_servers().getsockname(),
                 *self._poll_for_servers().getsockname(),
             )
             )
             reflex.reflex.export(
             reflex.reflex.export(

+ 14 - 15
reflex/utils/codespaces.py

@@ -21,28 +21,28 @@ def redirect_script() -> str:
     Returns:
     Returns:
         The redirect script as a string.
         The redirect script as a string.
     """
     """
-    return """
+    return f"""
 const thisUrl = new URL(window.location.href);
 const thisUrl = new URL(window.location.href);
 const params = new URLSearchParams(thisUrl.search)
 const params = new URLSearchParams(thisUrl.search)
 
 
-function doRedirect(url) {
-    if (!window.sessionStorage.getItem("authenticated_github_codespaces")) {
+function doRedirect(url) {{
+    if (!window.sessionStorage.getItem("authenticated_github_codespaces")) {{
         const a = document.createElement("a");
         const a = document.createElement("a");
-        if (params.has("redirect_to")) {
+        if (params.has("redirect_to")) {{
             a.href = params.get("redirect_to")
             a.href = params.get("redirect_to")
-        } else if (!window.location.href.startsWith(url)) {
-            a.href = url + `?redirect_to=${window.location.href}`
-        } else {
+        }} else if (!window.location.href.startsWith(url)) {{
+            a.href = url + `?redirect_to=${{window.location.href}}`
+        }} else {{
             return
             return
-        }
+        }}
         a.hidden = true;
         a.hidden = true;
         a.click();
         a.click();
         a.remove();
         a.remove();
         window.sessionStorage.setItem("authenticated_github_codespaces", "true")
         window.sessionStorage.setItem("authenticated_github_codespaces", "true")
-    }
-}
-doRedirect("%s")
-""" % Endpoint.AUTH_CODESPACE.get_url()
+    }}
+}}
+doRedirect("{Endpoint.AUTH_CODESPACE.get_url()}")
+"""
 
 
 
 
 def codespaces_port_forwarding_domain() -> str | None:
 def codespaces_port_forwarding_domain() -> str | None:
@@ -81,7 +81,7 @@ async def auth_codespace() -> HTMLResponse:
         An HTML response with an embedded script to redirect back to the app.
         An HTML response with an embedded script to redirect back to the app.
     """
     """
     return HTMLResponse(
     return HTMLResponse(
-        """
+        f"""
     <html>
     <html>
         <head>
         <head>
             <title>Reflex Github Codespace Forward Successfully Authenticated</title>
             <title>Reflex Github Codespace Forward Successfully Authenticated</title>
@@ -91,10 +91,9 @@ async def auth_codespace() -> HTMLResponse:
                 <h2>Successfully Authenticated</h2>
                 <h2>Successfully Authenticated</h2>
             </center>
             </center>
             <script language="javascript">
             <script language="javascript">
-                %s
+                {redirect_script()}
             </script>
             </script>
         </body>
         </body>
     </html>
     </html>
     """
     """
-        % redirect_script()
     )
     )

+ 2 - 1
reflex/utils/decorator.py

@@ -1,7 +1,8 @@
 """Decorator utilities."""
 """Decorator utilities."""
 
 
 import functools
 import functools
-from typing import Callable, ParamSpec, TypeVar
+from collections.abc import Callable
+from typing import ParamSpec, TypeVar
 
 
 T = TypeVar("T")
 T = TypeVar("T")
 
 

+ 1 - 1
reflex/utils/exec.py

@@ -10,8 +10,8 @@ import platform
 import re
 import re
 import subprocess
 import subprocess
 import sys
 import sys
+from collections.abc import Sequence
 from pathlib import Path
 from pathlib import Path
-from typing import Sequence
 from urllib.parse import urljoin
 from urllib.parse import urljoin
 
 
 import psutil
 import psutil

+ 2 - 2
reflex/utils/format.py

@@ -6,7 +6,7 @@ import inspect
 import json
 import json
 import os
 import os
 import re
 import re
-from typing import TYPE_CHECKING, Any, Union
+from typing import TYPE_CHECKING, Any
 
 
 from reflex import constants
 from reflex import constants
 from reflex.constants.state import FRONTEND_EVENT_STATE
 from reflex.constants.state import FRONTEND_EVENT_STATE
@@ -369,7 +369,7 @@ def format_match(
 
 
 
 
 def format_prop(
 def format_prop(
-    prop: Union[Var, EventChain, ComponentStyle, str],
+    prop: Var | EventChain | ComponentStyle | str,
 ) -> int | float | str:
 ) -> int | float | str:
     """Format a prop.
     """Format a prop.
 
 

+ 6 - 8
reflex/utils/imports.py

@@ -4,7 +4,7 @@ from __future__ import annotations
 
 
 import dataclasses
 import dataclasses
 from collections import defaultdict
 from collections import defaultdict
-from typing import DefaultDict, Mapping, Sequence, Union
+from collections.abc import Mapping, Sequence
 
 
 
 
 def merge_imports(
 def merge_imports(
@@ -18,7 +18,7 @@ def merge_imports(
     Returns:
     Returns:
         The merged import dicts.
         The merged import dicts.
     """
     """
-    all_imports: DefaultDict[str, list[ImportVar]] = defaultdict(list)
+    all_imports: defaultdict[str, list[ImportVar]] = defaultdict(list)
     for import_dict in imports:
     for import_dict in imports:
         for lib, fields in (
         for lib, fields in (
             import_dict if isinstance(import_dict, tuple) else import_dict.items()
             import_dict if isinstance(import_dict, tuple) else import_dict.items()
@@ -31,10 +31,8 @@ def merge_imports(
             )
             )
             if isinstance(fields, (list, tuple, set)):
             if isinstance(fields, (list, tuple, set)):
                 all_imports[lib].extend(
                 all_imports[lib].extend(
-                    (
-                        ImportVar(field) if isinstance(field, str) else field
-                        for field in fields
-                    )
+                    ImportVar(field) if isinstance(field, str) else field
+                    for field in fields
                 )
                 )
             else:
             else:
                 all_imports[lib].append(
                 all_imports[lib].append(
@@ -135,8 +133,8 @@ class ImportVar:
             return self.tag or ""
             return self.tag or ""
 
 
 
 
-ImportTypes = Union[str, ImportVar, list[str | ImportVar], list[ImportVar]]
-ImmutableImportTypes = Union[str, ImportVar, Sequence[str | ImportVar]]
+ImportTypes = str | ImportVar | list[str | ImportVar] | list[ImportVar]
+ImmutableImportTypes = str | ImportVar | Sequence[str | ImportVar]
 ImportDict = dict[str, ImportTypes]
 ImportDict = dict[str, ImportTypes]
 ImmutableImportDict = Mapping[str, ImmutableImportTypes]
 ImmutableImportDict = Mapping[str, ImmutableImportTypes]
 ParsedImportDict = dict[str, list[ImportVar]]
 ParsedImportDict = dict[str, list[ImportVar]]

+ 2 - 1
reflex/utils/misc.py

@@ -1,7 +1,8 @@
 """Miscellaneous functions for the experimental package."""
 """Miscellaneous functions for the experimental package."""
 
 
 import asyncio
 import asyncio
-from typing import Any, Callable
+from collections.abc import Callable
+from typing import Any
 
 
 
 
 async def run_in_thread(func: Callable) -> Any:
 async def run_in_thread(func: Callable) -> Any:

+ 2 - 1
reflex/utils/net.py

@@ -2,7 +2,8 @@
 
 
 import functools
 import functools
 import time
 import time
-from typing import Callable, ParamSpec, TypeVar
+from collections.abc import Callable
+from typing import ParamSpec, TypeVar
 
 
 import httpx
 import httpx
 
 

+ 3 - 2
reflex/utils/prerequisites.py

@@ -20,10 +20,11 @@ import tempfile
 import time
 import time
 import typing
 import typing
 import zipfile
 import zipfile
+from collections.abc import Callable, Sequence
 from datetime import datetime
 from datetime import datetime
 from pathlib import Path
 from pathlib import Path
 from types import ModuleType
 from types import ModuleType
-from typing import Callable, NamedTuple, Sequence
+from typing import NamedTuple
 from urllib.parse import urlparse
 from urllib.parse import urlparse
 
 
 import httpx
 import httpx
@@ -2048,7 +2049,7 @@ def _retrieve_cpu_info() -> CpuInfo | None:
     )
     )
 
 
 
 
-@functools.lru_cache(maxsize=None)
+@functools.cache
 def get_cpu_info() -> CpuInfo | None:
 def get_cpu_info() -> CpuInfo | None:
     """Get the CPU info of the underlining host.
     """Get the CPU info of the underlining host.
 
 

+ 6 - 5
reflex/utils/processes.py

@@ -8,9 +8,10 @@ import importlib.metadata
 import os
 import os
 import signal
 import signal
 import subprocess
 import subprocess
+from collections.abc import Callable, Generator, Sequence
 from concurrent import futures
 from concurrent import futures
 from pathlib import Path
 from pathlib import Path
-from typing import Any, Callable, Generator, Literal, Sequence, Tuple, overload
+from typing import Any, Literal, overload
 
 
 import psutil
 import psutil
 import typer
 import typer
@@ -261,7 +262,7 @@ def run_concurrently_context(
             executor.shutdown(wait=False)
             executor.shutdown(wait=False)
 
 
 
 
-def run_concurrently(*fns: Callable | Tuple) -> None:
+def run_concurrently(*fns: Callable | tuple) -> None:
     """Run functions concurrently in a thread pool.
     """Run functions concurrently in a thread pool.
 
 
     Args:
     Args:
@@ -277,7 +278,7 @@ def stream_logs(
     progress: Progress | None = None,
     progress: Progress | None = None,
     suppress_errors: bool = False,
     suppress_errors: bool = False,
     analytics_enabled: bool = False,
     analytics_enabled: bool = False,
-    prior_logs: Tuple[tuple[str, ...], ...] = (),
+    prior_logs: tuple[tuple[str, ...], ...] = (),
 ):
 ):
     """Stream the logs for a process.
     """Stream the logs for a process.
 
 
@@ -371,7 +372,7 @@ def show_status(
     process: subprocess.Popen,
     process: subprocess.Popen,
     suppress_errors: bool = False,
     suppress_errors: bool = False,
     analytics_enabled: bool = False,
     analytics_enabled: bool = False,
-    prior_logs: Tuple[tuple[str, ...], ...] = (),
+    prior_logs: tuple[tuple[str, ...], ...] = (),
 ) -> list[str]:
 ) -> list[str]:
     """Show the status of a process.
     """Show the status of a process.
 
 
@@ -451,7 +452,7 @@ def run_process_with_fallbacks(
     show_status_message: str,
     show_status_message: str,
     fallbacks: str | Sequence[str] | Sequence[Sequence[str]] | None = None,
     fallbacks: str | Sequence[str] | Sequence[Sequence[str]] | None = None,
     analytics_enabled: bool = False,
     analytics_enabled: bool = False,
-    prior_logs: Tuple[tuple[str, ...], ...] = (),
+    prior_logs: tuple[tuple[str, ...], ...] = (),
     **kwargs,
     **kwargs,
 ):
 ):
     """Run subprocess and retry using fallback command if initial command fails.
     """Run subprocess and retry using fallback command if initial command fails.

+ 6 - 5
reflex/utils/pyi_generator.py

@@ -11,6 +11,7 @@ import logging
 import re
 import re
 import subprocess
 import subprocess
 import typing
 import typing
+from collections.abc import Callable, Iterable, Sequence
 from fileinput import FileInput
 from fileinput import FileInput
 from hashlib import md5
 from hashlib import md5
 from inspect import getfullargspec
 from inspect import getfullargspec
@@ -18,7 +19,7 @@ from itertools import chain
 from multiprocessing import Pool, cpu_count
 from multiprocessing import Pool, cpu_count
 from pathlib import Path
 from pathlib import Path
 from types import ModuleType, SimpleNamespace, UnionType
 from types import ModuleType, SimpleNamespace, UnionType
-from typing import Any, Callable, Iterable, Sequence, Type, get_args, get_origin
+from typing import Any, get_args, get_origin
 
 
 from reflex.components.component import Component
 from reflex.components.component import Component
 from reflex.utils import types as rx_types
 from reflex.utils import types as rx_types
@@ -167,7 +168,7 @@ def _get_type_hint(
 
 
     if args:
     if args:
         inner_container_type_args = (
         inner_container_type_args = (
-            sorted((repr(arg) for arg in args))
+            sorted(repr(arg) for arg in args)
             if rx_types.is_literal(value)
             if rx_types.is_literal(value)
             else [
             else [
                 _get_type_hint(arg, type_hint_globals, is_optional=False)
                 _get_type_hint(arg, type_hint_globals, is_optional=False)
@@ -246,7 +247,7 @@ def _generate_imports(
     ]
     ]
 
 
 
 
-def _generate_docstrings(clzs: list[Type[Component]], props: list[str]) -> str:
+def _generate_docstrings(clzs: list[type[Component]], props: list[str]) -> str:
     """Generate the docstrings for the create method.
     """Generate the docstrings for the create method.
 
 
     Args:
     Args:
@@ -335,7 +336,7 @@ def _extract_func_kwargs_as_ast_nodes(
 
 
 def _extract_class_props_as_ast_nodes(
 def _extract_class_props_as_ast_nodes(
     func: Callable,
     func: Callable,
-    clzs: list[Type],
+    clzs: list[type],
     type_hint_globals: dict[str, Any],
     type_hint_globals: dict[str, Any],
     extract_real_default: bool = False,
     extract_real_default: bool = False,
 ) -> list[tuple[ast.arg, ast.Constant | None]]:
 ) -> list[tuple[ast.arg, ast.Constant | None]]:
@@ -769,7 +770,7 @@ class StubGenerator(ast.NodeTransformer):
     """A node transformer that will generate the stubs for a given module."""
     """A node transformer that will generate the stubs for a given module."""
 
 
     def __init__(
     def __init__(
-        self, module: ModuleType, classes: dict[str, Type[Component | SimpleNamespace]]
+        self, module: ModuleType, classes: dict[str, type[Component | SimpleNamespace]]
     ):
     ):
         """Initialize the stub generator.
         """Initialize the stub generator.
 
 

+ 13 - 25
reflex/utils/serializers.py

@@ -8,20 +8,11 @@ import functools
 import inspect
 import inspect
 import json
 import json
 import warnings
 import warnings
+from collections.abc import Callable, Sequence
 from datetime import date, datetime, time, timedelta
 from datetime import date, datetime, time, timedelta
 from enum import Enum
 from enum import Enum
 from pathlib import Path
 from pathlib import Path
-from typing import (
-    Any,
-    Callable,
-    Literal,
-    Sequence,
-    Type,
-    TypeVar,
-    Union,
-    get_type_hints,
-    overload,
-)
+from typing import Any, Literal, TypeVar, get_type_hints, overload
 from uuid import UUID
 from uuid import UUID
 
 
 from pydantic import BaseModel as BaseModelV2
 from pydantic import BaseModel as BaseModelV2
@@ -33,14 +24,14 @@ from reflex.utils import console, types
 
 
 # Mapping from type to a serializer.
 # Mapping from type to a serializer.
 # The serializer should convert the type to a JSON object.
 # The serializer should convert the type to a JSON object.
-SerializedType = Union[str, bool, int, float, list, dict, None]
+SerializedType = str | bool | int | float | list | dict | None
 
 
 
 
 Serializer = Callable[[Any], SerializedType]
 Serializer = Callable[[Any], SerializedType]
 
 
 
 
-SERIALIZERS: dict[Type, Serializer] = {}
-SERIALIZER_TYPES: dict[Type, Type] = {}
+SERIALIZERS: dict[type, Serializer] = {}
+SERIALIZER_TYPES: dict[type, type] = {}
 
 
 SERIALIZED_FUNCTION = TypeVar("SERIALIZED_FUNCTION", bound=Serializer)
 SERIALIZED_FUNCTION = TypeVar("SERIALIZED_FUNCTION", bound=Serializer)
 
 
@@ -48,7 +39,7 @@ SERIALIZED_FUNCTION = TypeVar("SERIALIZED_FUNCTION", bound=Serializer)
 @overload
 @overload
 def serializer(
 def serializer(
     fn: None = None,
     fn: None = None,
-    to: Type[SerializedType] | None = None,
+    to: type[SerializedType] | None = None,
     overwrite: bool | None = None,
     overwrite: bool | None = None,
 ) -> Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]: ...
 ) -> Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]: ...
 
 
@@ -56,7 +47,7 @@ def serializer(
 @overload
 @overload
 def serializer(
 def serializer(
     fn: SERIALIZED_FUNCTION,
     fn: SERIALIZED_FUNCTION,
-    to: Type[SerializedType] | None = None,
+    to: type[SerializedType] | None = None,
     overwrite: bool | None = None,
     overwrite: bool | None = None,
 ) -> SERIALIZED_FUNCTION: ...
 ) -> SERIALIZED_FUNCTION: ...
 
 
@@ -146,10 +137,7 @@ def serialize(value: Any) -> SerializedType | None: ...
 
 
 def serialize(
 def serialize(
     value: Any, get_type: bool = False
     value: Any, get_type: bool = False
-) -> Union[
-    SerializedType | None,
-    tuple[SerializedType | None, types.GenericType | None],
-]:
+) -> SerializedType | None | tuple[SerializedType | None, types.GenericType | None]:
     """Serialize the value to a JSON string.
     """Serialize the value to a JSON string.
 
 
     Args:
     Args:
@@ -182,7 +170,7 @@ def serialize(
 
 
 
 
 @functools.lru_cache
 @functools.lru_cache
-def get_serializer(type_: Type) -> Serializer | None:
+def get_serializer(type_: type) -> Serializer | None:
     """Get the serializer for the type.
     """Get the serializer for the type.
 
 
     Args:
     Args:
@@ -206,7 +194,7 @@ def get_serializer(type_: Type) -> Serializer | None:
 
 
 
 
 @functools.lru_cache
 @functools.lru_cache
-def get_serializer_type(type_: Type) -> Type | None:
+def get_serializer_type(type_: type) -> type | None:
     """Get the converted type for the type after serializing.
     """Get the converted type for the type after serializing.
 
 
     Args:
     Args:
@@ -229,7 +217,7 @@ def get_serializer_type(type_: Type) -> Type | None:
     return None
     return None
 
 
 
 
-def has_serializer(type_: Type, into_type: Type | None = None) -> bool:
+def has_serializer(type_: type, into_type: type | None = None) -> bool:
     """Check if there is a serializer for the type.
     """Check if there is a serializer for the type.
 
 
     Args:
     Args:
@@ -245,7 +233,7 @@ def has_serializer(type_: Type, into_type: Type | None = None) -> bool:
     )
     )
 
 
 
 
-def can_serialize(type_: Type, into_type: Type | None = None) -> bool:
+def can_serialize(type_: type, into_type: type | None = None) -> bool:
     """Check if there is a serializer for the type.
     """Check if there is a serializer for the type.
 
 
     Args:
     Args:
@@ -347,7 +335,7 @@ def serialize_sequence(value: Sequence) -> list:
 
 
 
 
 @serializer(to=str)
 @serializer(to=str)
-def serialize_datetime(dt: Union[date, datetime, time, timedelta]) -> str:
+def serialize_datetime(dt: date | datetime | time | timedelta) -> str:
     """Serialize a datetime to a JSON string.
     """Serialize a datetime to a JSON string.
 
 
     Args:
     Args:

+ 27 - 33
reflex/utils/types.py

@@ -5,25 +5,19 @@ from __future__ import annotations
 import dataclasses
 import dataclasses
 import inspect
 import inspect
 import types
 import types
+from collections.abc import Callable, Iterable, Mapping, Sequence
 from functools import cached_property, lru_cache, wraps
 from functools import cached_property, lru_cache, wraps
 from types import GenericAlias
 from types import GenericAlias
-from typing import (
+from typing import (  # noqa: UP035
     TYPE_CHECKING,
     TYPE_CHECKING,
     Any,
     Any,
-    Callable,
     ClassVar,
     ClassVar,
     Dict,
     Dict,
     ForwardRef,
     ForwardRef,
-    FrozenSet,
-    Iterable,
     List,
     List,
     Literal,
     Literal,
-    Mapping,
     NoReturn,
     NoReturn,
-    Optional,
-    Sequence,
     Tuple,
     Tuple,
-    Type,
     Union,
     Union,
     _GenericAlias,  # pyright: ignore [reportAttributeAccessIssue]
     _GenericAlias,  # pyright: ignore [reportAttributeAccessIssue]
     _SpecialGenericAlias,  # pyright: ignore [reportAttributeAccessIssue]
     _SpecialGenericAlias,  # pyright: ignore [reportAttributeAccessIssue]
@@ -54,11 +48,11 @@ GenericAliasTypes = (_GenericAlias, GenericAlias, _SpecialGenericAlias)
 UnionTypes = (Union, types.UnionType)
 UnionTypes = (Union, types.UnionType)
 
 
 # Union of generic types.
 # Union of generic types.
-GenericType = Type | _GenericAlias
+GenericType = type | _GenericAlias
 
 
 # Valid state var types.
 # Valid state var types.
 JSONType = {str, int, float, bool}
 JSONType = {str, int, float, bool}
-PrimitiveType = Union[int, float, bool, str, list, dict, set, tuple]
+PrimitiveType = int | float | bool | str | list | dict | set | tuple
 PrimitiveTypes = (int, float, bool, str, list, dict, set, tuple)
 PrimitiveTypes = (int, float, bool, str, list, dict, set, tuple)
 StateVar = PrimitiveType | Base | None
 StateVar = PrimitiveType | Base | None
 StateIterVar = list | set | tuple
 StateIterVar = list | set | tuple
@@ -81,9 +75,9 @@ else:
 
 
 
 
 PrimitiveToAnnotation = {
 PrimitiveToAnnotation = {
-    list: List,
-    tuple: Tuple,
-    dict: Dict,
+    list: List,  # noqa: UP006
+    tuple: Tuple,  # noqa: UP006
+    dict: Dict,  # noqa: UP006
 }
 }
 
 
 RESERVED_BACKEND_VAR_NAMES = {
 RESERVED_BACKEND_VAR_NAMES = {
@@ -116,7 +110,7 @@ class Unset:
         return False
         return False
 
 
 
 
-@lru_cache()
+@lru_cache
 def get_origin(tp: Any):
 def get_origin(tp: Any):
     """Get the origin of a class.
     """Get the origin of a class.
 
 
@@ -129,7 +123,7 @@ def get_origin(tp: Any):
     return get_origin_og(tp)
     return get_origin_og(tp)
 
 
 
 
-@lru_cache()
+@lru_cache
 def is_generic_alias(cls: GenericType) -> bool:
 def is_generic_alias(cls: GenericType) -> bool:
     """Check whether the class is a generic alias.
     """Check whether the class is a generic alias.
 
 
@@ -142,8 +136,8 @@ def is_generic_alias(cls: GenericType) -> bool:
     return isinstance(cls, GenericAliasTypes)
     return isinstance(cls, GenericAliasTypes)
 
 
 
 
-@lru_cache()
-def get_type_hints(obj: Any) -> Dict[str, Any]:
+@lru_cache
+def get_type_hints(obj: Any) -> dict[str, Any]:
     """Get the type hints of a class.
     """Get the type hints of a class.
 
 
     Args:
     Args:
@@ -155,7 +149,7 @@ def get_type_hints(obj: Any) -> Dict[str, Any]:
     return get_type_hints_og(obj)
     return get_type_hints_og(obj)
 
 
 
 
-def _unionize(args: list[GenericType]) -> Type:
+def _unionize(args: list[GenericType]) -> type:
     if not args:
     if not args:
         return Any  # pyright: ignore [reportReturnType]
         return Any  # pyright: ignore [reportReturnType]
     if len(args) == 1:
     if len(args) == 1:
@@ -164,10 +158,10 @@ def _unionize(args: list[GenericType]) -> Type:
     # In Python versions >= 3.11, we can simply do `return Union[*args]`
     # In Python versions >= 3.11, we can simply do `return Union[*args]`
     midpoint = len(args) // 2
     midpoint = len(args) // 2
     first_half, second_half = args[:midpoint], args[midpoint:]
     first_half, second_half = args[:midpoint], args[midpoint:]
-    return Union[unionize(*first_half), unionize(*second_half)]  # pyright: ignore [reportReturnType]
+    return Union[unionize(*first_half), unionize(*second_half)]  # pyright: ignore [reportReturnType]  # noqa: UP007
 
 
 
 
-def unionize(*args: GenericType) -> Type:
+def unionize(*args: GenericType) -> type:
     """Unionize the types.
     """Unionize the types.
 
 
     Args:
     Args:
@@ -191,7 +185,7 @@ def is_none(cls: GenericType) -> bool:
     return cls is type(None) or cls is None
     return cls is type(None) or cls is None
 
 
 
 
-@lru_cache()
+@lru_cache
 def is_union(cls: GenericType) -> bool:
 def is_union(cls: GenericType) -> bool:
     """Check if a class is a Union.
     """Check if a class is a Union.
 
 
@@ -204,7 +198,7 @@ def is_union(cls: GenericType) -> bool:
     return get_origin(cls) in UnionTypes
     return get_origin(cls) in UnionTypes
 
 
 
 
-@lru_cache()
+@lru_cache
 def is_literal(cls: GenericType) -> bool:
 def is_literal(cls: GenericType) -> bool:
     """Check if a class is a Literal.
     """Check if a class is a Literal.
 
 
@@ -217,7 +211,7 @@ def is_literal(cls: GenericType) -> bool:
     return get_origin(cls) is Literal
     return get_origin(cls) is Literal
 
 
 
 
-def has_args(cls: Type) -> bool:
+def has_args(cls: type) -> bool:
     """Check if the class has generic parameters.
     """Check if the class has generic parameters.
 
 
     Args:
     Args:
@@ -272,7 +266,7 @@ def true_type_for_pydantic_field(f: ModelField):
             and f.annotation.__forward_arg__.startswith("Optional")
             and f.annotation.__forward_arg__.startswith("Optional")
         )
         )
     ) and not is_optional(type_):
     ) and not is_optional(type_):
-        return Optional[type_]
+        return type_ | None
 
 
     return type_
     return type_
 
 
@@ -424,8 +418,8 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
     return None  # Attribute is not accessible.
     return None  # Attribute is not accessible.
 
 
 
 
-@lru_cache()
-def get_base_class(cls: GenericType) -> Type:
+@lru_cache
+def get_base_class(cls: GenericType) -> type:
     """Get the base class of a class.
     """Get the base class of a class.
 
 
     Args:
     Args:
@@ -544,7 +538,7 @@ def does_obj_satisfy_typed_dict(obj: Any, cls: GenericType) -> bool:
         return False
         return False
 
 
     key_names_to_values = get_type_hints(cls)
     key_names_to_values = get_type_hints(cls)
-    required_keys: FrozenSet[str] = getattr(cls, "__required_keys__", frozenset())
+    required_keys: frozenset[str] = getattr(cls, "__required_keys__", frozenset())
 
 
     if not all(
     if not all(
         isinstance(key, str)
         isinstance(key, str)
@@ -726,7 +720,7 @@ def _isinstance(
     return isinstance(obj, get_base_class(cls))
     return isinstance(obj, get_base_class(cls))
 
 
 
 
-def is_dataframe(value: Type) -> bool:
+def is_dataframe(value: type) -> bool:
     """Check if the given value is a dataframe.
     """Check if the given value is a dataframe.
 
 
     Args:
     Args:
@@ -740,7 +734,7 @@ def is_dataframe(value: Type) -> bool:
     return value.__name__ == "DataFrame"
     return value.__name__ == "DataFrame"
 
 
 
 
-def is_valid_var_type(type_: Type) -> bool:
+def is_valid_var_type(type_: type) -> bool:
     """Check if the given type is a valid prop type.
     """Check if the given type is a valid prop type.
 
 
     Args:
     Args:
@@ -752,7 +746,7 @@ def is_valid_var_type(type_: Type) -> bool:
     from reflex.utils import serializers
     from reflex.utils import serializers
 
 
     if is_union(type_):
     if is_union(type_):
-        return all((is_valid_var_type(arg) for arg in get_args(type_)))
+        return all(is_valid_var_type(arg) for arg in get_args(type_))
     return (
     return (
         _issubclass(type_, StateVar)
         _issubclass(type_, StateVar)
         or serializers.has_serializer(type_)
         or serializers.has_serializer(type_)
@@ -760,7 +754,7 @@ def is_valid_var_type(type_: Type) -> bool:
     )
     )
 
 
 
 
-def is_backend_base_variable(name: str, cls: Type) -> bool:
+def is_backend_base_variable(name: str, cls: type) -> bool:
     """Check if this variable name correspond to a backend variable.
     """Check if this variable name correspond to a backend variable.
 
 
     Args:
     Args:
@@ -817,7 +811,7 @@ def is_backend_base_variable(name: str, cls: Type) -> bool:
     return True
     return True
 
 
 
 
-def check_type_in_allowed_types(value_type: Type, allowed_types: Iterable) -> bool:
+def check_type_in_allowed_types(value_type: type, allowed_types: Iterable) -> bool:
     """Check that a value type is found in a list of allowed types.
     """Check that a value type is found in a list of allowed types.
 
 
     Args:
     Args:
@@ -859,7 +853,7 @@ def is_encoded_fstring(value: Any) -> bool:
     return isinstance(value, str) and constants.REFLEX_VAR_OPENING_TAG in value
     return isinstance(value, str) and constants.REFLEX_VAR_OPENING_TAG in value
 
 
 
 
-def validate_literal(key: str, value: Any, expected_type: Type, comp_name: str):
+def validate_literal(key: str, value: Any, expected_type: type, comp_name: str):
     """Check that a value is a valid literal.
     """Check that a value is a valid literal.
 
 
     Args:
     Args:

+ 49 - 55
reflex/vars/base.py

@@ -14,30 +14,24 @@ import re
 import string
 import string
 import uuid
 import uuid
 import warnings
 import warnings
+from collections.abc import Callable, Coroutine, Iterable, Mapping, Sequence
 from types import CodeType, FunctionType
 from types import CodeType, FunctionType
-from typing import (
+from typing import (  # noqa: UP035
     TYPE_CHECKING,
     TYPE_CHECKING,
     Any,
     Any,
-    Callable,
     ClassVar,
     ClassVar,
-    Coroutine,
     Dict,
     Dict,
     FrozenSet,
     FrozenSet,
     Generic,
     Generic,
-    Iterable,
     List,
     List,
     Literal,
     Literal,
-    Mapping,
     NoReturn,
     NoReturn,
     ParamSpec,
     ParamSpec,
     Protocol,
     Protocol,
-    Sequence,
     Set,
     Set,
     Tuple,
     Tuple,
-    Type,
     TypeGuard,
     TypeGuard,
     TypeVar,
     TypeVar,
-    Union,
     cast,
     cast,
     get_args,
     get_args,
     get_type_hints,
     get_type_hints,
@@ -102,13 +96,13 @@ warnings.filterwarnings("ignore", message="fields may not start with an undersco
 class VarSubclassEntry:
 class VarSubclassEntry:
     """Entry for a Var subclass."""
     """Entry for a Var subclass."""
 
 
-    var_subclass: Type[Var]
-    to_var_subclass: Type[ToOperation]
+    var_subclass: type[Var]
+    to_var_subclass: type[ToOperation]
     python_types: tuple[GenericType, ...]
     python_types: tuple[GenericType, ...]
 
 
 
 
 _var_subclasses: list[VarSubclassEntry] = []
 _var_subclasses: list[VarSubclassEntry] = []
-_var_literal_subclasses: list[tuple[Type[LiteralVar], VarSubclassEntry]] = []
+_var_literal_subclasses: list[tuple[type[LiteralVar], VarSubclassEntry]] = []
 
 
 
 
 @dataclasses.dataclass(
 @dataclasses.dataclass(
@@ -137,7 +131,7 @@ class VarData:
     position: Hooks.HookPosition | None = None
     position: Hooks.HookPosition | None = None
 
 
     # Components that are part of this var
     # Components that are part of this var
-    components: Tuple[BaseComponent, ...] = dataclasses.field(default_factory=tuple)
+    components: tuple[BaseComponent, ...] = dataclasses.field(default_factory=tuple)
 
 
     def __init__(
     def __init__(
         self,
         self,
@@ -284,7 +278,7 @@ class VarData:
         )
         )
 
 
     @classmethod
     @classmethod
-    def from_state(cls, state: Type[BaseState] | str, field_name: str = "") -> VarData:
+    def from_state(cls, state: type[BaseState] | str, field_name: str = "") -> VarData:
         """Set the state of the var.
         """Set the state of the var.
 
 
         Args:
         Args:
@@ -534,7 +528,7 @@ class Var(Generic[VAR_TYPE]):
     @overload
     @overload
     def _replace(
     def _replace(
         self,
         self,
-        _var_type: Type[OTHER_VAR_TYPE],
+        _var_type: type[OTHER_VAR_TYPE],
         merge_var_data: VarData | None = None,
         merge_var_data: VarData | None = None,
         **kwargs: Any,
         **kwargs: Any,
     ) -> Var[OTHER_VAR_TYPE]: ...
     ) -> Var[OTHER_VAR_TYPE]: ...
@@ -726,10 +720,10 @@ class Var(Generic[VAR_TYPE]):
         return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._js_expr}"
         return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._js_expr}"
 
 
     @overload
     @overload
-    def to(self, output: Type[str]) -> StringVar: ...
+    def to(self, output: type[str]) -> StringVar: ...
 
 
     @overload
     @overload
-    def to(self, output: Type[bool]) -> BooleanVar: ...
+    def to(self, output: type[bool]) -> BooleanVar: ...
 
 
     @overload
     @overload
     def to(self, output: type[int]) -> NumberVar[int]: ...
     def to(self, output: type[int]) -> NumberVar[int]: ...
@@ -751,12 +745,12 @@ class Var(Generic[VAR_TYPE]):
 
 
     @overload
     @overload
     def to(
     def to(
-        self, output: Type[ObjectVar], var_type: Type[VAR_INSIDE]
+        self, output: type[ObjectVar], var_type: type[VAR_INSIDE]
     ) -> ObjectVar[VAR_INSIDE]: ...
     ) -> ObjectVar[VAR_INSIDE]: ...
 
 
     @overload
     @overload
     def to(
     def to(
-        self, output: Type[ObjectVar], var_type: None = None
+        self, output: type[ObjectVar], var_type: None = None
     ) -> ObjectVar[VAR_TYPE]: ...
     ) -> ObjectVar[VAR_TYPE]: ...
 
 
     @overload
     @overload
@@ -765,13 +759,13 @@ class Var(Generic[VAR_TYPE]):
     @overload
     @overload
     def to(
     def to(
         self,
         self,
-        output: Type[OUTPUT] | types.GenericType,
+        output: type[OUTPUT] | types.GenericType,
         var_type: types.GenericType | None = None,
         var_type: types.GenericType | None = None,
     ) -> OUTPUT: ...
     ) -> OUTPUT: ...
 
 
     def to(
     def to(
         self,
         self,
-        output: Type[OUTPUT] | types.GenericType,
+        output: type[OUTPUT] | types.GenericType,
         var_type: types.GenericType | None = None,
         var_type: types.GenericType | None = None,
     ) -> Var:
     ) -> Var:
         """Convert the var to a different type.
         """Convert the var to a different type.
@@ -1841,7 +1835,7 @@ class cached_property:  # noqa: N801
                 f"({self._attrname!r} and {name!r})."
                 f"({self._attrname!r} and {name!r})."
             )
             )
 
 
-    def __get__(self, instance: Any, owner: Type | None = None):
+    def __get__(self, instance: Any, owner: type | None = None):
         """Get the cached property.
         """Get the cached property.
 
 
         Args:
         Args:
@@ -2144,7 +2138,7 @@ class ComputedVar(Var[RETURN_TYPE]):
 
 
     def _calculate_static_deps(
     def _calculate_static_deps(
         self,
         self,
-        deps: Union[list[str | Var], dict[str | None, set[str]]] | None = None,
+        deps: list[str | Var] | dict[str | None, set[str]] | None = None,
     ) -> dict[str | None, set[str]]:
     ) -> dict[str | None, set[str]]:
         """Calculate the static dependencies of the computed var from user input or existing dependencies.
         """Calculate the static dependencies of the computed var from user input or existing dependencies.
 
 
@@ -2279,56 +2273,56 @@ class ComputedVar(Var[RETURN_TYPE]):
     def __get__(
     def __get__(
         self: ComputedVar[bool],
         self: ComputedVar[bool],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> BooleanVar: ...
     ) -> BooleanVar: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[int] | ComputedVar[float],
         self: ComputedVar[int] | ComputedVar[float],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> NumberVar: ...
     ) -> NumberVar: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[str],
         self: ComputedVar[str],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> StringVar: ...
     ) -> StringVar: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[MAPPING_TYPE],
         self: ComputedVar[MAPPING_TYPE],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ObjectVar[MAPPING_TYPE]: ...
     ) -> ObjectVar[MAPPING_TYPE]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[list[LIST_INSIDE]],
         self: ComputedVar[list[LIST_INSIDE]],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ArrayVar[list[LIST_INSIDE]]: ...
     ) -> ArrayVar[list[LIST_INSIDE]]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[tuple[LIST_INSIDE, ...]],
         self: ComputedVar[tuple[LIST_INSIDE, ...]],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
     ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[BASE_TYPE],
         self: ComputedVar[BASE_TYPE],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ObjectVar[BASE_TYPE]: ...
     ) -> ObjectVar[BASE_TYPE]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: ComputedVar[SQLA_TYPE],
         self: ComputedVar[SQLA_TYPE],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ObjectVar[SQLA_TYPE]: ...
     ) -> ObjectVar[SQLA_TYPE]: ...
 
 
     if TYPE_CHECKING:
     if TYPE_CHECKING:
@@ -2339,12 +2333,12 @@ class ComputedVar(Var[RETURN_TYPE]):
         ) -> ObjectVar[DATACLASS_TYPE]: ...
         ) -> ObjectVar[DATACLASS_TYPE]: ...
 
 
     @overload
     @overload
-    def __get__(self, instance: None, owner: Type) -> ComputedVar[RETURN_TYPE]: ...
+    def __get__(self, instance: None, owner: type) -> ComputedVar[RETURN_TYPE]: ...
 
 
     @overload
     @overload
-    def __get__(self, instance: BaseState, owner: Type) -> RETURN_TYPE: ...
+    def __get__(self, instance: BaseState, owner: type) -> RETURN_TYPE: ...
 
 
-    def __get__(self, instance: BaseState | None, owner: Type):
+    def __get__(self, instance: BaseState | None, owner: type):
         """Get the ComputedVar value.
         """Get the ComputedVar value.
 
 
         If the value is already cached on the instance, return the cached value.
         If the value is already cached on the instance, return the cached value.
@@ -2400,7 +2394,7 @@ class ComputedVar(Var[RETURN_TYPE]):
 
 
     def _deps(
     def _deps(
         self,
         self,
-        objclass: Type[BaseState],
+        objclass: type[BaseState],
         obj: FunctionType | CodeType | None = None,
         obj: FunctionType | CodeType | None = None,
     ) -> dict[str, set[str]]:
     ) -> dict[str, set[str]]:
         """Determine var dependencies of this ComputedVar.
         """Determine var dependencies of this ComputedVar.
@@ -2458,7 +2452,7 @@ class ComputedVar(Var[RETURN_TYPE]):
         with contextlib.suppress(AttributeError):
         with contextlib.suppress(AttributeError):
             delattr(instance, self._cache_attr)
             delattr(instance, self._cache_attr)
 
 
-    def add_dependency(self, objclass: Type[BaseState], dep: Var):
+    def add_dependency(self, objclass: type[BaseState], dep: Var):
         """Explicitly add a dependency to the ComputedVar.
         """Explicitly add a dependency to the ComputedVar.
 
 
         After adding the dependency, when the `dep` changes, this computed var
         After adding the dependency, when the `dep` changes, this computed var
@@ -2489,7 +2483,7 @@ class ComputedVar(Var[RETURN_TYPE]):
             f"field name, got {dep!r}."
             f"field name, got {dep!r}."
         )
         )
 
 
-    def _determine_var_type(self) -> Type:
+    def _determine_var_type(self) -> type:
         """Get the type of the var.
         """Get the type of the var.
 
 
         Returns:
         Returns:
@@ -2501,7 +2495,7 @@ class ComputedVar(Var[RETURN_TYPE]):
         return Any  # pyright: ignore [reportReturnType]
         return Any  # pyright: ignore [reportReturnType]
 
 
     @property
     @property
-    def __class__(self) -> Type:
+    def __class__(self) -> type:
         """Get the class of the var.
         """Get the class of the var.
 
 
         Returns:
         Returns:
@@ -2546,56 +2540,56 @@ class AsyncComputedVar(ComputedVar[RETURN_TYPE]):
     def __get__(
     def __get__(
         self: AsyncComputedVar[bool],
         self: AsyncComputedVar[bool],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> BooleanVar: ...
     ) -> BooleanVar: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[int] | ComputedVar[float],
         self: AsyncComputedVar[int] | ComputedVar[float],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> NumberVar: ...
     ) -> NumberVar: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[str],
         self: AsyncComputedVar[str],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> StringVar: ...
     ) -> StringVar: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[MAPPING_TYPE],
         self: AsyncComputedVar[MAPPING_TYPE],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ObjectVar[MAPPING_TYPE]: ...
     ) -> ObjectVar[MAPPING_TYPE]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[list[LIST_INSIDE]],
         self: AsyncComputedVar[list[LIST_INSIDE]],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ArrayVar[list[LIST_INSIDE]]: ...
     ) -> ArrayVar[list[LIST_INSIDE]]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[tuple[LIST_INSIDE, ...]],
         self: AsyncComputedVar[tuple[LIST_INSIDE, ...]],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
     ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[BASE_TYPE],
         self: AsyncComputedVar[BASE_TYPE],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ObjectVar[BASE_TYPE]: ...
     ) -> ObjectVar[BASE_TYPE]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
         self: AsyncComputedVar[SQLA_TYPE],
         self: AsyncComputedVar[SQLA_TYPE],
         instance: None,
         instance: None,
-        owner: Type,
+        owner: type,
     ) -> ObjectVar[SQLA_TYPE]: ...
     ) -> ObjectVar[SQLA_TYPE]: ...
 
 
     if TYPE_CHECKING:
     if TYPE_CHECKING:
@@ -2606,11 +2600,11 @@ class AsyncComputedVar(ComputedVar[RETURN_TYPE]):
         ) -> ObjectVar[DATACLASS_TYPE]: ...
         ) -> ObjectVar[DATACLASS_TYPE]: ...
 
 
     @overload
     @overload
-    def __get__(self, instance: None, owner: Type) -> AsyncComputedVar[RETURN_TYPE]: ...
+    def __get__(self, instance: None, owner: type) -> AsyncComputedVar[RETURN_TYPE]: ...
 
 
     @overload
     @overload
     def __get__(
     def __get__(
-        self, instance: BaseState, owner: Type
+        self, instance: BaseState, owner: type
     ) -> Coroutine[None, None, RETURN_TYPE]: ...
     ) -> Coroutine[None, None, RETURN_TYPE]: ...
 
 
     def __get__(
     def __get__(
@@ -2781,7 +2775,7 @@ class CustomVarOperationReturn(Var[RETURN]):
     def create(
     def create(
         cls,
         cls,
         js_expression: str,
         js_expression: str,
-        _var_type: Type[RETURN] | None = None,
+        _var_type: type[RETURN] | None = None,
         _var_data: VarData | None = None,
         _var_data: VarData | None = None,
     ) -> CustomVarOperationReturn[RETURN]:
     ) -> CustomVarOperationReturn[RETURN]:
         """Create a CustomVarOperation.
         """Create a CustomVarOperation.
@@ -2803,7 +2797,7 @@ class CustomVarOperationReturn(Var[RETURN]):
 
 
 def var_operation_return(
 def var_operation_return(
     js_expression: str,
     js_expression: str,
-    var_type: Type[RETURN] | GenericType | None = None,
+    var_type: type[RETURN] | GenericType | None = None,
     var_data: VarData | None = None,
     var_data: VarData | None = None,
 ) -> CustomVarOperationReturn[RETURN]:
 ) -> CustomVarOperationReturn[RETURN]:
     """Shortcut for creating a CustomVarOperationReturn.
     """Shortcut for creating a CustomVarOperationReturn.
@@ -2934,7 +2928,7 @@ class LiteralNoneVar(LiteralVar, NoneVar):
         )
         )
 
 
 
 
-def get_to_operation(var_subclass: Type[Var]) -> Type[ToOperation]:
+def get_to_operation(var_subclass: type[Var]) -> type[ToOperation]:
     """Get the ToOperation class for a given Var subclass.
     """Get the ToOperation class for a given Var subclass.
 
 
     Args:
     Args:
@@ -3179,11 +3173,11 @@ def resolve_generic_type_with_mapping(
         return generic_type
         return generic_type
 
 
     mapping_for_older_python = {
     mapping_for_older_python = {
-        list: List,
-        set: Set,
-        dict: Dict,
-        tuple: Tuple,
-        frozenset: FrozenSet,
+        list: List,  # noqa: UP006
+        set: Set,  # noqa: UP006
+        dict: Dict,  # noqa: UP006
+        tuple: Tuple,  # noqa: UP006
+        frozenset: FrozenSet,  # noqa: UP006
     }
     }
 
 
     return mapping_for_older_python.get(generic_origin, generic_origin)[
     return mapping_for_older_python.get(generic_origin, generic_origin)[

+ 4 - 4
reflex/vars/dep_tracking.py

@@ -8,7 +8,7 @@ import dis
 import enum
 import enum
 import inspect
 import inspect
 from types import CellType, CodeType, FunctionType
 from types import CellType, CodeType, FunctionType
-from typing import TYPE_CHECKING, Any, ClassVar, Type, cast
+from typing import TYPE_CHECKING, Any, ClassVar, cast
 
 
 from reflex.utils.exceptions import VarValueError
 from reflex.utils.exceptions import VarValueError
 
 
@@ -50,16 +50,16 @@ class DependencyTracker:
     """State machine for identifying state attributes that are accessed by a function."""
     """State machine for identifying state attributes that are accessed by a function."""
 
 
     func: FunctionType | CodeType = dataclasses.field()
     func: FunctionType | CodeType = dataclasses.field()
-    state_cls: Type[BaseState] = dataclasses.field()
+    state_cls: type[BaseState] = dataclasses.field()
 
 
     dependencies: dict[str, set[str]] = dataclasses.field(default_factory=dict)
     dependencies: dict[str, set[str]] = dataclasses.field(default_factory=dict)
 
 
     scan_status: ScanStatus = dataclasses.field(default=ScanStatus.SCANNING)
     scan_status: ScanStatus = dataclasses.field(default=ScanStatus.SCANNING)
     top_of_stack: str | None = dataclasses.field(default=None)
     top_of_stack: str | None = dataclasses.field(default=None)
 
 
-    tracked_locals: dict[str, Type[BaseState]] = dataclasses.field(default_factory=dict)
+    tracked_locals: dict[str, type[BaseState]] = dataclasses.field(default_factory=dict)
 
 
-    _getting_state_class: Type[BaseState] | None = dataclasses.field(default=None)
+    _getting_state_class: type[BaseState] | None = dataclasses.field(default=None)
     _getting_var_instructions: list[dis.Instruction] = dataclasses.field(
     _getting_var_instructions: list[dis.Instruction] = dataclasses.field(
         default_factory=list
         default_factory=list
     )
     )

+ 3 - 13
reflex/vars/function.py

@@ -3,18 +3,8 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import dataclasses
 import dataclasses
-from typing import (
-    Any,
-    Callable,
-    Concatenate,
-    Generic,
-    ParamSpec,
-    Protocol,
-    Sequence,
-    Type,
-    TypeVar,
-    overload,
-)
+from collections.abc import Callable, Sequence
+from typing import Any, Concatenate, Generic, ParamSpec, Protocol, TypeVar, overload
 
 
 from reflex.utils import format
 from reflex.utils import format
 from reflex.utils.types import GenericType
 from reflex.utils.types import GenericType
@@ -211,7 +201,7 @@ class FunctionStringVar(FunctionVar[CALLABLE_TYPE]):
     def create(
     def create(
         cls,
         cls,
         func: str,
         func: str,
-        _var_type: Type[OTHER_CALLABLE_TYPE] = ReflexCallable[Any, Any],
+        _var_type: type[OTHER_CALLABLE_TYPE] = ReflexCallable[Any, Any],
         _var_data: VarData | None = None,
         _var_data: VarData | None = None,
     ) -> FunctionStringVar[OTHER_CALLABLE_TYPE]:
     ) -> FunctionStringVar[OTHER_CALLABLE_TYPE]:
         """Create a new function var from a string.
         """Create a new function var from a string.

+ 5 - 17
reflex/vars/number.py

@@ -5,16 +5,8 @@ from __future__ import annotations
 import dataclasses
 import dataclasses
 import json
 import json
 import math
 import math
-from typing import (
-    TYPE_CHECKING,
-    Any,
-    Callable,
-    NoReturn,
-    Type,
-    TypeVar,
-    Union,
-    overload,
-)
+from collections.abc import Callable
+from typing import TYPE_CHECKING, Any, NoReturn, TypeVar, overload
 
 
 from typing_extensions import TypeVar as TypeVarExt
 from typing_extensions import TypeVar as TypeVarExt
 
 
@@ -491,10 +483,8 @@ class NumberVar(Var[NUMBER_T], python_types=(int, float)):
 
 
         if format_spec:
         if format_spec:
             raise VarValueError(
             raise VarValueError(
-                (
-                    "Unknown format code '{}' for object of type 'NumberVar'. It is only supported to use ',', '_', and '.f' for float numbers."
-                    "If possible, use computed variables instead: https://reflex.dev/docs/vars/computed-vars/"
-                ).format(format_spec)
+                f"Unknown format code '{format_spec}' for object of type 'NumberVar'. It is only supported to use ',', '_', and '.f' for float numbers."
+                "If possible, use computed variables instead: https://reflex.dev/docs/vars/computed-vars/"
             )
             )
 
 
         return super().__format__(format_spec)
         return super().__format__(format_spec)
@@ -1114,9 +1104,7 @@ def ternary_operation(
     Returns:
     Returns:
         The ternary operation.
         The ternary operation.
     """
     """
-    type_value: Union[Type[T], Type[U]] = unionize(
-        if_true._var_type, if_false._var_type
-    )
+    type_value: type[T] | type[U] = unionize(if_true._var_type, if_false._var_type)
     value: CustomVarOperationReturn[T | U] = var_operation_return(
     value: CustomVarOperationReturn[T | U] = var_operation_return(
         js_expression=f"({condition} ? {if_true} : {if_false})",
         js_expression=f"({condition} ? {if_true} : {if_false})",
         var_type=type_value,
         var_type=type_value,

+ 7 - 15
reflex/vars/object.py

@@ -5,17 +5,9 @@ from __future__ import annotations
 import collections.abc
 import collections.abc
 import dataclasses
 import dataclasses
 import typing
 import typing
+from collections.abc import Mapping
 from inspect import isclass
 from inspect import isclass
-from typing import (
-    Any,
-    Mapping,
-    NoReturn,
-    Type,
-    TypeVar,
-    get_args,
-    get_type_hints,
-    overload,
-)
+from typing import Any, NoReturn, TypeVar, get_args, get_type_hints, overload
 
 
 from rich.markup import escape
 from rich.markup import escape
 from typing_extensions import is_typeddict
 from typing_extensions import is_typeddict
@@ -79,7 +71,7 @@ def _determine_value_type(var_type: GenericType):
 class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping):
 class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping):
     """Base class for immutable object vars."""
     """Base class for immutable object vars."""
 
 
-    def _key_type(self) -> Type:
+    def _key_type(self) -> type:
         """Get the type of the keys of the object.
         """Get the type of the keys of the object.
 
 
         Returns:
         Returns:
@@ -90,7 +82,7 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping):
     @overload
     @overload
     def _value_type(
     def _value_type(
         self: ObjectVar[Mapping[Any, VALUE_TYPE]],
         self: ObjectVar[Mapping[Any, VALUE_TYPE]],
-    ) -> Type[VALUE_TYPE]: ...
+    ) -> type[VALUE_TYPE]: ...
 
 
     @overload
     @overload
     def _value_type(self) -> GenericType: ...
     def _value_type(self) -> GenericType: ...
@@ -356,7 +348,7 @@ class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar):
 
 
     _var_value: Mapping[Var | Any, Var | Any] = dataclasses.field(default_factory=dict)
     _var_value: Mapping[Var | Any, Var | Any] = dataclasses.field(default_factory=dict)
 
 
-    def _key_type(self) -> Type:
+    def _key_type(self) -> type:
         """Get the type of the keys of the object.
         """Get the type of the keys of the object.
 
 
         Returns:
         Returns:
@@ -365,7 +357,7 @@ class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar):
         args_list = typing.get_args(self._var_type)
         args_list = typing.get_args(self._var_type)
         return args_list[0] if args_list else Any  # pyright: ignore [reportReturnType]
         return args_list[0] if args_list else Any  # pyright: ignore [reportReturnType]
 
 
-    def _value_type(self) -> Type:
+    def _value_type(self) -> type:
         """Get the type of the values of the object.
         """Get the type of the values of the object.
 
 
         Returns:
         Returns:
@@ -440,7 +432,7 @@ class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar):
     def create(
     def create(
         cls,
         cls,
         _var_value: Mapping,
         _var_value: Mapping,
-        _var_type: Type[OBJECT_TYPE] | None = None,
+        _var_type: type[OBJECT_TYPE] | None = None,
         _var_data: VarData | None = None,
         _var_data: VarData | None = None,
     ) -> LiteralObjectVar[OBJECT_TYPE]:
     ) -> LiteralObjectVar[OBJECT_TYPE]:
         """Create the literal object var.
         """Create the literal object var.

+ 11 - 23
reflex/vars/sequence.py

@@ -7,20 +7,8 @@ import dataclasses
 import inspect
 import inspect
 import json
 import json
 import re
 import re
-from typing import (
-    TYPE_CHECKING,
-    Any,
-    Iterable,
-    List,
-    Literal,
-    Mapping,
-    Sequence,
-    Type,
-    TypeVar,
-    Union,
-    get_args,
-    overload,
-)
+from collections.abc import Iterable, Mapping, Sequence
+from typing import TYPE_CHECKING, Any, Literal, TypeVar, get_args, overload
 
 
 from typing_extensions import TypeVar as TypingExtensionsTypeVar
 from typing_extensions import TypeVar as TypingExtensionsTypeVar
 
 
@@ -251,7 +239,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
 
 
     @overload
     @overload
     @classmethod
     @classmethod
-    def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ...
+    def range(cls, stop: int | NumberVar, /) -> ArrayVar[list[int]]: ...
 
 
     @overload
     @overload
     @classmethod
     @classmethod
@@ -261,7 +249,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
         end: int | NumberVar,
         end: int | NumberVar,
         step: int | NumberVar = 1,
         step: int | NumberVar = 1,
         /,
         /,
-    ) -> ArrayVar[List[int]]: ...
+    ) -> ArrayVar[list[int]]: ...
 
 
     @overload
     @overload
     @classmethod
     @classmethod
@@ -270,7 +258,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
         first_endpoint: int | NumberVar,
         first_endpoint: int | NumberVar,
         second_endpoint: int | NumberVar | None = None,
         second_endpoint: int | NumberVar | None = None,
         step: int | NumberVar | None = None,
         step: int | NumberVar | None = None,
-    ) -> ArrayVar[List[int]]: ...
+    ) -> ArrayVar[list[int]]: ...
 
 
     @classmethod
     @classmethod
     def range(
     def range(
@@ -278,7 +266,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
         first_endpoint: int | NumberVar,
         first_endpoint: int | NumberVar,
         second_endpoint: int | NumberVar | None = None,
         second_endpoint: int | NumberVar | None = None,
         step: int | NumberVar | None = None,
         step: int | NumberVar | None = None,
-    ) -> ArrayVar[List[int]]:
+    ) -> ArrayVar[list[int]]:
         """Create a range of numbers.
         """Create a range of numbers.
 
 
         Args:
         Args:
@@ -493,7 +481,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
 class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]):
 class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]):
     """Base class for immutable literal array vars."""
     """Base class for immutable literal array vars."""
 
 
-    _var_value: Sequence[Union[Var, Any]] = dataclasses.field(default=())
+    _var_value: Sequence[Var | Any] = dataclasses.field(default=())
 
 
     @cached_property_no_lock
     @cached_property_no_lock
     def _cached_var_name(self) -> str:
     def _cached_var_name(self) -> str:
@@ -557,7 +545,7 @@ class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]):
     def create(
     def create(
         cls,
         cls,
         value: OTHER_ARRAY_VAR_TYPE,
         value: OTHER_ARRAY_VAR_TYPE,
-        _var_type: Type[OTHER_ARRAY_VAR_TYPE] | None = None,
+        _var_type: type[OTHER_ARRAY_VAR_TYPE] | None = None,
         _var_data: VarData | None = None,
         _var_data: VarData | None = None,
     ) -> LiteralArrayVar[OTHER_ARRAY_VAR_TYPE]:
     ) -> LiteralArrayVar[OTHER_ARRAY_VAR_TYPE]:
         """Create a var from a string value.
         """Create a var from a string value.
@@ -1752,7 +1740,7 @@ def array_concat_operation(
     """
     """
     return var_operation_return(
     return var_operation_return(
         js_expression=f"[...{lhs}, ...{rhs}]",
         js_expression=f"[...{lhs}, ...{rhs}]",
-        var_type=Union[lhs._var_type, rhs._var_type],  # pyright: ignore [reportArgumentType]
+        var_type=lhs._var_type | rhs._var_type,
     )
     )
 
 
 
 
@@ -1774,7 +1762,7 @@ class LiteralColorVar(CachedVarOperation, LiteralVar, ColorVar):
     def create(
     def create(
         cls,
         cls,
         value: Color,
         value: Color,
-        _var_type: Type[Color] | None = None,
+        _var_type: type[Color] | None = None,
         _var_data: VarData | None = None,
         _var_data: VarData | None = None,
     ) -> ColorVar:
     ) -> ColorVar:
         """Create a var from a string value.
         """Create a var from a string value.
@@ -1905,7 +1893,7 @@ class LiteralRangeVar(CachedVarOperation, LiteralVar, RangeVar):
     def create(
     def create(
         cls,
         cls,
         value: range,
         value: range,
-        _var_type: Type[range] | None = None,
+        _var_type: type[range] | None = None,
         _var_data: VarData | None = None,
         _var_data: VarData | None = None,
     ) -> RangeVar:
     ) -> RangeVar:
         """Create a var from a string value.
         """Create a var from a string value.

+ 1 - 1
tests/benchmarks/test_evaluate.py

@@ -1,4 +1,4 @@
-from typing import Callable
+from collections.abc import Callable
 
 
 from pytest_codspeed import BenchmarkFixture
 from pytest_codspeed import BenchmarkFixture
 
 

+ 1 - 1
tests/integration/test_background_task.py

@@ -1,6 +1,6 @@
 """Test @rx.event(background=True) task functionality."""
 """Test @rx.event(background=True) task functionality."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 3 - 8
tests/integration/test_call_script.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By
@@ -433,12 +433,7 @@ def test_call_script(
     assert call_script.poll_for_value(counter, exp_not_equal="0") == "4"
     assert call_script.poll_for_value(counter, exp_not_equal="0") == "4"
     assert (
     assert (
         call_script.poll_for_value(results, exp_not_equal="[]")
         call_script.poll_for_value(results, exp_not_equal="[]")
-        == '["%s1",null,{"%s3":42,"a":[1,2,3],"s":"js","o":{"a":1,"b":2}},"async %s4"]'
-        % (
-            script,
-            script,
-            script,
-        )
+        == f'["{script}1",null,{{"{script}3":42,"a":[1,2,3],"s":"js","o":{{"a":1,"b":2}}}},"async {script}4"]'
     )
     )
     reset_button.click()
     reset_button.click()
     assert call_script.poll_for_value(counter, exp_not_equal="4") == "0"
     assert call_script.poll_for_value(counter, exp_not_equal="4") == "0"
@@ -448,7 +443,7 @@ def test_call_script(
     assert call_script.poll_for_value(counter, exp_not_equal="0") == "1"
     assert call_script.poll_for_value(counter, exp_not_equal="0") == "1"
     assert (
     assert (
         call_script.poll_for_value(results, exp_not_equal="[]")
         call_script.poll_for_value(results, exp_not_equal="[]")
-        == '[{"%s3":42,"a":[1,2,3],"s":"js","o":{"a":1,"b":2}}]' % script
+        == f'[{{"{script}3":42,"a":[1,2,3],"s":"js","o":{{"a":1,"b":2}}}}]'
     )
     )
     reset_button.click()
     reset_button.click()
     assert call_script.poll_for_value(counter, exp_not_equal="1") == "0"
     assert call_script.poll_for_value(counter, exp_not_equal="1") == "0"

+ 1 - 1
tests/integration/test_client_storage.py

@@ -3,7 +3,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import time
 import time
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver import Firefox
 from selenium.webdriver import Firefox

+ 1 - 1
tests/integration/test_component_state.py

@@ -1,6 +1,6 @@
 """Test that per-component state scaffold works and operates independently."""
 """Test that per-component state scaffold works and operates independently."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_computed_vars.py

@@ -3,7 +3,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import time
 import time
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_connection_banner.py

@@ -1,7 +1,7 @@
 """Test case for displaying the connection banner when the websocket drops."""
 """Test case for displaying the connection banner when the websocket drops."""
 
 
 import functools
 import functools
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.common.exceptions import NoSuchElementException
 from selenium.common.exceptions import NoSuchElementException

+ 1 - 1
tests/integration/test_deploy_url.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 2 - 1
tests/integration/test_dynamic_components.py

@@ -1,7 +1,8 @@
 """Integration tests for var operations."""
 """Integration tests for var operations."""
 
 
 import time
 import time
-from typing import Callable, Generator, TypeVar
+from collections.abc import Callable, Generator
+from typing import TypeVar
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 2 - 2
tests/integration/test_dynamic_routes.py

@@ -3,7 +3,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import time
 import time
-from typing import Callable, Coroutine, Generator, Type
+from collections.abc import Callable, Coroutine, Generator
 from urllib.parse import urlsplit
 from urllib.parse import urlsplit
 
 
 import pytest
 import pytest
@@ -147,7 +147,7 @@ def DynamicRoute():
 
 
 @pytest.fixture(scope="module")
 @pytest.fixture(scope="module")
 def dynamic_route(
 def dynamic_route(
-    app_harness_env: Type[AppHarness], tmp_path_factory
+    app_harness_env: type[AppHarness], tmp_path_factory
 ) -> Generator[AppHarness, None, None]:
 ) -> Generator[AppHarness, None, None]:
     """Start DynamicRoute app at tmp_path via AppHarness.
     """Start DynamicRoute app at tmp_path via AppHarness.
 
 

+ 1 - 1
tests/integration/test_event_actions.py

@@ -4,7 +4,7 @@ from __future__ import annotations
 
 
 import asyncio
 import asyncio
 import time
 import time
-from typing import Callable, Coroutine, Generator
+from collections.abc import Callable, Coroutine, Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_event_chain.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 2 - 2
tests/integration/test_exception_handlers.py

@@ -3,7 +3,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import time
 import time
-from typing import Generator, Type
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By
@@ -71,7 +71,7 @@ def TestApp():
 
 
 @pytest.fixture(scope="module")
 @pytest.fixture(scope="module")
 def test_app(
 def test_app(
-    app_harness_env: Type[AppHarness], tmp_path_factory
+    app_harness_env: type[AppHarness], tmp_path_factory
 ) -> Generator[AppHarness, None, None]:
 ) -> Generator[AppHarness, None, None]:
     """Start TestApp app at tmp_path via AppHarness.
     """Start TestApp app at tmp_path via AppHarness.
 
 

+ 1 - 1
tests/integration/test_extra_overlay_function.py

@@ -1,6 +1,6 @@
 """Test case for adding an overlay component defined in the rxconfig."""
 """Test case for adding an overlay component defined in the rxconfig."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_form_submit.py

@@ -2,7 +2,7 @@
 
 
 import functools
 import functools
 import time
 import time
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_icon.py

@@ -1,6 +1,6 @@
 """Integration tests for the Icon component."""
 """Integration tests for the Icon component."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_input.py

@@ -1,6 +1,6 @@
 """Integration tests for text input and related components."""
 """Integration tests for text input and related components."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_lifespan.py

@@ -1,6 +1,6 @@
 """Test cases for the FastAPI lifespan integration."""
 """Test cases for the FastAPI lifespan integration."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_login_flow.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.common.exceptions import NoSuchElementException
 from selenium.common.exceptions import NoSuchElementException

+ 1 - 1
tests/integration/test_media.py

@@ -1,6 +1,6 @@
 """Integration tests for media components."""
 """Integration tests for media components."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_memo.py

@@ -1,6 +1,6 @@
 """Integration tests for rx.memo components."""
 """Integration tests for rx.memo components."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_navigation.py

@@ -1,6 +1,6 @@
 """Integration tests for links and related components."""
 """Integration tests for links and related components."""
 
 
-from typing import Generator
+from collections.abc import Generator
 from urllib.parse import urlsplit
 from urllib.parse import urlsplit
 
 
 import pytest
 import pytest

+ 1 - 1
tests/integration/test_server_side_event.py

@@ -1,7 +1,7 @@
 """Integration tests for special server side events."""
 """Integration tests for special server side events."""
 
 
 import time
 import time
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_shared_state.py

@@ -2,7 +2,7 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 
 

+ 1 - 1
tests/integration/test_state_inheritance.py

@@ -2,8 +2,8 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from collections.abc import Generator
 from contextlib import suppress
 from contextlib import suppress
-from typing import Generator
 
 
 import pytest
 import pytest
 from selenium.common.exceptions import NoAlertPresentException
 from selenium.common.exceptions import NoAlertPresentException

+ 1 - 1
tests/integration/test_tailwind.py

@@ -1,7 +1,7 @@
 """Test case for disabling tailwind in the config."""
 """Test case for disabling tailwind in the config."""
 
 
 import functools
 import functools
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/test_upload.py

@@ -4,8 +4,8 @@ from __future__ import annotations
 
 
 import asyncio
 import asyncio
 import time
 import time
+from collections.abc import Generator
 from pathlib import Path
 from pathlib import Path
-from typing import Generator
 from urllib.parse import urlsplit
 from urllib.parse import urlsplit
 
 
 import pytest
 import pytest

+ 1 - 1
tests/integration/test_var_operations.py

@@ -1,6 +1,6 @@
 """Integration tests for var operations."""
 """Integration tests for var operations."""
 
 
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.by import By

+ 1 - 1
tests/integration/tests_playwright/test_appearance.py

@@ -1,4 +1,4 @@
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from playwright.sync_api import Page, expect
 from playwright.sync_api import Page, expect

+ 1 - 1
tests/integration/tests_playwright/test_datetime_operations.py

@@ -1,4 +1,4 @@
-from typing import Generator
+from collections.abc import Generator
 
 
 import pytest
 import pytest
 from playwright.sync_api import Page, expect
 from playwright.sync_api import Page, expect

Some files were not shown because too many files changed in this diff