nebius/SWE-bench-extra huggingface dataset:
Repository: fgmacedo/python-statemachine

Issue:
SignatureAdapter wrap
* Python State Machine version: 2.0.0
* Python version: 3.7.16
* Operating System: MacBook

### Description

I have a decorator class for state machine child class's transitions methods.
The decorator has this function:
```
 def __get__(self, instance, owner):
        return partial(self.__call__, instance)
```
When partial is from functools package.

wrap function crashes on this line:
`sig.__name__ = method.__name__`
When method is functors.partial(decorator_class.__call__)

`AttributeError: 'functools.partial' object has no attribute '__name__'`



Comments:

Patch:
diff --git a/docs/releases/2.0.1.md b/docs/releases/2.0.1.md
new file mode 100644
index 0000000..fab6a72
--- /dev/null
+++ b/docs/releases/2.0.1.md
@@ -0,0 +1,12 @@
+# StateMachine 2.0.1
+
+*Not released yet*
+
+
+StateMachine 2.0.1 is a bugfix release.
+
+
+## Bugfixes
+
+- Fixes [#369](https://github.com/fgmacedo/python-statemachine/issues/336) adding support to wrap
+  methods used as {ref}`Actions` decorated with `functools.partial`.
diff --git a/docs/releases/index.md b/docs/releases/index.md
index e4a62da..2d8c6f5 100644
--- a/docs/releases/index.md
+++ b/docs/releases/index.md
@@ -15,6 +15,7 @@ Below are release notes through StateMachine and its patch releases.
 ```{toctree}
 :maxdepth: 1
 
+2.0.1
 2.0.0
 
 ```
diff --git a/statemachine/signature.py b/statemachine/signature.py
index bef064b..e3dca83 100644
--- a/statemachine/signature.py
+++ b/statemachine/signature.py
@@ -1,4 +1,5 @@
 import itertools
+from functools import partial
 from inspect import BoundArguments
 from inspect import Parameter
 from inspect import Signature
@@ -15,7 +16,9 @@ class SignatureAdapter(Signature):
 
         sig = cls.from_callable(method)
         sig.method = method
-        sig.__name__ = method.__name__
+        sig.__name__ = (
+            method.func.__name__ if isinstance(method, partial) else method.__name__
+        )
         return sig
 
     def __call__(self, *args: Any, **kwargs: Any) -> Any:


Test patch:
diff --git a/tests/test_signature.py b/tests/test_signature.py
index fd9a891..175d2e2 100644
--- a/tests/test_signature.py
+++ b/tests/test_signature.py
@@ -1,4 +1,5 @@
 import inspect
+from functools import partial
 
 import pytest
 
@@ -148,9 +149,17 @@ class TestSignatureAdapter:
     def test_wrap_fn_single_positional_parameter(self, func, args, kwargs, expected):
 
         wrapped_func = SignatureAdapter.wrap(func)
+        assert wrapped_func.__name__ == func.__name__
 
         if inspect.isclass(expected) and issubclass(expected, Exception):
             with pytest.raises(expected):
                 wrapped_func(*args, **kwargs)
         else:
             assert wrapped_func(*args, **kwargs) == expected
+
+    def test_support_for_partial(self):
+        part = partial(positional_and_kw_arguments, event="activated")
+        wrapped_func = SignatureAdapter.wrap(part)
+
+        assert wrapped_func("A", "B") == ("A", "B", "activated")
+        assert wrapped_func.__name__ == positional_and_kw_arguments.__name__