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.

Unsupported provider

classification
Title: PEP 362 "Signature Objects" reference implementation
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Alexandre.Zani, Ramchandra Apte, Yury.Selivanov, benjamin.peterson, brett.cannon, eric.araujo, ezio.melotti, larry, python-dev, yselivanov
Priority: normal Keywords: needs review, patch

Created on 2012-06-05 22:06 by Yury.Selivanov, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pep362.1.patch Yury.Selivanov, 2012-06-05 22:06 review
pep362.2.patch Yury.Selivanov, 2012-06-14 02:29 review
pep362.3.patch Yury.Selivanov, 2012-06-15 18:04 review
pep362.4.patch Yury.Selivanov, 2012-06-19 02:27 review
pep362.5.patch Yury.Selivanov, 2012-06-19 17:58 review
pep362.6.patch Yury.Selivanov, 2012-06-19 19:26 review
pep362.7.patch Yury.Selivanov, 2012-06-21 17:15 review
pep362.8.patch Yury.Selivanov, 2012-06-22 20:11 review
Repositories containing patches
https://bitbucket.org/1st1/cpython/changesets/tip/branch(%22pep362%22)
Messages (17)
msg162377 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-05 22:06
This issue will track implementation of PEP 362 functionality.
msg162388 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-06-06 03:01
Signature and signature are two variable names that differ only in case.
To avoid confusion, I recommend one of the names should be changed.
msg162390 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-06 03:12
Well, 'Signature' class is unlikely to be used very frequently.  So I think it's fine.
msg162393 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-06-06 03:46
Yes, it seems quite common to me to have a class called Thing and instances named thing.  Unless it makes the code wrap better, using real names like signature instead of for example sig is recommended by PEP 8.
msg162748 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-14 02:29
Attaching a patch that implements the latest version of the PEP.

Quick summary:

1. Ditched Signature.name & Signature.qualname
2. Added Signature.__eq__ and __ne__
3. signature() supports classes, metaclasses, decorated stuff, partials, methods, classmethods, callable objects etc
4. signature() does a deepcopy of __signature__ attribute if
there is one
5. No implicit caching anywhere
6. Signature.format(...) and Signature.__str__
7. Signature.bind_partial
msg162927 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-15 18:04
Attaching the new version of the patch.

Summary:

1. 'is_*' family was replaced with 'Parameter.kind'
2. 'signature()' function was updated to check for '__wrapped__' 
attribute in all callables
3. 'is_implemented' -> 'implemented'
4. Added support for POSITIONAL_ONLY parameters (in 'bind()')
msg162979 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-06-16 16:52
One small thing: can we find a name for the function that starts with a verb?  It’s the recommended naming style for functions, and would help making a difference between the class and the function.  I also expect people to use “signature” and “sig” for their instances.
msg163133 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-19 02:27
New version (pep363.4.patch)

Summary:

1. Removed 'Signature.implemented'
2. No more patching built-ins - no issues with shared interpreters
3. Removed 'Signature.format()'. If needed we'll reintroduce it in 3.4 (although we still have 'Signature.__str__')
4. Signature now implements just __copy__ - creates a shallow copy (__deepcopy__ has been removed, as it wasn't deep)
5. Signature.__eq__ fixed to ignore order of keyword-only arguments.

Thanks and please review!
msg163134 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-19 02:29
Eric,

I personally prefer simple 'signature()' more than 'get_signature()'.  But I'll ask this question on python-dev on the next PEP update.
msg163197 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-19 17:58
New patch (pep362.5.patch)

Fixed a bug in BoundArguments.args & BoundArguments.kwargs
msg163202 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-06-19 18:38
I left a few comments on rietveld.
The '\' is sometimes used where not necessary and the preferred way to write conditions on multiple lines is:
(foo == bar and
 bar == baz and
 baz == asd)
rather than
foo == bar \
    and bar == baz \
    and baz == asd

Have you measured the coverage of the tests?
msg163203 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-19 19:26
New patch - pep362.6.patch

Ezio,

I've eliminated almost all '\'.
Test coverage is now almost 100%.
msg163352 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-21 17:15
New patch - pep362.7.patch

Summary:

1. Signature & Parameter objects are now immutable

2. Signature.replace() and Parameter.replace()

3. Signature has a new default constructor, which
accepts parameters list and a return_annotation; and
a new 'from_function', which create a Signature object
for the passed function.

4. Parameter.__str__

The implementation has 100% test coverage and is stable.
Please review.

Thanks!
msg163477 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2012-06-22 20:11
New patch - pep362.8.patch

One big change (Guido's request) - No more AttributeErrors on missing Parameter.default of Signature.return_annotation.  They now will be set to Parameter.empty & Signature.empty correspondingly.
msg163500 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-06-22 22:20
New changeset d892bf410478 by Larry Hastings in branch 'default':
Issue #15008: Implement PEP 362 "Signature Objects".
http://hg.python.org/cpython/rev/d892bf410478
msg166431 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-07-25 22:33
Are we going to get documentation?
msg166440 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2012-07-25 23:22
Benjamin: http://bugs.python.org/issue15151
History
Date User Action Args
2022-04-11 14:57:31adminsetgithub: 59213
2012-07-25 23:22:48yselivanovsetnosy: + yselivanov
messages: + msg166440
2012-07-25 22:33:54benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg166431
2012-06-26 02:29:46eric.araujolinkissue8916 superseder
2012-06-22 22:26:05larrysetstage: patch review -> resolved
2012-06-22 22:24:52Yury.Selivanovsetstatus: open -> closed
resolution: fixed
2012-06-22 22:20:13python-devsetnosy: + python-dev
messages: + msg163500
2012-06-22 20:11:40Yury.Selivanovsetfiles: + pep362.8.patch

messages: + msg163477
2012-06-21 17:15:15Yury.Selivanovsetfiles: + pep362.7.patch

messages: + msg163352
2012-06-19 19:26:33Yury.Selivanovsetfiles: + pep362.6.patch

messages: + msg163203
2012-06-19 18:38:34ezio.melottisetnosy: + ezio.melotti
messages: + msg163202
2012-06-19 17:59:04Yury.Selivanovsetfiles: + pep362.5.patch

messages: + msg163197
2012-06-19 02:29:05Yury.Selivanovsetmessages: + msg163134
2012-06-19 02:27:42Yury.Selivanovsetfiles: + pep362.4.patch

messages: + msg163133
2012-06-16 16:52:40eric.araujosetmessages: + msg162979
2012-06-15 18:04:35Yury.Selivanovsetfiles: + pep362.3.patch

messages: + msg162927
2012-06-14 02:29:37Yury.Selivanovsetfiles: + pep362.2.patch

messages: + msg162748
2012-06-06 03:47:00eric.araujosetkeywords: + needs review
title: PEP 362 reference implementation for 3.3 -> PEP 362 "Signature Objects" reference implementation
stage: patch review
2012-06-06 03:46:31eric.araujosetnosy: + eric.araujo
messages: + msg162393
2012-06-06 03:12:22Yury.Selivanovsetmessages: + msg162390
2012-06-06 03:01:26Ramchandra Aptesetnosy: + Ramchandra Apte
messages: + msg162388
2012-06-06 01:57:39Alexandre.Zanisetnosy: + Alexandre.Zani
2012-06-05 22:06:43Yury.Selivanovcreate