reflex 0.5.10a2__py3-none-any.whl → 0.5.10.post1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

reflex/state.py CHANGED
@@ -1135,6 +1135,29 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1135
1135
  for substate in self.substates.values():
1136
1136
  substate.reset()
1137
1137
 
1138
+ @classmethod
1139
+ @functools.lru_cache
1140
+ def _is_client_storage(cls, prop_name_or_field: str | ModelField) -> bool:
1141
+ """Check if the var is a client storage var.
1142
+
1143
+ Args:
1144
+ prop_name_or_field: The name of the var or the field itself.
1145
+
1146
+ Returns:
1147
+ Whether the var is a client storage var.
1148
+ """
1149
+ if isinstance(prop_name_or_field, str):
1150
+ field = cls.get_fields().get(prop_name_or_field)
1151
+ else:
1152
+ field = prop_name_or_field
1153
+ return field is not None and (
1154
+ isinstance(field.default, ClientStorageBase)
1155
+ or (
1156
+ isinstance(field.type_, type)
1157
+ and issubclass(field.type_, ClientStorageBase)
1158
+ )
1159
+ )
1160
+
1138
1161
  def _reset_client_storage(self):
1139
1162
  """Reset client storage base vars to their default values."""
1140
1163
  # Client-side storage is reset during hydrate so that clearing cookies
@@ -1142,10 +1165,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1142
1165
  fields = self.get_fields()
1143
1166
  for prop_name in self.base_vars:
1144
1167
  field = fields[prop_name]
1145
- if isinstance(field.default, ClientStorageBase) or (
1146
- isinstance(field.type_, type)
1147
- and issubclass(field.type_, ClientStorageBase)
1148
- ):
1168
+ if self._is_client_storage(field):
1149
1169
  setattr(self, prop_name, copy.deepcopy(field.default))
1150
1170
 
1151
1171
  # Recursively reset the substate client storage.
@@ -1891,8 +1911,9 @@ class UpdateVarsInternalState(State):
1891
1911
  for var, value in vars.items():
1892
1912
  state_name, _, var_name = var.rpartition(".")
1893
1913
  var_state_cls = State.get_class_substate(state_name)
1894
- var_state = await self.get_state(var_state_cls)
1895
- setattr(var_state, var_name, value)
1914
+ if var_state_cls._is_client_storage(var_name):
1915
+ var_state = await self.get_state(var_state_cls)
1916
+ setattr(var_state, var_name, value)
1896
1917
 
1897
1918
 
1898
1919
  class OnLoadInternalState(State):
reflex/utils/net.py ADDED
@@ -0,0 +1,43 @@
1
+ """Helpers for downloading files from the network."""
2
+
3
+ import os
4
+
5
+ import httpx
6
+
7
+ from . import console
8
+
9
+
10
+ def _httpx_verify_kwarg() -> bool:
11
+ """Get the value of the HTTPX verify keyword argument.
12
+
13
+ Returns:
14
+ True if SSL verification is enabled, False otherwise
15
+ """
16
+ ssl_no_verify = os.environ.get("SSL_NO_VERIFY", "").lower() in ["true", "1", "yes"]
17
+ return not ssl_no_verify
18
+
19
+
20
+ def get(url: str, **kwargs) -> httpx.Response:
21
+ """Make an HTTP GET request.
22
+
23
+ Args:
24
+ url: The URL to request.
25
+ **kwargs: Additional keyword arguments to pass to httpx.get.
26
+
27
+ Returns:
28
+ The response object.
29
+
30
+ Raises:
31
+ httpx.ConnectError: If the connection cannot be established.
32
+ """
33
+ kwargs.setdefault("verify", _httpx_verify_kwarg())
34
+ try:
35
+ return httpx.get(url, **kwargs)
36
+ except httpx.ConnectError as err:
37
+ if "CERTIFICATE_VERIFY_FAILED" in str(err):
38
+ # If the error is a certificate verification error, recommend mitigating steps.
39
+ console.error(
40
+ f"Certificate verification failed for {url}. Set environment variable SSL_CERT_FILE to the "
41
+ "path of the certificate file or SSL_NO_VERIFY=1 to disable verification."
42
+ )
43
+ raise
@@ -34,7 +34,7 @@ from reflex import constants, model
34
34
  from reflex.base import Base
35
35
  from reflex.compiler import templates
36
36
  from reflex.config import Config, get_config
37
- from reflex.utils import console, path_ops, processes
37
+ from reflex.utils import console, net, path_ops, processes
38
38
  from reflex.utils.format import format_library_name
39
39
  from reflex.utils.registry import _get_best_registry
40
40
 
