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

Smarter rl complete: hide private and special names #69199

serhiy-storchaka opened this issue Sep 5, 2015 · 6 comments

Smarter rl complete: hide private and special names #69199

serhiy-storchaka opened this issue Sep 5, 2015 · 6 comments
stdlib Python modules in the Lib dir type-feature A feature request or enhancement


Copy link

BPO 25011
Nosy @Yhg1s, @pitrou, @bitdancer, @serhiy-storchaka
  • rlcomplete_filter_private.patch
  • rlcomplete_filter_private_2.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 = ''
    closed_at = <Date 2015-09-27.10:48:14.186>
    created_at = <Date 2015-09-05.21:29:27.603>
    labels = ['type-feature', 'library']
    title = 'Smarter rl complete: hide private and special names'
    updated_at = <Date 2015-09-27.16:04:05.447>
    user = '' fields:

    activity = <Date 2015-09-27.16:04:05.447>
    actor = 'berker.peksag'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-09-27.10:48:14.186>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-09-05.21:29:27.603>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['40377', '40399']
    hgrepos = []
    issue_num = 25011
    keywords = ['patch']
    message_count = 6.0
    messages = ['249928', '250025', '250134', '250147', '251064', '251699']
    nosy_count = 5.0
    nosy_names = ['twouters', 'pitrou', 'r.david.murray', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = ''
    versions = ['Python 3.6']

    Copy link
    Member Author

    When press tabulation just after the dot, the output is too long. It contains all attributes, most of them are dunder names.

    >>> int.
    int.__abs__(            int.__doc__             int.__int__(            int.__pos__(            int.__round__(          int.__truediv__(
    int.__add__(            int.__eq__(             int.__invert__(         int.__pow__(            int.__rpow__(           int.__trunc__(
    int.__and__(            int.__flags__           int.__itemsize__        int.__prepare__(        int.__rrshift__(        int.__weakrefoffset__
    int.__base__(           int.__float__(          int.__le__(             int.__qualname__        int.__rshift__(         int.__xor__(
    int.__bases__           int.__floor__(          int.__lshift__(         int.__radd__(           int.__rsub__(           int.bit_length(
    int.__basicsize__       int.__floordiv__(       int.__lt__(             int.__rand__(           int.__rtruediv__(       int.conjugate(
    int.__bool__(           int.__format__(         int.__mod__(            int.__rdivmod__(        int.__rxor__(           int.denominator
    int.__call__(           int.__ge__(             int.__module__          int.__reduce__(         int.__setattr__(        int.from_bytes(
    int.__ceil__(           int.__getattribute__(   int.__mro__             int.__reduce_ex__(      int.__sizeof__(         int.imag
    int.__class__(          int.__getnewargs__(     int.__mul__(            int.__repr__(           int.__str__(            int.mro(
    int.__delattr__(        int.__gt__(             int.__name__            int.__rfloordiv__(      int.__sub__(            int.numerator
    int.__dict__            int.__hash__(           int.__ne__(             int.__rlshift__(        int.__subclasscheck__(  int.real
    int.__dictoffset__      int.__index__(          int.__neg__(            int.__rmod__(           int.__subclasses__(     int.to_bytes(
    int.__dir__(            int.__init__(           int.__new__(            int.__rmul__(           int.__subclasshook__(   
    int.__divmod__(         int.__instancecheck__(  int.__or__(             int.__ror__(            int.__text_signature__  

    Proposed patch hides underscored names and show dunder names only if a prefix starts with '__', and private members only if a prefix starts with '_'.

    >>> int.
    int.bit_length(  int.conjugate(   int.denominator  int.from_bytes(  int.imag         int.mro(         int.numerator    int.real         int.to_bytes(
    >>> int.__
    int.__abs__(            int.__divmod__(         int.__init__(           int.__neg__(            int.__rlshift__(        int.__sub__(
    int.__add__(            int.__doc__             int.__instancecheck__(  int.__new__(            int.__rmod__(           int.__subclasscheck__(
    int.__and__(            int.__eq__(             int.__int__(            int.__or__(             int.__rmul__(           int.__subclasses__(
    int.__base__(           int.__flags__           int.__invert__(         int.__pos__(            int.__ror__(            int.__subclasshook__(
    int.__bases__           int.__float__(          int.__itemsize__        int.__pow__(            int.__round__(          int.__text_signature__
    int.__basicsize__       int.__floor__(          int.__le__(             int.__prepare__(        int.__rpow__(           int.__truediv__(
    int.__bool__(           int.__floordiv__(       int.__lshift__(         int.__qualname__        int.__rrshift__(        int.__trunc__(
    int.__call__(           int.__format__(         int.__lt__(             int.__radd__(           int.__rshift__(         int.__weakrefoffset__
    int.__ceil__(           int.__ge__(             int.__mod__(            int.__rand__(           int.__rsub__(           int.__xor__(
    int.__class__(          int.__getattribute__(   int.__module__          int.__rdivmod__(        int.__rtruediv__(       
    int.__delattr__(        int.__getnewargs__(     int.__mro__             int.__reduce__(         int.__rxor__(           
    int.__dict__            int.__gt__(             int.__mul__(            int.__reduce_ex__(      int.__setattr__(        
    int.__dictoffset__      int.__hash__(           int.__name__            int.__repr__(           int.__sizeof__(         
    int.__dir__(            int.__index__(          int.__ne__(             int.__rfloordiv__(      int.__str__(            

    (The completion of int._ returns nothing because int has no private members).

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Sep 5, 2015
    Copy link

    pitrou commented Sep 6, 2015

    I like the idea, though some people may object to breaking their worflow (tm). Nosy'ing David just in case ;-)

    Copy link

    Sounds good to me, especially the __ part.

    I don't actually use completions, though :)

    Copy link
    Member Author

    Here is improved patch. The completion of empty prefix now returns the list of private names if there are no public names. The completion of empty prefix or prefix '_' now returns the list of dunder names if there are no non-dunder names. For example try "None.".

    In addition attr_matches() no longer returns duplicated names.

    Copy link
    Member Author

    If no one has objections, I'll commit the patch.

    @serhiy-storchaka serhiy-storchaka self-assigned this Sep 19, 2015
    Copy link

    python-dev mannequin commented Sep 27, 2015

    New changeset 4dbb315fe667 by Serhiy Storchaka in branch 'default':
    Issue bpo-25011: rlcomplete now omits private and special attribute names unless

    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    None yet

    No branches or pull requests

    3 participants