Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clinic: use raw types in types= set #68189

Closed
larryhastings opened this issue Apr 19, 2015 · 11 comments
Closed

Clinic: use raw types in types= set #68189

larryhastings opened this issue Apr 19, 2015 · 11 comments
Assignees
Labels
topic-argument-clinic type-feature A feature request or enhancement

Comments

@larryhastings
Copy link
Contributor

BPO 24001
Nosy @larryhastings, @zware, @serhiy-storchaka
Files
  • larry.clinic.use.raw.types.1.txt
  • larry.clinic.use.raw.types.2.txt
  • larry.clinic.use.raw.types.3.txt
  • 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 = 'https://github.com/larryhastings'
    closed_at = <Date 2015-05-04.15:04:21.025>
    created_at = <Date 2015-04-19.01:06:17.176>
    labels = ['type-feature', 'expert-argument-clinic']
    title = 'Clinic: use raw types in types= set'
    updated_at = <Date 2015-05-04.15:04:21.024>
    user = 'https://github.com/larryhastings'

    bugs.python.org fields:

    activity = <Date 2015-05-04.15:04:21.024>
    actor = 'larry'
    assignee = 'larry'
    closed = True
    closed_date = <Date 2015-05-04.15:04:21.025>
    closer = 'larry'
    components = ['Argument Clinic']
    creation = <Date 2015-04-19.01:06:17.176>
    creator = 'larry'
    dependencies = []
    files = ['39114', '39128', '39145']
    hgrepos = []
    issue_num = 24001
    keywords = []
    message_count = 11.0
    messages = ['241469', '241476', '241479', '241481', '241532', '241535', '241552', '241553', '241671', '241689', '242558']
    nosy_count = 4.0
    nosy_names = ['larry', 'python-dev', 'zach.ware', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue24001'
    versions = []

    @larryhastings
    Copy link
    Contributor Author

    New proposed semantics for the types= parameter to converters: where possible, pass in actual types. The resulting syntax:

    c: int(types={str}) # maps to 'U'
    s: str(types={str, robuffer}, length=True, zeroes=True) # maps to 's#'

    Since "buffer", "robuffer", and "rwbuffer" are fake pseudotypes, I created empty classes with those names.

    Serhiy: with this change in place, the types= parameter uses almost the same number of characters as it used to when it was a string. (The new syntax requires commas between elements, so for two or more types it's slightly longer.) Yet this makes the types= parameter far more accurate in illustrating what it's supposed to represent.

    Does this make you happy? :)

    @larryhastings larryhastings self-assigned this Apr 19, 2015
    @larryhastings larryhastings added topic-argument-clinic type-feature A feature request or enhancement labels Apr 19, 2015
    @larryhastings
    Copy link
    Contributor Author

    Should types= be renamed accept= ? It's a set of the types of the Python objects that this parameter should accept.

    @larryhastings
    Copy link
    Contributor Author

    I should mention that evalify_node() is pretty hacked up here, and is not ready to be checked in. (I'm proposing separately that we simply add something like this directly into the standard library, see issue bpo-24002.)

    @serhiy-storchaka
    Copy link
    Member

    accept= (or accept_types=) LGTM.

    @larryhastings
    Copy link
    Contributor Author

    Thanks to bpo-24002 I now know how to write evalify_node properly. This revision of the patch is much better, and maybe ready for checkin.

    @serhiy-storchaka
    Copy link
    Member

    Looks as this is a patch for different issue.

    @larryhastings
    Copy link
    Contributor Author

    Whoops. I'll fix that.

    @larryhastings
    Copy link
    Contributor Author

    Here's the right patch.

    @larryhastings
    Copy link
    Contributor Author

    Attached is a patch implementing all my proposed changes here:

    • "types" is now renamed "accept"
    • it accepts a set of real Python types
    • there are placeholder types for buffer, robuffer, rwbuffer
    • "nullable=True" is gone, replaced with adding NoneType to accept={}

    @serhiy-storchaka
    Copy link
    Member

    Usually converters are named by the C type of the result. May be rename the "str" converter to "pchar"?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 4, 2015

    New changeset 41fb7fd04b5d by Larry Hastings in branch 'default':
    Issue bpo-24001: Argument Clinic converters now use accept={type}
    https://hg.python.org/cpython/rev/41fb7fd04b5d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-argument-clinic type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants