Repository: EmilStenstrom/django-components

Issue:
template_loader blocks on STATICFILES_DIRS if there are tuples
## How to reproduce

Simply run django with, in your _settings.py_, something like :
```
STATICFILES_DIRS = [
    # ...
    ("downloads", "/opt/webfiles/stats"),
]
```

(as made possible [natively in Django](https://docs.djangoproject.com/en/3.2/ref/settings/#std-setting-STATICFILES_DIRS))

## Current behaviour

Getting `TypeError: expected str, bytes or os.PathLike object, not tuple` given [this line] (https://github.com/EmilStenstrom/django-components/blob/e566d8ecbb7016cf3a8861a47a4a52e4a503b838/src/django_components/template_loader.py#L49) 


## Expected

`class Loader` from _src/django_components/template_loader.py_ should consider the second item of STATICFILES_DIRS list item when not a str.

## Furthermore

Thank you a lot, sir, for this django library. It helped us, a French news company, a lot to center our codebase almost fully on Django.
I might try to suggest a clean PR for this

Discussion:
JuroOravec: @alexandreMartinEcl Looks good to me! I pushed one fix for a typing error.

One thing that remains - the tests fail for Python 3.8-3.10 somewhere around [where we've added `MagicMock` or `@patch()`](https://github.com/EmilStenstrom/django-components/pull/489/files#diff-6faab92c5a5f55ed5c40230f2e1878cfe9603debd5af3d9b90c4ee875d5c2e93R141)
 
See logs https://github.com/EmilStenstrom/django-components/actions/runs/8990294238/job/24695481406?pr=489
alexandreMartinEcl: Indeed older version of python does not seem to appreciate my way to mock. It returns 
`'django_components.logger' is not a package` on `@patch("django_components.logger.logger.warning")`

I'm trying another way, but did not find a quick way to test on python3.8

HAve you maybe also experienced a difficulty with _mocking_ on old versions of python ?

Patch:
diff --git a/src/django_components/template_loader.py b/src/django_components/template_loader.py
index ea897b8..ae8ab3f 100644
--- a/src/django_components/template_loader.py
+++ b/src/django_components/template_loader.py
@@ -37,6 +37,16 @@ class Loader(FilesystemLoader):
 
         directories: Set[Path] = set()
         for component_dir in component_dirs:
+            if isinstance(component_dir, (tuple, list)) and len(component_dir) == 2:
+                component_dir = component_dir[1]
+            try:
+                Path(component_dir)
+            except TypeError:
+                logger.warning(
+                    f"STATICFILES_DIRS expected str, bytes or os.PathLike object, or tuple/list of length 2. "
+                    f"See Django documentation. Got {type(component_dir)} : {component_dir}"
+                )
+                continue
             curr_directories: Set[Path] = set()
 
             # For each dir in `settings.STATICFILES_DIRS`, we go over all Django apps


Test patch:
diff --git a/tests/test_autodiscover.py b/tests/test_autodiscover.py
index 9abde89..ff06eb5 100644
--- a/tests/test_autodiscover.py
+++ b/tests/test_autodiscover.py
@@ -1,5 +1,6 @@
 from pathlib import Path
 from unittest import mock
+from unittest.mock import MagicMock, patch
 
 from django.template.engine import Engine
 from django.urls import include, path
@@ -125,6 +126,29 @@ class TestBaseDir(BaseTestCase):
         self.assertEqual(sorted(dirs), sorted(expected))
 
 
+class TestStaticFilesDirs(BaseTestCase):
+    def setUp(self):
+        settings.STATICFILES_DIRS = [
+            "components",
+            ("with_alias", "components"),
+            ("too_many", "items", "components"),
+            ("with_not_str_alias", 3),
+        ]  # noqa
+
+    def tearDown(self) -> None:
+        del settings.STATICFILES_DIRS  # noqa
+
+    @patch("django_components.template_loader.logger.warning")
+    def test_static_files_dirs(self, mock_warning: MagicMock):
+        mock_warning.reset_mock()
+        current_engine = Engine.get_default()
+        Loader(current_engine).get_dirs()
+
+        warn_inputs = [warn.args[0] for warn in mock_warning.call_args_list]
+        assert "Got <class 'tuple'> : ('too_many', 'items', 'components')" in warn_inputs[0]
+        assert "Got <class 'int'> : 3" in warn_inputs[1]
+
+
 class TestFilepathToPythonModule(BaseTestCase):
     def test_prepares_path(self):
         self.assertEqual(