Skip to content

Commit

Permalink
Merge branch 'main' into elijah/markdown-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adhami3310 committed Nov 6, 2024
2 parents 8f4f661 + 4c0b491 commit 0ef8abd
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:

- name: Install Requirements for reflex-web
working-directory: ./reflex-web
run: poetry run uv pip install -r requirements.txt
run: poetry run uv pip install $(grep -ivE "reflex " requirements.txt)
- name: Install additional dependencies for DB access
run: poetry run uv pip install psycopg2-binary
- name: Init Website for reflex-web
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/test_benchmark_compile_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def app_with_one_page(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app1")
root = tmp_path_factory.mktemp("app1")

yield AppHarness.create(root=root, app_source=AppWithOnePage) # type: ignore

Expand All @@ -227,7 +227,7 @@ def app_with_ten_pages(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app10")
root = tmp_path_factory.mktemp("app10")
yield AppHarness.create(
root=root,
app_source=functools.partial(
Expand All @@ -249,7 +249,7 @@ def app_with_hundred_pages(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app100")
root = tmp_path_factory.mktemp("app100")

yield AppHarness.create(
root=root,
Expand All @@ -272,7 +272,7 @@ def app_with_thousand_pages(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app1000")
root = tmp_path_factory.mktemp("app1000")

yield AppHarness.create(
root=root,
Expand All @@ -295,7 +295,7 @@ def app_with_ten_thousand_pages(
Yields:
running AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app10000")
root = tmp_path_factory.mktemp("app10000")

yield AppHarness.create(
root=root,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff]
target-version = "py39"
lint.select = ["B", "D", "E", "F", "I", "SIM", "W"]
lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541", "SIM115"]
lint.ignore = ["B008", "D205", "E501", "F403", "SIM115"]
lint.pydocstyle.convention = "google"

[tool.ruff.lint.per-file-ignores]
Expand Down
1 change: 0 additions & 1 deletion reflex/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class ComponentNamespace(SimpleNamespace):
def __hash__(self) -> int:
"""Get the hash of the namespace.
Returns:
The hash of the namespace.
"""
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/core/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def add_hooks(self) -> list[str | Var]:

individual_hooks = [
f"const toast_props = {str(LiteralVar.create(props))};",
f"const [userDismissed, setUserDismissed] = useState(false);",
"const [userDismissed, setUserDismissed] = useState(false);",
FunctionStringVar(
"useEffect",
_var_data=VarData(
Expand Down
1 change: 0 additions & 1 deletion reflex/components/datadisplay/dataeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class DataEditor(NoSSRComponent):
library: str = "@glideapps/glide-data-grid@^6.0.3"
lib_dependencies: List[str] = [
"lodash@^4.17.21",
"marked@^14.1.2",
"react-responsive-carousel@^3.2.7",
]

Expand Down
37 changes: 18 additions & 19 deletions reflex/components/datadisplay/shiki_code_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,48 @@
def copy_script() -> Any:
"""Copy script for the code block and modify the child SVG element.
Returns:
Any: The result of calling the script.
"""
return run_script(
f"""
"""
// Event listener for the parent click
document.addEventListener('click', function(event) {{
document.addEventListener('click', function(event) {
// Find the closest button (parent element)
const parent = event.target.closest('button');
// If the parent is found
if (parent) {{
if (parent) {
// Find the SVG element within the parent
const svgIcon = parent.querySelector('svg');
// If the SVG exists, proceed with the script
if (svgIcon) {{
if (svgIcon) {
const originalPath = svgIcon.innerHTML;
const checkmarkPath = '<polyline points="20 6 9 17 4 12"></polyline>'; // Checkmark SVG path
function transition(element, scale, opacity) {{
element.style.transform = `scale(${{scale}})`;
function transition(element, scale, opacity) {
element.style.transform = `scale(${scale})`;
element.style.opacity = opacity;
}}
}
// Animate the SVG
transition(svgIcon, 0, '0');
setTimeout(() => {{
setTimeout(() => {
svgIcon.innerHTML = checkmarkPath; // Replace content with checkmark
svgIcon.setAttribute('viewBox', '0 0 24 24'); // Adjust viewBox if necessary
transition(svgIcon, 1, '1');
setTimeout(() => {{
setTimeout(() => {
transition(svgIcon, 0, '0');
setTimeout(() => {{
setTimeout(() => {
svgIcon.innerHTML = originalPath; // Restore original SVG content
transition(svgIcon, 1, '1');
}}, 125);
}}, 600);
}}, 125);
}} else {{
}, 125);
}, 600);
}, 125);
} else {
// console.error('SVG element not found within the parent.');
}}
}} else {{
}
} else {
// console.error('Parent element not found.');
}}
}})
}
})
"""
)

Expand Down
2 changes: 1 addition & 1 deletion reflex/components/lucide/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create(cls, *children, **props) -> Component:

props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon"
props["alias"] = f"Lucide{props['tag']}"
props.setdefault("color", f"var(--current-color)")
props.setdefault("color", "var(--current-color)")
return super().create(*children, **props)


Expand Down
6 changes: 3 additions & 3 deletions reflex/components/radix/primitives/accordion.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def add_style(self) -> dict[str, Any] | None:
"background_color": color("accent", 4),
},
"& > .AccordionChevron": {
"transition": f"transform var(--animation-duration) var(--animation-easing)",
"transition": "transform var(--animation-duration) var(--animation-easing)",
},
_inherited_variant_selector("classic"): {
"color": "var(--accent-contrast)",
Expand Down Expand Up @@ -485,11 +485,11 @@ def add_style(self) -> dict[str, Any] | None:
The style of the component.
"""
slideDown = LiteralVar.create(
f"${{slideDown}} var(--animation-duration) var(--animation-easing)",
"${slideDown} var(--animation-duration) var(--animation-easing)",
)

slideUp = LiteralVar.create(
f"${{slideUp}} var(--animation-duration) var(--animation-easing)",
"${slideUp} var(--animation-duration) var(--animation-easing)",
)

return {
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/radix/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _render(self, props: dict[str, Any] | None = None) -> Tag:
tag = super()._render(props)
tag.add_props(
css=Var(
_js_expr=f"{{...theme.styles.global[':root'], ...theme.styles.global.body}}"
_js_expr="{...theme.styles.global[':root'], ...theme.styles.global.body}"
),
)
return tag
Expand Down
2 changes: 1 addition & 1 deletion reflex/constants/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Reflex(SimpleNamespace):
# The root directory of the reflex library.
ROOT_DIR = Path(__file__).parents[2]

RELEASES_URL = f"https://api.github.com/repos/reflex-dev/templates/releases"
RELEASES_URL = "https://api.github.com/repos/reflex-dev/templates/releases"


class ReflexHostingCLI(SimpleNamespace):
Expand Down
2 changes: 1 addition & 1 deletion reflex/constants/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def DEFAULT_PATH(cls):

DEFAULT_CONFIG = """
[install]
registry = {registry}
registry = "{registry}"
"""


Expand Down
8 changes: 4 additions & 4 deletions reflex/custom_components/custom_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ def _validate_project_info():
)
# PyPI only shows the first author.
author = project.get("authors", [{}])[0]
author["name"] = console.ask(f"Author Name", default=author.get("name", ""))
author["email"] = console.ask(f"Author Email", default=author.get("email", ""))
author["name"] = console.ask("Author Name", default=author.get("name", ""))
author["email"] = console.ask("Author Email", default=author.get("email", ""))

console.print(f'Current keywords are: {project.get("keywords") or []}')
keyword_action = console.ask(
Expand Down Expand Up @@ -923,7 +923,7 @@ def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None:
image_file = file_extension = None
while image_file is None:
image_filepath = console.ask(
f"Upload a preview image of your demo app (enter to skip)"
"Upload a preview image of your demo app (enter to skip)"
)
if not image_filepath:
break
Expand Down Expand Up @@ -973,6 +973,6 @@ def install(
console.set_log_level(loglevel)

if _pip_install_on_demand(package_name=".", install_args=["-e"]):
console.info(f"Package installed successfully!")
console.info("Package installed successfully!")
else:
raise typer.Exit(code=1)
2 changes: 1 addition & 1 deletion reflex/reflex.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _login() -> str:
access_token = hosting.authenticate_on_browser(invitation_code)

if not access_token:
console.error(f"Unable to authenticate. Please try again or contact support.")
console.error("Unable to authenticate. Please try again or contact support.")
raise typer.Exit(1)

console.print("Successfully logged in.")
Expand Down
1 change: 0 additions & 1 deletion reflex/utils/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def ask(
def progress():
"""Create a new progress bar.
Returns:
A new progress bar.
"""
Expand Down
2 changes: 1 addition & 1 deletion reflex/utils/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def output_system_info():
except Exception:
config_file = None

console.rule(f"System Info")
console.rule("System Info")
console.debug(f"Config file: {config_file!r}")
console.debug(f"Config: {config}")

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_background_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def background_task(
running AppHarness instance
"""
with AppHarness.create(
root=tmp_path_factory.mktemp(f"background_task"),
root=tmp_path_factory.mktemp("background_task"),
app_source=BackgroundTask, # type: ignore
) as harness:
yield harness
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_computed_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def computed_vars(
running AppHarness instance
"""
with AppHarness.create(
root=tmp_path_factory.mktemp(f"computed_vars"),
root=tmp_path_factory.mktemp("computed_vars"),
app_source=ComputedVars, # type: ignore
) as harness:
yield harness
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_dynamic_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def dynamic_route(
running AppHarness instance
"""
with app_harness_env.create(
root=tmp_path_factory.mktemp(f"dynamic_route"),
root=tmp_path_factory.mktemp("dynamic_route"),
app_name=f"dynamicroute_{app_harness_env.__name__.lower()}",
app_source=DynamicRoute, # type: ignore
) as harness:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_event_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def event_action(tmp_path_factory) -> Generator[AppHarness, None, None]:
running AppHarness instance
"""
with AppHarness.create(
root=tmp_path_factory.mktemp(f"event_action"),
root=tmp_path_factory.mktemp("event_action"),
app_source=TestEventAction, # type: ignore
) as harness:
yield harness
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_large_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_large_state(var_count: int, tmp_path_factory, benchmark):
large_state_rendered = template.render(var_count=var_count)

with AppHarness.create(
root=tmp_path_factory.mktemp(f"large_state"),
root=tmp_path_factory.mktemp("large_state"),
app_source=large_state_rendered,
app_name="large_state",
) as large_state:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def test_navigation_app(navigation_app: AppHarness):

with poll_for_navigation(driver):
internal_link.click()
assert urlsplit(driver.current_url).path == f"/internal/"
assert urlsplit(driver.current_url).path == "/internal/"
with poll_for_navigation(driver):
driver.back()

Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_server_side_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]:
def driver(server_side_event: AppHarness):
"""Get an instance of the browser open to the server_side_event app.
Args:
server_side_event: harness for ServerSideEvent app
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_state_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def state_inheritance(
running AppHarness instance
"""
with AppHarness.create(
root=tmp_path_factory.mktemp(f"state_inheritance"),
root=tmp_path_factory.mktemp("state_inheritance"),
app_source=StateInheritance, # type: ignore
) as harness:
yield harness
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive
substate_token = f"{token}_{state_full_name}"

upload_box = driver.find_elements(By.XPATH, "//input[@type='file']")[1]
upload_button = driver.find_element(By.ID, f"upload_button_secondary")
cancel_button = driver.find_element(By.ID, f"cancel_button_secondary")
upload_button = driver.find_element(By.ID, "upload_button_secondary")
cancel_button = driver.find_element(By.ID, "cancel_button_secondary")

exp_name = "large.txt"
target_file = tmp_path / exp_name
Expand Down
10 changes: 5 additions & 5 deletions tests/units/compiler/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ def test_compile_stylesheets(tmp_path, mocker):

assert compiler.compile_root_stylesheet(stylesheets) == (
str(Path(".web") / "styles" / "styles.css"),
f"@import url('./tailwind.css'); \n"
f"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
f"@import url('https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'); \n"
f"@import url('../public/styles.css'); \n"
f"@import url('https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-theme.min.css'); \n",
"@import url('./tailwind.css'); \n"
"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
"@import url('https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'); \n"
"@import url('../public/styles.css'); \n"
"@import url('https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-theme.min.css'); \n",
)


Expand Down
1 change: 0 additions & 1 deletion tests/units/components/core/test_debounce.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class S(BaseState):
def on_change(self, v: str):
"""Dummy on_change handler.
Args:
v: The changed value.
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/units/components/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ def test_stateful_banner():
merge_var_data=TEST_VAR._var_data
)
FORMATTED_TEST_VAR_DICT_OF_DICT = LiteralVar.create(
{"a": {"b": f"footestbar"}}
{"a": {"b": "footestbar"}}
)._replace(merge_var_data=TEST_VAR._var_data)

TEST_VAR_LIST_OF_LIST = LiteralVar.create([["test"]])._replace(
Expand Down
4 changes: 2 additions & 2 deletions tests/units/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,11 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker):
}

file1 = UploadFile(
filename=f"image1.jpg",
filename="image1.jpg",
file=bio,
)
file2 = UploadFile(
filename=f"image2.jpg",
filename="image2.jpg",
file=bio,
)
upload_fn = upload(app)
Expand Down
Loading

0 comments on commit 0ef8abd

Please sign in to comment.