Sfoglia il codice sorgente

used ruff formatting

Yummy-Yums 1 anno fa
parent
commit
3e9ced5276

+ 1 - 3
reflex/components/component.py

@@ -1819,9 +1819,7 @@ class NoSSRComponent(Component):
         library_import = f"const {self.alias if self.alias else self.tag} = dynamic(() => import('{import_name}')"
         library_import = f"const {self.alias if self.alias else self.tag} = dynamic(() => import('{import_name}')"
         mod_import = (
         mod_import = (
             # https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#with-named-exports
             # https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#with-named-exports
-            f".then((mod) => mod.{self.tag})"
-            if not self.is_default
-            else ""
+            f".then((mod) => mod.{self.tag})" if not self.is_default else ""
         )
         )
         return "".join((library_import, mod_import, opts_fragment))
         return "".join((library_import, mod_import, opts_fragment))
 
 

+ 18 - 9
reflex/components/el/elements/media.py

@@ -79,15 +79,6 @@ class Audio(BaseHTML):
 class Img(BaseHTML):
 class Img(BaseHTML):
     """Display the img element."""
     """Display the img element."""
 
 
-    @classmethod
-    def create(cls, *children, **props) -> Component:
-        if len(children) == 0:
-            comp = super().create(*children, **props)
-        else:
-            return super().create(src=children[0], **props)
-
-        return comp
-
     tag = "img"
     tag = "img"
 
 
     # Image alignment with respect to its surrounding elements
     # Image alignment with respect to its surrounding elements
@@ -126,6 +117,24 @@ class Img(BaseHTML):
     # The name of the map to use with the image
     # The name of the map to use with the image
     use_map: Var[Union[str, int, bool]]
     use_map: Var[Union[str, int, bool]]
 
 
+    @classmethod
+    def create(cls, *children, **props) -> Component:
+        """Override create method to apply source attribute to value if user fails to pass in attribute.
+
+        Args:
+            *children: The children of the component.
+            **props: The props of the component.
+
+        Returns:
+            The component.
+
+        """
+        return (
+            super().create(src=children[0], **props)
+            if children
+            else super().create(*children, **props)
+        )
+
 
 
 class Map(BaseHTML):
 class Map(BaseHTML):
     """Display the map element."""
     """Display the map element."""

+ 4 - 8
reflex/components/markdown/markdown.py

@@ -98,8 +98,8 @@ class Markdown(Component):
         Returns:
         Returns:
             The markdown component.
             The markdown component.
         """
         """
-        assert len(children) == 1 and types._isinstance(
-            children[0], Union[str, Var]
+        assert (
+            len(children) == 1 and types._isinstance(children[0], Union[str, Var])
         ), "Markdown component must have exactly one child containing the markdown source."
         ), "Markdown component must have exactly one child containing the markdown source."
 
 
         # Update the base component map with the custom component map.
         # Update the base component map with the custom component map.
@@ -243,9 +243,7 @@ class Markdown(Component):
         }
         }
 
 
         # Separate out inline code and code blocks.
         # Separate out inline code and code blocks.
-        components[
-            "code"
-        ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
+        components["code"] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
     const match = (className || '').match(/language-(?<lang>.*)/);
     const match = (className || '').match(/language-(?<lang>.*)/);
     const language = match ? match[1] : '';
     const language = match ? match[1] : '';
     if (language) {{
     if (language) {{
@@ -263,9 +261,7 @@ class Markdown(Component):
     ) : (
     ) : (
         {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False))}
         {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False))}
     );
     );
-      }}}}""".replace(
-            "\n", " "
-        )
+      }}}}""".replace("\n", " ")
 
 
         return components
         return components
 
 

+ 6 - 1
reflex/reflex.py

@@ -528,7 +528,12 @@ def deploy(
 
 
     hosting_cli.deploy(
     hosting_cli.deploy(
         app_name=app_name,
         app_name=app_name,
-        export_fn=lambda zip_dest_dir, api_url, deploy_url, frontend, backend, zipping: export_utils.export(
+        export_fn=lambda zip_dest_dir,
+        api_url,
+        deploy_url,
+        frontend,
+        backend,
+        zipping: export_utils.export(
             zip_dest_dir=zip_dest_dir,
             zip_dest_dir=zip_dest_dir,
             api_url=api_url,
             api_url=api_url,
             deploy_url=deploy_url,
             deploy_url=deploy_url,