@@ -80,7 +80,7 @@ def check_latest_package_version(package_name: str):
80
80
  # Get the latest version from PyPI
81
81
  current_version = importlib.metadata.version(package_name)
82
82
  url = f"https://pypi.org/pypi/{package_name}/json"
83
- response = httpx.get(url)
83
+ response = net.get(url)
84
84
  latest_version = response.json()["info"]["version"]
85
85
  if (
86
86
  version.parse(current_version) < version.parse(latest_version)
@@ -670,7 +670,7 @@ def download_and_run(url: str, *args, show_status: bool = False, **env):
670
670
  """
671
671
  # Download the script
672
672
  console.debug(f"Downloading {url}")
673
- response = httpx.get(url)
673
+ response = net.get(url)
674
674
  if response.status_code != httpx.codes.OK:
675
675
  response.raise_for_status()
676
676
 
@@ -700,11 +700,11 @@ def download_and_extract_fnm_zip():
700
700
  try:
701
701
  # Download the FNM zip release.
702
702
  # TODO: show progress to improve UX
703
- with httpx.stream("GET", url, follow_redirects=True) as response:
704
- response.raise_for_status()
705
- with open(fnm_zip_file, "wb") as output_file:
706
- for chunk in response.iter_bytes():
707
- output_file.write(chunk)
703
+ response = net.get(url, follow_redirects=True)
704
+ response.raise_for_status()
705
+ with open(fnm_zip_file, "wb") as output_file:
706
+ for chunk in response.iter_bytes():
707
+ output_file.write(chunk)
708
708
 
709
709
  # Extract the downloaded zip file.
710
710
  with zipfile.ZipFile(fnm_zip_file, "r") as zip_ref:
@@ -1222,7 +1222,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]:
1222
1222
  """
1223
1223
 
1224
1224
  def get_release_by_tag(tag: str) -> dict | None:
1225
- response = httpx.get(constants.Reflex.RELEASES_URL)
1225
+ response = net.get(constants.Reflex.RELEASES_URL)
1226
1226
  response.raise_for_status()
1227
1227
  releases = response.json()
1228
1228
  for release in releases:
@@ -1243,7 +1243,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]:
1243
1243
  else:
1244
1244
  templates_url = asset["browser_download_url"]
1245
1245
 
1246
- templates_data = httpx.get(templates_url, follow_redirects=True).json()["templates"]
1246
+ templates_data = net.get(templates_url, follow_redirects=True).json()["templates"]
1247
1247
 
1248
1248
  for template in templates_data:
1249
1249
  if template["name"] == "blank":
@@ -1286,7 +1286,7 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str
1286
1286
  zip_file_path = Path(temp_dir) / "template.zip"
1287
1287
  try:
1288
1288
  # Note: following redirects can be risky. We only allow this for reflex built templates at the moment.
1289
- response = httpx.get(template_url, follow_redirects=True)
1289
+ response = net.get(template_url, follow_redirects=True)
1290
1290
  console.debug(f"Server responded download request: {response}")
1291
1291
  response.raise_for_status()
1292
1292
  except httpx.HTTPError as he:
@@ -1417,7 +1417,7 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash:
1417
1417
  generation_hash: The generation hash from reflex.build.
1418
1418
  """
1419
1419
  # Download the reflex code for the generation.
1420
- resp = httpx.get(
1420
+ resp = net.get(
1421
1421
  constants.Templates.REFLEX_BUILD_CODE_URL.format(
1422
1422
  generation_hash=generation_hash
1423
1423
  )
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: reflex
3
- Version: 0.5.10a2
3
+ Version: 0.5.10.post1
4
4
  Summary: Web apps in pure Python.
5
- Home-page: https://reflex.dev
6
5
  License: Apache-2.0
7
6
  Keywords: web,framework
8
7
  Author: Nikhil Rao
@@ -16,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
19
  Requires-Dist: alembic (>=1.11.1,<2.0)
20
20
  Requires-Dist: build (>=1.0.3,<2.0)
21
21
  Requires-Dist: charset-normalizer (>=3.3.2,<4.0)
@@ -50,6 +50,7 @@ Requires-Dist: wheel (>=0.42.0,<1.0)
50
50
  Requires-Dist: wrapt (>=1.11.0,<2.0) ; python_version < "3.11"
51
51
  Requires-Dist: wrapt (>=1.14.0,<2.0) ; python_version >= "3.11"
52
52
  Project-URL: Documentation, https://reflex.dev/docs/getting-started/introduction
53
+ Project-URL: Homepage, https://reflex.dev
53
54
  Project-URL: Repository, https://github.com/reflex-dev/reflex
54
55
  Description-Content-Type: text/markdown
55
56
 
@@ -380,7 +380,7 @@ reflex/model.py,sha256=f9F3J3JZX_NmUCU5mN4Lh7afclq9fikPUB1K2FmNlhU,13545
380
380
  reflex/page.py,sha256=NPT0xMownZGTiYiRtrUJnvAe_4oEvlzEJEkG-vrGhqI,2077
381
381
  reflex/reflex.py,sha256=xkghsOzZJVP-Obnw7okr-GK_LXxL67qK6uvbNZ3pZWQ,18440
382
382
  reflex/route.py,sha256=WZS7stKgO94nekFFYHaOqNgN3zZGpJb3YpGF4ViTHmw,4198
383
- reflex/state.py,sha256=_PGFnIFiMGadh-HeAGsRNpGxkN10LqqKD0lg0SWf950,114404
383
+ reflex/state.py,sha256=C_DMHg58Cl2zPwVtcC-8RD14w7nRdDU99sDoI20kdag,115083
384
384
  reflex/style.py,sha256=sLeIKBKUpZV1q1QwexVyckqFphjoxsPqCstVQf-D0Ak,11703
385
385
  reflex/testing.py,sha256=EkQJlwGFtiURbCyJNB5yDacp1sLYWOW6oauyTjwN8Fw,34285
386
386
  reflex/utils/__init__.py,sha256=y-AHKiRQAhk2oAkvn7W8cRVTZVK625ff8tTwvZtO7S4,24
@@ -394,8 +394,9 @@ reflex/utils/export.py,sha256=3dI9QjoU0ZA_g8OSQipVLpFWQcxWa_sHkpezWemvWbo,2366
394
394
  reflex/utils/format.py,sha256=elfO3XY5dVBvv6drfZFbfMUokcldiOk03qupvvRuDkk,26389
395
395
  reflex/utils/imports.py,sha256=Pvdcr_bkFpTgZ5gZfc5SKKPCvbcqlZSfwyGVhxNh2kc,4770
396
396
  reflex/utils/lazy_loader.py,sha256=utVpUjKcz32GC1I7g0g7OlTyvVoZNFcuAjNtnxiSYww,1282
397
+ reflex/utils/net.py,sha256=UFCfaOjvRDVLTeTzLKJ5iDAWtPNuhng5gOs-pIMYQek,1267
397
398
  reflex/utils/path_ops.py,sha256=XQVq_r_2tFHECWuJPyxzk3GzijCJemgXxfI5w2rc_Vs,4924
398
- reflex/utils/prerequisites.py,sha256=Im3BuRUbKuXxXPhaU16EkEljcpblsh_KLd6KYsqVHik,51763
399
+ reflex/utils/prerequisites.py,sha256=8dlCDS71EvwxoGNlZVA2Og9lHDhsO4hQEosC2jpU2ao,51721
399
400
  reflex/utils/processes.py,sha256=y8X5PxycEWT1ItLtpIS-rzrUvNQ9MUOkHdIg_zK9Vp0,13228
400
401
  reflex/utils/pyi_generator.py,sha256=7kz5F0hzE8nEdybnrU8C_y3xaZwpjX3J50d3PVPwIhs,34363
401
402
  reflex/utils/redir.py,sha256=B0K9m6ejDW0ABeclBb4AsRRORvx_stCTWsrDe1YvkzY,1679
@@ -406,8 +407,8 @@ reflex/utils/types.py,sha256=tTA5z7rSWQjOcKi_hdw9wLioU4UP3fDZQolgdMBc37M,17838
406
407
  reflex/utils/watch.py,sha256=ukPT3YrvqsXYN6BInWiO_RPry5osSch9lOomQhxDyk0,2685
407
408
  reflex/vars.py,sha256=Ft-DOADYSOyWdLuQ9Axjzg777n9ZdZ8glEZMvU5u_G0,85297
408
409
  reflex/vars.pyi,sha256=d55fH5lM6vt8RU_CPSvvOYVTr6orhXOCbL_XY2HgGIc,7214
409
- reflex-0.5.10a2.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
410
- reflex-0.5.10a2.dist-info/METADATA,sha256=pVT-_QTZ8Q3Nhm87f393vjfjKB-asvYv0Z-OiANJErU,12237
411
- reflex-0.5.10a2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
412
- reflex-0.5.10a2.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
413
- reflex-0.5.10a2.dist-info/RECORD,,
410
+ reflex-0.5.10.post1.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
411
+ reflex-0.5.10.post1.dist-info/METADATA,sha256=GWepOaUtt8rk3ahduMUYk_RPqQycJyazBVmbGd435_k,12304
412
+ reflex-0.5.10.post1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
413
+ reflex-0.5.10.post1.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
414
+ reflex-0.5.10.post1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any