Skip to content

Commit 44144e3

Browse files
committed
more
1 parent 8c902cc commit 44144e3

File tree

8 files changed

+26
-36
lines changed

8 files changed

+26
-36
lines changed

reflex/custom_components/custom_components.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _get_default_library_name_parts() -> list[str]:
359359
"""Get the default library name. Based on the current directory name, remove any non-alphanumeric characters.
360360
361361
Raises:
362-
Exit: If the current directory name is not suitable for python projects, and we cannot find a valid library name based off it.
362+
SystemExit: If the current directory name is not suitable for python projects, and we cannot find a valid library name based off it.
363363
364364
Returns:
365365
The parts of default library name.
@@ -408,7 +408,7 @@ def _validate_library_name(library_name: str | None) -> NameVariants:
408408
library_name: The name of the library if picked otherwise None.
409409
410410
Raises:
411-
Exit: If the library name is not suitable for python projects.
411+
SystemExit: If the library name is not suitable for python projects.
412412
413413
Returns:
414414
A tuple containing the various names such as package name, class name, etc., needed for the project.
@@ -513,7 +513,7 @@ def init(
513513
install: Whether to install package from this local custom component in editable mode.
514514
515515
Raises:
516-
Exit: If the pyproject.toml already exists.
516+
SystemExit: If the pyproject.toml already exists.
517517
"""
518518
from reflex.utils import exec
519519

@@ -627,7 +627,7 @@ def _run_build():
627627
"""Run the build command.
628628
629629
Raises:
630-
Exit: If the build fails.
630+
SystemExit: If the build fails.
631631
"""
632632
console.print("Building custom component...")
633633

@@ -651,7 +651,7 @@ def _collect_details_for_gallery():
651651
"""Helper to collect details on the custom component to be included in the gallery.
652652
653653
Raises:
654-
Exit: If pyproject.toml file is ill-formed or the request to the backend services fails.
654+
SystemExit: If pyproject.toml file is ill-formed or the request to the backend services fails.
655655
"""
656656
import httpx
657657
from reflex_cli.utils import hosting
@@ -790,7 +790,7 @@ def install():
790790
"""Install package from this local custom component in editable mode.
791791
792792
Raises:
793-
Exit: If unable to install the current directory in editable mode.
793+
SystemExit: If unable to install the current directory in editable mode.
794794
"""
795795
if _pip_install_on_demand(package_name=".", install_args=["-e"]):
796796
console.info("Package installed successfully!")

reflex/utils/frontend_skeleton.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import re
66
from pathlib import Path
77

8-
import click
9-
108
from reflex import constants
119
from reflex.compiler import templates
1210
from reflex.config import Config, get_config
@@ -54,7 +52,7 @@ def initialize_requirements_txt() -> bool:
5452
True if the user has to update the requirements.txt file.
5553
5654
Raises:
57-
Exit: If the requirements.txt file cannot be read or written to.
55+
SystemExit: If the requirements.txt file cannot be read or written to.
5856
"""
5957
requirements_file_path = Path(constants.RequirementsTxt.FILE)
6058
if (

reflex/utils/js_runtimes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from collections.abc import Sequence
77
from pathlib import Path
88

9-
import click
109
from packaging import version
1110

1211
from reflex import constants
@@ -193,7 +192,7 @@ def download_and_run(url: str, *args, show_status: bool = False, **env):
193192
env: The environment variables to use.
194193
195194
Raises:
196-
Exit: If the script fails to download.
195+
SystemExit: If the script fails to download.
197196
"""
198197
import httpx
199198

@@ -226,7 +225,7 @@ def install_bun():
226225
227226
Raises:
228227
SystemPackageMissingError: If "unzip" is missing.
229-
Exit: If REFLEX_USE_NPM is set but Node.js is not installed.
228+
SystemExit: If REFLEX_USE_NPM is set but Node.js is not installed.
230229
"""
231230
if npm_escape_hatch():
232231
if get_node_version() is not None:
@@ -290,7 +289,7 @@ def validate_bun(bun_path: Path | None = None):
290289
bun_path: The path to the bun executable. If None, the default bun path is used.
291290
292291
Raises:
293-
Exit: If custom specified bun does not exist or does not meet requirements.
292+
SystemExit: If custom specified bun does not exist or does not meet requirements.
294293
"""
295294
bun_path = bun_path or path_ops.get_bun_path()
296295

