Skip to content

PEP 362 "Signature Objects" reference implementation #59213

Closed

Description

@YurySelivanov
BPO 15008
Nosy @brettcannon, @larryhastings, @benjaminp, @ezio-melotti, @merwok, @1st1
Files
  • pep362.1.patch
  • pep362.2.patch
  • pep362.3.patch
  • pep362.4.patch
  • pep362.5.patch
  • pep362.6.patch
  • pep362.7.patch
  • pep362.8.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-06-22.22:24:52.496>
    created_at = <Date 2012-06-05.22:06:43.097>
    labels = ['type-feature', 'library']
    title = 'PEP 362 "Signature Objects" reference implementation'
    updated_at = <Date 2012-07-25.23:22:48.938>
    user = 'https://bugs.python.org/YurySelivanov'

    bugs.python.org fields:

    activity = <Date 2012-07-25.23:22:48.938>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-06-22.22:24:52.496>
    closer = 'Yury.Selivanov'
    components = ['Library (Lib)']
    creation = <Date 2012-06-05.22:06:43.097>
    creator = 'Yury.Selivanov'
    dependencies = []
    files = ['25838', '26005', '26021', '26048', '26052', '26055', '26071', '26092']
    hgrepos = ['131']
    issue_num = 15008
    keywords = ['patch', 'needs review']
    message_count = 17.0
    messages = ['162377', '162388', '162390', '162393', '162748', '162927', '162979', '163133', '163134', '163197', '163202', '163203', '163352', '163477', '163500', '166431', '166440']
    nosy_count = 10.0
    nosy_names = ['brett.cannon', 'larry', 'benjamin.peterson', 'ezio.melotti', 'eric.araujo', 'Yury.Selivanov', 'python-dev', 'Alexandre.Zani', 'Ramchandra Apte', 'yselivanov']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15008'
    versions = ['Python 3.3']

    Activity

    1. YurySelivanov commented on Jun 5, 2012

      YurySelivanovmannequin
      MannequinAuthor

      This issue will track implementation of PEP-362 functionality.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Jun 5, 2012
    3. RamchandraApte commented on Jun 6, 2012

      RamchandraAptemannequin
      Mannequin

      Signature and signature are two variable names that differ only in case.
      To avoid confusion, I recommend one of the names should be changed.

    4. YurySelivanov commented on Jun 6, 2012

      YurySelivanovmannequin
      MannequinAuthor

      Well, 'Signature' class is unlikely to be used very frequently. So I think it's fine.

    5. merwok commented on Jun 6, 2012

      @merwok
      Member

      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.

    6. changed the title [-]PEP 362 reference implementation for 3.3[/-] [+]PEP 362 "Signature Objects" reference implementation[/+] on Jun 6, 2012
    7. YurySelivanov commented on Jun 14, 2012

      YurySelivanovmannequin
      MannequinAuthor

      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
    8. YurySelivanov commented on Jun 15, 2012

      YurySelivanovmannequin
      MannequinAuthor

      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()')
    9. merwok commented on Jun 16, 2012

      @merwok
      Member

      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.

    10. YurySelivanov commented on Jun 19, 2012

      YurySelivanovmannequin
      MannequinAuthor

      New version (PEP-363.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!

    11. YurySelivanov commented on Jun 19, 2012

      YurySelivanovmannequin
      MannequinAuthor

      Eric,

      I personally prefer simple 'signature()' more than 'get_signature()'. But I'll ask this question on python-dev on the next PEP update.

    12. YurySelivanov commented on Jun 19, 2012

      YurySelivanovmannequin
      MannequinAuthor

      New patch (PEP-362.5.patch)

      Fixed a bug in BoundArguments.args & BoundArguments.kwargs

    13. ezio-melotti commented on Jun 19, 2012

      @ezio-melotti
      Member

      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?

    14. YurySelivanov commented on Jun 19, 2012

      YurySelivanovmannequin
      MannequinAuthor

      New patch - PEP-362.6.patch

      Ezio,

      I've eliminated almost all '\'.
      Test coverage is now almost 100%.

    15. YurySelivanov commented on Jun 21, 2012

      YurySelivanovmannequin
      MannequinAuthor

      New patch - PEP-362.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!

    16. YurySelivanov commented on Jun 22, 2012

      YurySelivanovmannequin
      MannequinAuthor

      New patch - PEP-362.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.

    17. python-dev commented on Jun 22, 2012

      python-devmannequin
      Mannequin

      New changeset d892bf410478 by Larry Hastings in branch 'default':
      Issue bpo-15008: Implement PEP-362 "Signature Objects".
      http://hg.python.org/cpython/rev/d892bf410478

    18. benjaminp commented on Jul 25, 2012

      @benjaminp
      Contributor

      Are we going to get documentation?

    19. 1st1 commented on Jul 25, 2012

      @1st1
      Member
    20. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions