Repository: litestar-org/litestar

Issue:
StaticFilesConfig and virtual directories
I'm trying to write a ``FileSystemProtocol`` to load files from the package data using [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/using.html#). But because ``directories`` is defined as ``DirectoryPath``, pydantic checks if the given directories exist in the local filesystem. 

This is not generally true, especially in any kind of virtual filesystem (e.g. a zipped package). I think this condition should be relaxed to support virtual filesystems.

https://github.com/starlite-api/starlite/blob/9bb6dcd57c10a591377cf8e3a537e9292566d5b9/starlite/config/static_files.py#L32


Discussion:
I agree. Do you want to submit a PR?

Resolving patch:
diff --git a/starlite/cli/commands/core.py b/starlite/cli/commands/core.py
--- a/starlite/cli/commands/core.py
+++ b/starlite/cli/commands/core.py
@@ -62,6 +62,8 @@ def run_command(
     # invoke uvicorn in a subprocess to be able to use the --reload flag. see
     # https://github.com/litestar-org/litestar/issues/1191 and https://github.com/encode/uvicorn/issues/1045
 
+    show_app_info(app)
+
     process_args = {
         "reload": env.reload or reload,
         "host": env.host or host,


Test patch:
diff --git a/tests/cli/conftest.py b/tests/cli/conftest.py
--- a/tests/cli/conftest.py
+++ b/tests/cli/conftest.py
@@ -86,8 +86,8 @@ def runner() -> CliRunner:
 
 
 @pytest.fixture
-def mock_uvicorn_run(mocker: MockerFixture) -> "MagicMock":
-    return mocker.patch("uvicorn.run")
+def mock_subprocess_run(mocker: MockerFixture) -> "MagicMock":
+    return mocker.patch("subprocess.run")
 
 
 @pytest.fixture
diff --git a/tests/cli/test_run_command.py b/tests/cli/test_run_command.py
--- a/tests/cli/test_run_command.py
+++ b/tests/cli/test_run_command.py
@@ -26,7 +26,7 @@ def test_run_command(
     mocker: MockerFixture,
     runner: CliRunner,
     monkeypatch: MonkeyPatch,
-    mock_uvicorn_run: MagicMock,
+    mock_subprocess_run: MagicMock,
     reload: Optional[bool],
     port: Optional[int],
     host: Optional[str],
@@ -72,13 +72,12 @@ def test_run_command(
     assert result.exception is None
     assert result.exit_code == 0
 
-    mock_uvicorn_run.assert_called_once_with(
-        f"{path.stem}:app",
-        reload=reload,
-        port=port,
-        host=host,
-        factory=False,
-    )
+    expected_args = ["uvicorn", f"{path.stem}:app", f"--host={host}", f"--port={port}"]
+    if reload:
+        expected_args.append("--reload")
+
+    mock_subprocess_run.assert_called_once()
+    assert sorted(mock_subprocess_run.call_args_list[0].args[0]) == sorted(expected_args)
     mock_show_app_info.assert_called_once()
 
 
@@ -93,7 +92,7 @@ def test_run_command(
 )
 def test_run_command_with_autodiscover_app_factory(
     runner: CliRunner,
-    mock_uvicorn_run: MagicMock,
+    mock_subprocess_run: MagicMock,
     file_name: str,
     file_content: str,
     factory_name: str,
@@ -107,18 +106,14 @@ def test_run_command_with_autodiscover_app_factory(
     assert result.exception is None
     assert result.exit_code == 0
 
-    mock_uvicorn_run.assert_called_once_with(
-        f"{path.stem}:{factory_name}",
-        reload=False,
-        port=8000,
-        host="127.0.0.1",
-        factory=True,
-    )
+    expected_args = ["uvicorn", f"{path.stem}:{factory_name}", "--host=127.0.0.1", "--port=8000", "--factory"]
+    mock_subprocess_run.assert_called_once()
+    assert sorted(mock_subprocess_run.call_args_list[0].args[0]) == sorted(expected_args)
 
 
 def test_run_command_with_app_factory(
     runner: CliRunner,
-    mock_uvicorn_run: MagicMock,
+    mock_subprocess_run: MagicMock,
     create_app_file: CreateAppFileFixture,
 ) -> None:
     path = create_app_file("_create_app_with_path.py", content=CREATE_APP_FILE_CONTENT)
@@ -128,13 +123,9 @@ def test_run_command_with_app_factory(
     assert result.exception is None
     assert result.exit_code == 0
 
-    mock_uvicorn_run.assert_called_once_with(
-        f"{app_path}",
-        reload=False,
-        port=8000,
-        host="127.0.0.1",
-        factory=True,
-    )
+    expected_args = ["uvicorn", str(app_path), "--host=127.0.0.1", "--port=8000", "--factory"]
+    mock_subprocess_run.assert_called_once()
+    assert sorted(mock_subprocess_run.call_args_list[0].args[0]) == sorted(expected_args)
 
 
 def test_run_command_force_debug(app_file: Path, mocker: MockerFixture, runner: CliRunner) -> None: