Skip to content

Changes to v2 to encourage simplicity #1297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Unreleased
**Added**

- :pull:`1113` - Added ``reactpy.executors.asgi.ReactPy`` that can be used to run ReactPy in standalone mode via ASGI.
- :pull:`1269` - Added ``reactpy.executors.asgi.ReactPyPyodide`` that can be used to run ReactPy in standalone mode via ASGI, but rendered entirely client-sided.
- :pull:`1269` - Added ``reactpy.executors.asgi.ReactPyCsr`` that can be used to run ReactPy in standalone mode via ASGI, but rendered entirely client-sided.
- :pull:`1113` - Added ``reactpy.executors.asgi.ReactPyMiddleware`` that can be used to utilize ReactPy within any ASGI compatible framework.
- :pull:`1269` - Added ``reactpy.templatetags.Jinja`` that can be used alongside ``ReactPyMiddleware`` to embed several ReactPy components into your existing application. This includes the following template tags: ``{% component %}``, ``{% pyscript_component %}``, and ``{% pyscript_setup %}``.
- :pull:`1269` - Added ``reactpy.templatetags.ReactPyJinja`` that can be used alongside ``ReactPyMiddleware`` to embed several ReactPy components into your existing application. This includes the following template tags: ``{% component %}``, ``{% pyscript_component %}``, and ``{% pyscript_setup %}``.
- :pull:`1269` - Added ``reactpy.pyscript_component`` that can be used to embed ReactPy components into your existing application.
- :pull:`1113` - Added ``uvicorn`` and ``jinja`` installation extras (for example ``pip install reactpy[jinja]``).
- :pull:`1113` - Added ``asgi`` and ``jinja`` installation extras (for example ``pip install reactpy[asgi, jinja]``).
- :pull:`1113` - Added support for Python 3.12 and 3.13.
- :pull:`1264` - Added ``reactpy.use_async_effect`` hook.
- :pull:`1267` - Added ``shutdown_timeout`` parameter to the ``reactpy.use_async_effect`` hook.
Expand Down Expand Up @@ -61,7 +61,7 @@ Unreleased
- :pull:`1113` - Removed ``reactpy.core.types`` module. Use ``reactpy.types`` instead.
- :pull:`1278` - Removed ``reactpy.utils.html_to_vdom``. Use ``reactpy.utils.string_to_reactpy`` instead.
- :pull:`1278` - Removed ``reactpy.utils.vdom_to_html``. Use ``reactpy.utils.reactpy_to_string`` instead.
- :pull:`1113` - All backend related installation extras (such as ``pip install reactpy[starlette]``) have been removed.
- :pull:`1113` - Removed all backend related installation extras (such as ``pip install reactpy[starlette]``).
- :pull:`1113` - Removed deprecated function ``module_from_template``.
- :pull:`1113` - Removed support for Python 3.9.
- :pull:`1264` - Removed support for async functions within ``reactpy.use_effect`` hook. Use ``reactpy.use_async_effect`` instead.
Expand All @@ -72,8 +72,8 @@ Unreleased
**Fixed**

- :pull:`1239` - Fixed a bug where script elements would not render to the DOM as plain text.
- :pull:`1271` - Fixed a bug where the ``key`` property provided via server-side ReactPy code was failing to propagate to the front-end JavaScript component.
- :pull:`1254` - Fixed a bug where ``RuntimeError("Hook stack is in an invalid state")`` errors would be provided when using a webserver that reuses threads.
- :pull:`1271` - Fixed a bug where the ``key`` property provided within server-side ReactPy code was failing to propagate to the front-end JavaScript components.
- :pull:`1254` - Fixed a bug where ``RuntimeError("Hook stack is in an invalid state")`` errors could be generated when using a webserver that reuses threads.

v1.1.0
------
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ urls.Documentation = "https://reactpy.dev/"
urls.Source = "https://github.com/reactive-python/reactpy"

[project.optional-dependencies]
all = ["reactpy[asgi,jinja,uvicorn,testing]"]
all = ["reactpy[asgi,jinja,testing]"]
asgi = ["asgiref", "asgi-tools", "servestatic", "orjson", "pip"]
jinja = ["jinja2-simple-tags", "jinja2 >=3"]
uvicorn = ["uvicorn[standard]"]
testing = ["playwright"]
testing = ["playwright", "uvicorn[standard]"]

[tool.hatch.version]
path = "src/reactpy/__init__.py"
Expand Down
4 changes: 2 additions & 2 deletions src/reactpy/executors/asgi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from reactpy.executors.asgi.middleware import ReactPyMiddleware
from reactpy.executors.asgi.pyscript import ReactPyPyscript
from reactpy.executors.asgi.pyscript import ReactPyCsr
from reactpy.executors.asgi.standalone import ReactPy

__all__ = ["ReactPy", "ReactPyMiddleware", "ReactPyPyscript"]
__all__ = ["ReactPy", "ReactPyCsr", "ReactPyMiddleware"]
4 changes: 2 additions & 2 deletions src/reactpy/executors/asgi/pyscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from reactpy.types import ReactPyConfig, VdomDict


