Skip to content

Commit 13ea3ff

Browse files
committed
remove unneeded escapes
1 parent e6e3784 commit 13ea3ff

24 files changed

Lines changed: 225 additions & 178 deletions

File tree

‎docs/advanced_onboarding/how-reflex-works.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ Under the hood, these components compile down to React components. For example,
9999

100100
```jsx
101101
<HStack>
102-
<Link href=\{GithubState.url}>
103-
<Avatar src=\{GithubState.profile_image}/>
102+
<Link href={GithubState.url}>
103+
<Avatar src={GithubState.profile_image}/>
104104
</Link>
105105
<Input
106106
placeholder="Your Github username"
107107
// This would actually be a websocket call to the backend.
108-
onBlur=\{GithubState.set_profile}
108+
onBlur={GithubState.set_profile}
109109
>
110110
</HStack>
111111
```
@@ -140,7 +140,7 @@ class GithubState(rx.State):
140140
def set_profile(self, username: str):
141141
if username == "":
142142
return
143-
github_data = requests.get(f"https://api.github.com/users/\{username}").json()
143+
github_data = requests.get(f"https://api.github.com/users/{username}").json()
144144
self.url = github_data["url"]
145145
self.profile_image = github_data["avatar_url"]
146146
```
@@ -216,7 +216,7 @@ Once we have the user's state, the next step is to run the event handler with th
216216
def set_profile(self, username: str):
217217
if username == "":
218218
return
219-
github_data = requests.get(f"https://api.github.com/users/\{username}").json()
219+
github_data = requests.get(f"https://api.github.com/users/{username}").json()
220220
self.url = github_data["url"]
221221
self.profile_image = github_data["avatar_url"]
222222
```

‎docs/api-reference/var_system.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If the type is known, it can be any of the following:
3030
- `BooleanVar` represents a boolean expression. For example: `false`, `3 > 2`.
3131
- `StringVar` represents an expression that evaluates to a string. For example: `'hello'`, `(2).toString()`.
3232
- `ArrayVar` represents an expression that evaluates to an array object. For example: `[1, 2, 3]`, `'words'.split()`.
33-
- `ObjectVar` represents an expression that evaluates to an object. For example: `\{a: 2, b: 3}`, `\{deeply: \{nested: \{value: false}}}`.
33+
- `ObjectVar` represents an expression that evaluates to an object. For example: `{a: 2, b: 3}`, `{deeply: {nested: {value: false}}}`.
3434
- `NoneVar` represent null values. These can be either `undefined` or `null`.
3535

3636
## Creating Vars
@@ -67,7 +67,7 @@ from reflex.vars import var_operation, var_operation_return, ArrayVar, NumberVar
6767
@var_operation
6868
def multiply_array_values(a: ArrayVar):
6969
return var_operation_return(
70-
js_expression=f"\{a}.reduce((p, c) => p * c, 1)",
70+
js_expression=f"{a}.reduce((p, c) => p * c, 1)",
7171
var_type=int,
7272
)
7373

