[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-26 Thread Nick Coghlan
Nick Coghlan added the comment: On the historical front, wraps & update_wrapper were only designed to handle true wrapper functions (i.e. those that don't change the calling signature). For anything else (including partial), I considered it unlikely that the doc string would still be accurat

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-25 Thread Graham Dumpleton
Graham Dumpleton added the comment: These days I have no idea who is active on Django. -- ___ Python tracker ___ ___ Python-bugs-li

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-25 Thread Larry Hastings
Larry Hastings added the comment: Ooh, good one. I don't know anybody in the Django project to contact though. Anybody have any leads? -- ___ Python tracker ___ ___

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-25 Thread Graham Dumpleton
Graham Dumpleton added the comment: Another example in Django, albeit in a test harness. * https://github.com/django/django/blob/7119f40c9881666b6f9b5cf7df09ee1d21cc8344/tests/urlpatterns_reverse/views.py#L65 -- ___ Python tracker

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-25 Thread Graham Dumpleton
Graham Dumpleton added the comment: It is Django I would worry about and look at closely as they do stuff with decorators on instance methods that uses partials. https://github.com/django/django/blob/7119f40c9881666b6f9b5cf7df09ee1d21cc8344/django/utils/decorators.py#L43 ``` def _wrapper

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-25 Thread Larry Hastings
Larry Hastings added the comment: I heard back from both Samuel Colvin (Pydantic) and Sebastián Ramírez (FastAPI). They said neither of them use update_wrapper with partial objects. They also took a peek in a bunch of other projects (FastAPI, Typer, SQLModel, Asyncer, SQLAlchemy, Trio, and

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-12 Thread Larry Hastings
Larry Hastings added the comment: You make a good point. I filed a separate bug (#46846) suggesting that partial objects should set their own annotations and signature. I agree that objects performing such magic should take care of these details themselves, rather than requiring the inspec

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-12 Thread Graham Dumpleton
Graham Dumpleton added the comment: I am still working through this and thinking about implications, but my first impression is that the functools.partial object should provide an attribute (property) __signature__ which yields the correct result. When you think about it, any user who wants

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-11 Thread Graham Dumpleton
Graham Dumpleton added the comment: My vague recollection was that I identified some time back that partial() didn't behave correctly regards introspection for some use case I was trying to apply it to in the wrapt implementation. As a result I ended up creating my own PartialCallableObjectP

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-10 Thread Larry Hastings
Larry Hastings added the comment: Nobody I've nosied on this issue recently has expressed any opinion on the matter. I'm gonna try one more person: Graham Dumpleton, the maintainer of "wrapt", Python's premier function-wrapping. Graham, care to express any opinions about this issue? Can we

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-03-06 Thread Ofey Chan
Ofey Chan added the comment: I updated NEWS and all checks have passed! -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-27 Thread Larry Hastings
Larry Hastings added the comment: I emailed the Pydantic and FastAPI guys and didn't hear back. Given what you found on their issue trackers, I think it's unlikely that they care a lot about this issue (but were too busy to reply). It's far more likely that they don't care. Doing a little

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-27 Thread Ofey Chan
Ofey Chan added the comment: > Maybe we can loop in someone who works on a popular runtime function > introspection library (FastAPI, Pydantic) to see if they have any take on it. I've checked issues of FastAPI and Pydantic. There is only one issue about `update_wrapper()`, and it's about do

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-24 Thread Larry Hastings
Larry Hastings added the comment: Okay, so, I considered the problem for a while, and I have a reasonable theory about what follow_wrapper_chains was for in the first place. If you have a generic decorator, like functools.cache(), it usually looks like this: def my_decorator(fn): def

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-23 Thread Ofey Chan
Ofey Chan added the comment: Thank you Larry. It can never be too careful to deal with language issues! > why the code behaves like this--is this behavior a genuine bug, or is it > actually a bugfix for some worse behavior? In my view, there's rather an concept needing clarify, than a genui

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-23 Thread Larry Hastings
Larry Hastings added the comment: Ofey, I appreciate your enthusiasm, but you should probably slow down. Fixing the bug is probably going to be the easy part here. But we're not to that stage quite yet. First, we need to determine * why the code behaves like this--is this behavior a genui

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-23 Thread Ofey Chan
Change by Ofey Chan : Added file: https://bugs.python.org/file50639/update_wrapper.breaks.partial.signature.check.__wrapped__.py ___ Python tracker ___ ___

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-23 Thread Ofey Chan
Ofey Chan added the comment: I fix the problem. But sorry for my last message, because it totally miss the point ;) In `inspect.signature()`, the order of handle `follow_wrapper_chains` and `functools.partial` cause the problem. Relevant code: https://github.com/python/cpython/blob/288af84

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-23 Thread Ofey Chan
Change by Ofey Chan : -- keywords: +patch pull_requests: +29653 stage: test needed -> patch review pull_request: https://github.com/python/cpython/pull/31529 ___ Python tracker ___

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-23 Thread Ofey Chan
Ofey Chan added the comment: Hello, I am new to cpython project and want to help. I dig into `follow_wrapper_chains` feature and found it really interesting. In `inspect.signature()`, the conversion of `functools.partial` object's signature is made when going down the unwrap chain. Relevant

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-21 Thread Ka-Ping Yee
Ka-Ping Yee added the comment: Hmm, interesting. I wasn't involved in writing the `follow_wrapper_chains` feature, so I don't know why it's there. I wonder if some digging through the revision history of `functools.py` and `inspect.py` would yield insight. -- _

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-19 Thread Larry Hastings
Larry Hastings added the comment: Yury, Ka-Ping, can you guys shed any light on this? Your names are still on inspect.py. -- nosy: +ping, yselivanov ___ Python tracker ___ _

[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-15 Thread Larry Hastings
New submission from Larry Hastings : It's considered good hygiene to use functools.update_wrapper() to make your wrapped functions look like the original. However, when using functools.partial() to pre-supply arguments to a function, if you then call functools.update_wrapper() to update that