class ReactPyPyscript(ReactPy):
class ReactPyCsr(ReactPy):
def __init__(
self,
*file_paths: str | Path,
Expand Down Expand Up @@ -88,7 +88,7 @@ def match_dispatch_path(self, scope: AsgiWebsocketScope) -> bool: # nocov
class ReactPyPyscriptApp(ReactPyApp):
"""ReactPy's standalone ASGI application for Client-Side Rendering (CSR) via PyScript."""

parent: ReactPyPyscript
parent: ReactPyCsr
_index_html = ""
_etag = ""
_last_modified = ""
Expand Down
9 changes: 3 additions & 6 deletions src/reactpy/pyscript/component_template.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# ruff: noqa: TC004, N802, N816, RUF006
# ruff: noqa: N802, N816, RUF006
# type: ignore
from typing import TYPE_CHECKING
import asyncio

if TYPE_CHECKING:
import asyncio

from reactpy.pyscript.layout_handler import ReactPyLayoutHandler
from reactpy.pyscript.layout_handler import ReactPyLayoutHandler


# User component is inserted below by regex replacement
Expand Down
2 changes: 1 addition & 1 deletion src/reactpy/pyscript/layout_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class ReactPyLayoutHandler:
"""Encapsulate the entire layout handler with a class to prevent overlapping
"""Encapsulate the entire PyScript layout handler with a class to prevent overlapping
variable names between user code.

This code is designed to be run directly by PyScript, and is not intended to be run
Expand Down
4 changes: 2 additions & 2 deletions src/reactpy/templatetags/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from reactpy.templatetags.jinja import Jinja
from reactpy.templatetags.jinja import ReactPyJinja

__all__ = ["Jinja"]
__all__ = ["ReactPyJinja"]
2 changes: 1 addition & 1 deletion src/reactpy/templatetags/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from reactpy.pyscript.utils import pyscript_component_html, pyscript_setup_html


class Jinja(StandaloneTag): # type: ignore
class ReactPyJinja(StandaloneTag): # type: ignore
safe_output = True
tags: ClassVar[set[str]] = {"component", "pyscript_component", "pyscript_setup"}

Expand Down
6 changes: 3 additions & 3 deletions tests/test_asgi/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def display(page):
templates = Jinja2Templates(
env=JinjaEnvironment(
loader=JinjaFileSystemLoader("tests/templates"),
extensions=["reactpy.templatetags.Jinja"],
extensions=["reactpy.templatetags.ReactPyJinja"],
)
)

Expand Down Expand Up @@ -60,7 +60,7 @@ async def test_unregistered_root_component():
templates = Jinja2Templates(
env=JinjaEnvironment(
loader=JinjaFileSystemLoader("tests/templates"),
extensions=["reactpy.templatetags.Jinja"],
extensions=["reactpy.templatetags.ReactPyJinja"],
)
)

Expand Down Expand Up @@ -124,7 +124,7 @@ async def test_templatetag_bad_kwargs(page, caplog):
templates = Jinja2Templates(
env=JinjaEnvironment(
loader=JinjaFileSystemLoader("tests/templates"),
extensions=["reactpy.templatetags.Jinja"],
extensions=["reactpy.templatetags.ReactPyJinja"],
)
)

Expand Down
10 changes: 5 additions & 5 deletions tests/test_asgi/test_pyscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from starlette.templating import Jinja2Templates

from reactpy import html
from reactpy.executors.asgi.pyscript import ReactPyPyscript
from reactpy.executors.asgi.pyscript import ReactPyCsr
from reactpy.testing import BackendFixture, DisplayFixture


@pytest.fixture()
async def display(page):
"""Override for the display fixture that uses ReactPyMiddleware."""
app = ReactPyPyscript(
app = ReactPyCsr(
Path(__file__).parent / "pyscript_components" / "root.py",
initial=html.div({"id": "loading"}, "Loading..."),
)
Expand All @@ -29,7 +29,7 @@ async def display(page):
@pytest.fixture()
async def multi_file_display(page):
"""Override for the display fixture that uses ReactPyMiddleware."""
app = ReactPyPyscript(
app = ReactPyCsr(
Path(__file__).parent / "pyscript_components" / "load_first.py",
Path(__file__).parent / "pyscript_components" / "load_second.py",
initial=html.div({"id": "loading"}, "Loading..."),
Expand All @@ -46,7 +46,7 @@ async def jinja_display(page):
templates = Jinja2Templates(
env=JinjaEnvironment(
loader=JinjaFileSystemLoader("tests/templates"),
extensions=["reactpy.templatetags.Jinja"],
extensions=["reactpy.templatetags.ReactPyJinja"],
)
)

Expand Down Expand Up @@ -93,7 +93,7 @@ async def test_multi_file_components(multi_file_display: DisplayFixture):

def test_bad_file_path():
with pytest.raises(ValueError):
ReactPyPyscript()
ReactPyCsr()


async def test_jinja_template_tag(jinja_display: DisplayFixture):
Expand Down
Loading