Repository: litestar-org/litestar

Issue:
Bug: `AttributeError: 'wrapper_descriptor' object has no attribute '__module__'`
### Description

Litestar app fails to start, due to the above error.

### URL to code causing the issue

https://github.com/litestar-org/litestar/blob/4f734ea5970d414d49b92cf3c49988aa158cad30/litestar/utils/signature.py#L64

### MCVE

```python
from uuid import UUID

from litestar import Controller, Litestar, get
from litestar.di import Provide
from pydantic import BaseModel


class TestService:
    ...


class TestOutput(BaseModel):
    id: UUID


class TestController(Controller):
    path = "/test"
    dependencies = {
        "test_service": Provide(TestService),
    }

    @get("/{test_id:uuid}")
    async def get_by_id(self, test_id: UUID) -> TestOutput:
        return TestOutput(id=test_id)


app = Litestar(
    route_handlers=[TestController],
)
```

### Steps to reproduce

Run the app in MCVE section above.

### Screenshots

_No response_

### Logs

```bash
File "/app/src/asgi.py", line 11, in <module>
    app = Litestar(
          ^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 438, in __init__
    self.register(route_handler)
  File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 546, in register
    self._create_handler_signature_model(route_handler=route_handler)
  File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 775, in _create_handler_signature_model
    parsed_signature=ParsedSignature.from_fn(
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/litestar/utils/signature.py", line 283, in from_fn
    fn_type_hints = get_fn_type_hints(fn, namespace=signature_namespace)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/litestar/utils/signature.py", line 64, in get_fn_type_hints
    **vars(sys.modules[fn_to_inspect.__module__]),
                       ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'wrapper_descriptor' object has no attribute '__module__'. Did you mean: '__reduce__'?
```


### Litestar Version

- `main` branch
- v2.0.0alpha4

### Platform

- [X] Linux
- [ ] Mac
- [ ] Windows
- [ ] Other (Please specify in the description above)


Discussion:
Thanks for the report @lqmanh - if possible, can you provide an example of the code that reproduces this?
@peterschutt I've updated the MCVE code

Resolving patch:
diff --git a/litestar/utils/signature.py b/litestar/utils/signature.py
--- a/litestar/utils/signature.py
+++ b/litestar/utils/signature.py
@@ -45,6 +45,8 @@ def get_fn_type_hints(fn: Any, namespace: dict[str, Any] | None = None) -> dict[
     """
     fn_to_inspect: Any = fn
 
+    module_name = fn_to_inspect.__module__
+
     if isclass(fn_to_inspect):
         fn_to_inspect = fn_to_inspect.__init__
 
@@ -61,7 +63,7 @@ def get_fn_type_hints(fn: Any, namespace: dict[str, Any] | None = None) -> dict[
     namespace = {
         **_GLOBAL_NAMES,
         **vars(typing),
-        **vars(sys.modules[fn_to_inspect.__module__]),
+        **vars(sys.modules[module_name]),
         **(namespace or {}),
     }
     return get_type_hints(fn_to_inspect, globalns=namespace, include_extras=True)


Test patch:
diff --git a/tests/utils/test_signature.py b/tests/utils/test_signature.py
--- a/tests/utils/test_signature.py
+++ b/tests/utils/test_signature.py
@@ -42,6 +42,18 @@ def test_get_fn_type_hints(fn: Any) -> None:
     assert get_fn_type_hints(fn) == {"a": int, "b": str, "c": float, "return": NoneType}
 
 
+def test_get_fn_type_hints_class_no_init() -> None:
+    """Test that get_fn_type_hints works with classes that don't have an __init__ method.
+
+    Ref: https://github.com/litestar-org/litestar/issues/1504
+    """
+
+    class C:
+        ...
+
+    assert get_fn_type_hints(C) == {}
+
+
 class _TD(TypedDict):
     req_int: Required[int]
     req_list_int: Required[List[int]]