This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年05月24日 21:20 by terrence, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
functools-wrapper-assign-annotations.diff | terrence, 2010年05月24日 21:20 | Patch to add __annotations__ to WRAPPER_ASSIGNMENTS | ||
functools-wrapper-assign-annotations.diff | terrence, 2010年05月24日 21:48 | Improved patch with documentation fixed to match. | ||
functools-wrapper-assign-annotations.diff | terrence, 2010年06月17日 01:04 | Improved patch with documentation and tests |
Pull Requests | |||
---|---|---|---|
URL | Status | Linked | Edit |
PR 21392 | open | David Caro, 2020年07月08日 09:16 |
Messages (13) | |||
---|---|---|---|
msg106394 - (view) | Author: Terrence Cole (terrence) | Date: 2010年05月24日 21:20 | |
__annotations__ should be included in the set of attributes copied by default to a wrapped method. An example of the problem: >>> from functools import wraps >>> def mydecorator(fn): ... @wraps(fn) ... def inner(*args, **kwargs): ... return fn(*args, **kwargs) ... return inner ... >>> @mydecorator ... def foo(a:int, b:str): ... pass ... >>> foo.__annotations__ {} With the included fix: >>> foo.__annotations__ {'a': <class 'int'>, 'b': <class 'str'>} |
|||
msg106396 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年05月24日 21:33 | |
The patch is fine. Can you check if some doc has to be updated to mention that? (files under Doc and docstrings in functools.py). Removing 3.1 since this is a new feature, and 3.3 since 3.2 is not frozen. |
|||
msg106402 - (view) | Author: Terrence Cole (terrence) | Date: 2010年05月24日 21:48 | |
Thank you for looking it over! The updated patch adds __annotations__ to the documentation where the value of WRAPPER_ASSIGNMENTS is given. I think it would be nice if the documentation showed WRAPPER_ASSIGNMENTS and WRAPPER_UPDATES in their own section, but that would probably merit a separate issue to fix, if it is even worth bothering with. |
|||
msg107759 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年06月13日 22:13 | |
Patch looks good to me. Could you add some tests to Lib/test/test_functools.py to check that annotations are really copied? (3.2 is not frozen, adjusting versions) |
|||
msg107974 - (view) | Author: Terrence Cole (terrence) | Date: 2010年06月17日 01:04 | |
Alright, I've added several tests. I also modified update_wrapper to not copy missing attributes (like __annotations__ on builtin methods) -- see issue 1576241. (I also finally see what you mean with removing 3.3 from the versions list. Sorry I didn't grok that before.) |
|||
msg112851 - (view) | Author: Terrence Cole (terrence) | Date: 2010年08月04日 18:18 | |
Is there still a chance to get this fix in 3.2? |
|||
msg112852 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年08月04日 18:29 | |
The patch is now committed in py3k (r83731). Thanks for your contribution! |
|||
msg112856 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年08月04日 18:38 | |
This should probably be backported to 3.1 |
|||
msg112858 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年08月04日 18:48 | |
> This should probably be backported to 3.1 Well, I think this is technically a new feature. If someone wants to backport it, then fine, but I don't think there's much point in doing so. |
|||
msg112860 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年08月04日 18:52 | |
Okay, I'll do it. The intention of wrapper assignments was to wrap all of the standard attributes, so the omission of __annotations__ is a bug. |
|||
msg112874 - (view) | Author: Terrence Cole (terrence) | Date: 2010年08月04日 19:50 | |
Awesome! I greatly appreciate the 3.1 backport, as that's what I'm going to be using for the foreseeable future. |
|||
msg112903 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年08月04日 21:42 | |
Thanks for sticking with this Terrence, it fell off my radar. Thanks Antoine for the commit. |
|||
msg113220 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年08月08日 00:57 | |
Backported to Py3.1 in r83807 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022年04月11日 14:57:01 | admin | set | github: 53060 |
2020年07月08日 09:16:01 | David Caro | set | nosy:
+ David Caro pull_requests: + pull_request20539 |
2010年08月08日 00:57:27 | rhettinger | set | status: open -> closed messages: + msg113220 |
2010年08月04日 21:42:36 | eric.araujo | set | messages:
+ msg112903 versions: + Python 3.1 |
2010年08月04日 19:50:04 | terrence | set | messages:
+ msg112874 versions: + Python 3.2, - Python 3.1 |
2010年08月04日 18:52:26 | rhettinger | set | status: closed -> open assignee: rhettinger messages: + msg112860 versions: + Python 3.1, - Python 3.2 |
2010年08月04日 18:48:47 | pitrou | set | messages: + msg112858 |
2010年08月04日 18:38:51 | rhettinger | set | nosy:
+ rhettinger messages: + msg112856 |
2010年08月04日 18:29:02 | pitrou | set | status: open -> closed nosy: + pitrou messages: + msg112852 resolution: fixed |
2010年08月04日 18:18:52 | terrence | set | messages: + msg112851 |
2010年06月17日 01:04:17 | terrence | set | files:
+ functools-wrapper-assign-annotations.diff messages: + msg107974 |
2010年06月13日 22:13:56 | eric.araujo | set | stage: test needed messages: + msg107759 versions: - Python 3.3 |
2010年05月24日 21:48:53 | terrence | set | files:
+ functools-wrapper-assign-annotations.diff messages: + msg106402 versions: + Python 3.3 |
2010年05月24日 21:33:00 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg106396 versions: - Python 3.1, Python 3.3 |
2010年05月24日 21:20:57 | terrence | create |