diff --git a/pyproject.toml b/pyproject.toml index 619c4ff47..8d20e256e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,13 +93,13 @@ build-backend = "poetry.core.masonry.api" [tool.ruff] target-version = "py39" lint.isort.split-on-trailing-comma = false -lint.select = ["B", "D", "E", "F", "I", "SIM", "W"] +lint.select = ["B", "D", "E", "F", "I", "SIM", "W", "S101"] lint.ignore = ["B008", "D205", "E501", "F403", "SIM115"] lint.pydocstyle.convention = "google" [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"tests/*.py" = ["D100", "D103", "D104", "B018"] +"tests/*.py" = ["D100", "D103", "D104", "B018", "S101"] "reflex/.templates/*.py" = ["D100", "D103", "D104"] "*.pyi" = ["D301", "D415", "D417", "D418", "E742"] "*/blank.py" = ["I001"] diff --git a/reflex/assets.py b/reflex/assets.py index 8a50664b6..a175315a3 100644 --- a/reflex/assets.py +++ b/reflex/assets.py @@ -46,7 +46,7 @@ def asset( Raises: FileNotFoundError: If the file does not exist. - ValueError: If subfolder is provided for local assets. + ValueError: If subfolder is provided for local assets or the module is not found. Returns: The relative URL to the asset. @@ -69,7 +69,8 @@ def asset( frame = inspect.stack()[_stack_level] calling_file = frame.filename module = inspect.getmodule(frame[0]) - assert module is not None + if module is None: + raise ValueError(f"Module {frame[0]} not found.") external = constants.Dirs.EXTERNAL_APP_ASSETS src_file_shared = Path(calling_file).parent / path