@@ -320,7 +319,7 @@ def validate_frontend_dependencies(init: bool = True):
320319
init: whether running `reflex init`
321320
322321
Raises:
323-
Exit: If the package manager is invalid.
322+
SystemExit: If the package manager is invalid.
324323
"""
325324
if not init:
326325
try:

reflex/utils/prerequisites.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from types import ModuleType
1616
from typing import NamedTuple
1717

18-
import click
1918
from alembic.util.exc import CommandError
2019
from packaging import version
2120
from redis import Redis as RedisSync
@@ -444,7 +443,7 @@ def validate_app_name(app_name: str | None = None) -> str:
444443
The app name after validation.
445444
446445
Raises:
447-
Exit: if the app directory name is reflex or if the name is not standard for a python package name.
446+
SystemExit: if the app directory name is reflex or if the name is not standard for a python package name.
448447
"""
449448
app_name = app_name if app_name else Path.cwd().name.replace("-", "_")
450449
# Make sure the app is not named "reflex".
@@ -499,7 +498,7 @@ def assert_in_reflex_dir():
499498
"""Assert that the current working directory is the reflex directory.
500499
501500
Raises:
502-
Exit: If the current working directory is not the reflex directory.
501+
SystemExit: If the current working directory is not the reflex directory.
503502
"""
504503
if not constants.Config.FILE.exists():
505504
console.error(

reflex/utils/processes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from pathlib import Path
1616
from typing import Any, Literal, overload
1717

18-
import click
1918
import rich.markup
2019
from redis.exceptions import RedisError
2120
from rich.progress import Progress
@@ -39,7 +38,7 @@ def get_num_workers() -> int:
3938
"""Get the number of backend worker processes.
4039
4140
Raises:
42-
Exit: If unable to connect to Redis.
41+
SystemExit: If unable to connect to Redis.
4342
4443
Returns:
4544
The number of backend worker processes.
@@ -131,7 +130,7 @@ def handle_port(service_name: str, port: int, auto_increment: bool) -> int:
131130
The port to run the service on.
132131
133132
Raises:
134-
Exit:when the port is in use.
133+
SystemExit:when the port is in use.
135134
"""
136135
console.debug(f"Checking if {service_name.capitalize()} port: {port} is in use.")
137136

@@ -211,7 +210,7 @@ def new_process(
211210
Execute a child program in a new process.
212211
213212
Raises:
214-
Exit: When attempting to run a command with a None value.
213+
SystemExit: When attempting to run a command with a None value.
215214
"""
216215
# Check for invalid command first.
217216
non_empty_args = list(filter(None, args)) if isinstance(args, list) else [args]
@@ -325,7 +324,7 @@ def stream_logs(
325324
The lines of the process output.
326325
327326
Raises:
328-
Exit: If the process failed.
327+
SystemExit: If the process failed.
329328
ValueError: If the process stdout pipe is closed, but the process remains running.
330329
"""
331330
from reflex.utils import telemetry

reflex/utils/rename.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import sys
55
from pathlib import Path
66

7-
import click
8-
97
from reflex import constants
108
from reflex.config import get_config
119
from reflex.utils import console
@@ -57,7 +55,7 @@ def rename_app(new_app_name: str, loglevel: constants.LogLevel):
5755
loglevel: The log level to use.
5856
5957
Raises:
60-
Exit: If the command is not ran in the root dir or the app module cannot be imported.
58+
SystemExit: If the command is not ran in the root dir or the app module cannot be imported.
6159
"""
6260
# Set the log level.
6361
console.set_log_level(loglevel)

reflex/utils/templates.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from pathlib import Path
88
from urllib.parse import urlparse
99

10-
import click
11-
1210
from reflex import constants
1311
from reflex.config import get_config
1412
from reflex.utils import console, net, path_ops, redir
@@ -51,7 +49,7 @@ def initialize_app_directory(
5149
template_dir: The directory of the template source files.
5250
5351
Raises:
54-
Exit: If template_name, template_code_dir_name, template_dir combination is not supported.
52+
SystemExit: If template_name, template_code_dir_name, template_dir combination is not supported.
5553
"""
5654
console.log("Initializing the app directory.")
5755

@@ -117,7 +115,7 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str
117115
template_url: The path to the template source code as a zip file.
118116
119117
Raises:
120-
Exit: If any download, file operations fail or unexpected zip file format.
118+
SystemExit: If any download, file operations fail or unexpected zip file format.
121119
122120
"""
123121
import httpx
@@ -204,7 +202,7 @@ def validate_and_create_app_using_remote_template(
204202
templates: The available templates.
205203
206204
Raises:
207-
Exit: If the template is not found.
205+
SystemExit: If the template is not found.
208206
"""
209207
# If user selects a template, it needs to exist.
210208
if template in templates:
@@ -327,7 +325,7 @@ def prompt_for_template_options(templates: list[Template]) -> str:
327325
The template name the user selects.
328326
329327
Raises:
330-
Exit: If the user does not select a template.
328+
SystemExit: If the user does not select a template.
331329
"""
332330
# Show the user the URLs of each template to preview.
333331
console.print("\nGet started with a template:")
@@ -372,7 +370,7 @@ def initialize_app(app_name: str, template: str | None = None) -> str | None:
372370
The name of the template.
373371
374372
Raises:
375-
Exit: If the template is not valid or unspecified.
373+
SystemExit: If the template is not valid or unspecified.
376374
"""
377375
# Local imports to avoid circular imports.
378376
from reflex.utils import telemetry

tests/units/utils/test_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
from typing import Any, ClassVar, List, Literal, NoReturn # noqa: UP035
77

8-
import click
98
import pytest
109
from packaging import version
1110
from pytest_mock import MockerFixture
@@ -192,7 +191,7 @@ def test_validate_invalid_bun_path(mocker: MockerFixture):
192191
mocker.patch("reflex.utils.path_ops.samefile", return_value=False)
193192
mocker.patch("reflex.utils.js_runtimes.get_bun_version", return_value=None)
194193

195-
with pytest.raises(click.exceptions.Exit):
194+
with pytest.raises(SystemExit):
196195
js_runtimes.validate_bun()
197196

198197

@@ -434,10 +433,10 @@ def test_validate_app_name(tmp_path, mocker: MockerFixture):
434433

435434
mocker.patch("os.getcwd", return_value=str(reflex))
436435

437-
with pytest.raises(click.exceptions.Exit):
436+
with pytest.raises(SystemExit):
438437
prerequisites.validate_app_name()
439438

440-
with pytest.raises(click.exceptions.Exit):
439+
with pytest.raises(SystemExit):
441440
prerequisites.validate_app_name(app_name="1_test")
442441

443442

0 commit comments

Comments
 (0)