‎docs/app/templates/llamaindex-app.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ input_payload = {
3939
deployment_name = os.environ.get("DEPLOYMENT_NAME", "MyDeployment")
4040
apiserver_url = os.environ.get("APISERVER_URL", "http://localhost:4501")
4141
response = await client.post(
42-
f"\{apiserver_url}/deployments/\{deployment_name}/tasks/create",
43-
json=\{"input": json.dumps(input_payload)},
42+
f"{apiserver_url}/deployments/{deployment_name}/tasks/create",
43+
json={"input": json.dumps(input_payload)},
4444
timeout=60,
4545
)
4646
answer = response.text

‎docs/database/queries.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,14 @@ import reflex as rx
173173

174174

175175
class State(rx.State):
176-
177176
@rx.event
178177
def insert_user_raw(self, username, email):
179178
with rx.session() as session:
180179
session.execute(
181180
sqlalchemy.text(
182-
"INSERT INTO user (username, email) "
183-
"VALUES (:username, :email)"
181+
"INSERT INTO user (username, email) VALUES (:username, :email)"
184182
),
185-
\{"username": username, "email": email},
183+
{"username": username, "email": email},
186184
)
187185
session.commit()
188186

‎docs/database/relationships.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ chain loaded from the `Post.flags` relationship.
138138
### Specifying the Loading Mechanism on the Relationship
139139

140140
Alternatively, the loading mechanism can be specified on the relationship by
141-
passing `sa_relationship_kwargs=\{"lazy": method}` to `sqlmodel.Relationship`,
141+
passing `sa_relationship_kwargs={"lazy": method}` to `sqlmodel.Relationship`,
142142
which will use the given loading mechanism in all queries by default.
143143

144144
```python
@@ -153,10 +153,10 @@ class Post(rx.Model, table=True):
153153
...
154154
user: Optional["User"] = sqlmodel.Relationship(
155155
back_populates="posts",
156-
sa_relationship_kwargs=\{"lazy": "selectin"},
156+
sa_relationship_kwargs={"lazy": "selectin"},
157157
)
158158
flags: Optional[List["Flag"]] = sqlmodel.Relationship(
159159
back_populates="post",
160-
sa_relationship_kwargs=\{"lazy": "selectin"},
160+
sa_relationship_kwargs={"lazy": "selectin"},
161161
)
162162
```

‎docs/enterprise/ag_grid/index.md‎

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ The format of the data passed to the `row_data` prop is a list of dictionaries.
4545

4646
```python
4747
[
48-
\{"direction": "N", "strength": "0-1", "frequency": 0.5\},
49-
\{"direction": "NNE", "strength": "0-1", "frequency": 0.6\},
50-
\{"direction": "NE", "strength": "0-1", "frequency": 0.5\},
48+
{"direction": "N", "strength": "0-1", "frequency": 0.5},
49+
{"direction": "NNE", "strength": "0-1", "frequency": 0.6},
50+
{"direction": "NE", "strength": "0-1", "frequency": 0.5},
5151
]
5252
```
5353

@@ -257,6 +257,7 @@ import reflex as rx
257257
import reflex_enterprise as rxe
258258
import pandas as pd
259259

260+
260261
class AGGridEditingState(rx.State):
261262
data: list[dict] = []
262263
_data_df: pd.DataFrame
@@ -270,15 +271,30 @@ class AGGridEditingState(rx.State):
270271
def cell_value_changed(self, row, col_field, new_value):
271272
self._data_df.at[row, col_field] = new_value
272273
self.data = self._data_df.to_dict("records")
273-
yield rx.toast(f"Cell value changed, Row: {row}, Column: {col_field}, New Value: {new_value}")
274+
yield rx.toast(
275+
f"Cell value changed, Row: {row}, Column: {col_field}, New Value: {new_value}"
276+
)
274277

275278

276279
column_defs = [
277-
\{"field": "country"\},
278-
\{"field": "pop", "headerName": "Population", "editable": True, "cellEditor": rxe.ag_grid.editors.number\},
279-
\{"field": "continent", "editable": True, "cellEditor": rxe.ag_grid.editors.select, "cellEditorParams": \{"values": ['Asia', 'Europe', 'Africa', 'Americas', 'Oceania']\}\},
280+
{"field": "country"},
281+
{
282+
"field": "pop",
283+
"headerName": "Population",
284+
"editable": True,
285+
"cellEditor": rxe.ag_grid.editors.number,
286+
},
287+
{
288+
"field": "continent",
289+
"editable": True,
290+
"cellEditor": rxe.ag_grid.editors.select,
291+
"cellEditorParams": {
292+
"values": ["Asia", "Europe", "Africa", "Americas", "Oceania"]
293+
},
294+
},
280295
]
281296

297+
282298
def ag_grid_simple_editing():
283299
return rxe.ag_grid(
284300
id="ag_grid_basic_editing",
@@ -336,6 +352,7 @@ import reflex as rx
336352
import reflex_enterprise as rxe
337353
import pandas as pd
338354

355+
339356
class AGGridState2(rx.State):
340357
data: list[dict] = []
341358

@@ -344,12 +361,14 @@ class AGGridState2(rx.State):
344361
_df = pd.read_csv("data/gapminder2007.csv")
345362
self.data = _df.to_dict("records")
346363

364+
347365
column_defs = [
348-
\{"field": "country"\},
349-
\{"field": "pop", "headerName": "Population"\},
350-
\{"field": "continent"\},
366+
{"field": "country"},
367+
{"field": "pop", "headerName": "Population"},
368+
{"field": "continent"},
351369
]
352370

371+
353372
def ag_grid_state_2():
354373
return rxe.ag_grid(
355374
id="ag_grid_state_2",
@@ -370,8 +389,10 @@ import reflex as rx
370389
import reflex_enterprise as rxe
371390
import pandas as pd
372391

392+
373393
class AgGridState(rx.State):
374394
"""The app state."""
395+
375396
all_columns: list = []
376397

377398
two_columns: list = []
@@ -381,15 +402,15 @@ class AgGridState(rx.State):
381402
@rx.event
382403
def init_columns(self):
383404
self.all_columns = [
384-
\{"field": "country"\},
385-
\{"field": "pop"\},
386-
\{"field": "continent"\},
387-
\{"field": "lifeExp"\},
388-
\{"field": "gdpPercap"\},
405+
{"field": "country"},
406+
{"field": "pop"},
407+
{"field": "continent"},
408+
{"field": "lifeExp"},
409+
{"field": "gdpPercap"},
389410
]
390411
self.two_columns = [
391-
\{"field": "country"\},
392-
\{"field": "pop"\},
412+
{"field": "country"},
413+
{"field": "pop"},
393414
]
394415
self.column_defs = self.all_columns
395416

@@ -436,14 +457,14 @@ import reflex_enterprise as rxe
436457
import pandas as pd
437458
from sqlmodel import select
438459

460+
439461
class Country(rx.Model, table=True):
440462
country: str
441463
population: int
442464
continent: str
443465

444466

445467
class AGGridDatabaseState(rx.State):
446-
447468
countries: list[Country]
448469

449470
# Insert data from a csv loaded dataframe to the database (Do this on the page load)
@@ -453,9 +474,9 @@ class AGGridDatabaseState(rx.State):
453474
with rx.session() as session:
454475
for _, row in data.iterrows():
455476
db_record = Country(
456-
country=row['country'],
457-
population=row['pop'],
458-
continent=row['continent'],
477+
country=row["country"],
478+
population=row["pop"],
479+
continent=row["continent"],
459480
)
460481
session.add(db_record)
461482
session.commit()
@@ -476,15 +497,30 @@ class AGGridDatabaseState(rx.State):
476497
country = Country(**self.countries[row])
477498
session.merge(country)
478499
session.commit()
479-
yield rx.toast(f"Cell value changed, Row: \{row}, Column: \{col_field}, New Value: \{new_value}")
500+
yield rx.toast(
501+
f"Cell value changed, Row: {row}, Column: {col_field}, New Value: {new_value}"
502+
)
480503

481504

482505
column_defs = [
483-
\{"field": "country"\},
484-
\{"field": "population", "headerName": "Population", "editable": True, "cellEditor": rxe.ag_grid.editors.number\},
485-
\{"field": "continent", "editable": True, "cellEditor": rxe.ag_grid.editors.select, "cellEditorParams": \{"values": ['Asia', 'Europe', 'Africa', 'Americas', 'Oceania']\}\},
506+
{"field": "country"},
507+
{
508+
"field": "population",
509+
"headerName": "Population",
510+
"editable": True,
511+
"cellEditor": rxe.ag_grid.editors.number,
512+
},
513+
{
514+
"field": "continent",
515+
"editable": True,
516+
"cellEditor": rxe.ag_grid.editors.select,
517+
"cellEditorParams": {
518+
"values": ["Asia", "Europe", "Africa", "Americas", "Oceania"]
519+
},
520+
},
486521
]
487522

523+
488524
def index():
489525
return rxe.ag_grid(
490526
id="ag_grid_basic_editing",
@@ -495,6 +531,7 @@ def index():
495531
height="40vh",
496532
)
497533

534+
498535
# Add state and page to the app.
499536
app = rx.App()
500537
app.add_page(index, on_load=AGGridDatabaseState.insert_dataframe_to_db)
@@ -657,9 +694,9 @@ df = pd.read_csv(
657694
)
658695

659696
column_defs = [
660-
\{"field": "country", "checkboxSelection": True\},
661-
\{"field": "pop"\},
662-
\{"field": "continent"\},
697+
{"field": "country", "checkboxSelection": True},
698+
{"field": "pop"},
699+
{"field": "continent"},
663700
]
664701

665702
def ag_grid_api_argument():

‎docs/getting_started/chatapp_tutorial.md‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ uv run reflex run
112112

113113
You should see your app running at [http://localhost:3000](http://localhost:3000).
114114

115-
Reflex also starts the backend server which handles all the state management and communication with the frontend. You can test the backend server is running by navigating to [http://localhost:8000/ping]({"http://localhost:8000/ping"}).
115+
Reflex also starts the backend server which handles all the state management and communication with the frontend. You can test the backend server is running by navigating to [http://localhost:8000/ping](http://localhost:8000/ping).
116116

117117
Now that we have our project set up, in the next section we will start building our app!
118118

@@ -627,16 +627,15 @@ import os
627627

628628
from openai import AsyncOpenAI
629629

630+
630631
@rx.event
631632
async def answer(self):
632633
# Our chatbot has some brains now!
633634
client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"])
634635

635636
session = await client.chat.completions.create(
636637
model="gpt-4o-mini",
637-
messages=[
638-
\{"role": "user", "content": self.question}
639-
],
638+
messages=[{"role": "user", "content": self.question}],
640639
stop=None,
641640
temperature=0.7,
642641
stream=True,
@@ -736,6 +735,7 @@ import os
736735
from openai import AsyncOpenAI
737736
import reflex as rx
738737

738+
739739
class State(rx.State):
740740
question: str
741741
chat_history: list[tuple[str, str]] = []
@@ -746,9 +746,7 @@ class State(rx.State):
746746
# Start streaming completion from OpenAI
747747
session = await client.chat.completions.create(
748748
model="gpt-4o-mini",
749-
messages=[
750-
\{"role": "user", "content": self.question}
751-
],
749+
messages=[{"role": "user", "content": self.question}],
752750
temperature=0.7,
753751
stream=True,
754752
)

0 commit comments

Comments
 (0)