#StackBounty: #python #autocomplete #attributes Is it possible to have Python IDEs offer autocompletion for dynamically generated class…

Bounty: 200

Are there any tricks I can employ to get IDEs to offer code completion for dynamically generated class attributes? For instance


class A:
    
    def __init__(self):
        setattr(self, "a", 5)

This code will set the class attribute of A called a to the value of 5. But IDEs do not know about a and therefore you do not get code completion for it. I’ve read that the __dir__ method can be hooked, but the suggestion made in that answer has not worked for me. Does anybody have any ideas?


Get this bounty!!!

#StackBounty: #python #python-3.x #machine-learning #autocomplete #artificial-intelligence Is there a way to reset Kite Autocomplete&#3…

Bounty: 50

I’m wondering if I can reset the training of Kite’s AI that uses my code. I want to do this because I want to change my code style and there is some stuff that I quit doing.

Take xrange for example; it’s deprecated in python3 (I’m a python coder). So, I want to reset all of the data it learned from me as if I just got it again. I don’t want to uninstall and reinstall it.

Is uninstalling the Sublime Text/Atom plugins and reinstalling them would do the trick? Or is it not possible?

And for the specs, I got a MacOS Catalina (10.15.5 (19F96)), non-pro and no account for Kite, and Kite version 0.20200609.2.

I really want to know if there’s an official way, not some file removing magic.

But if some file removing magic is necessary, then I’m fine.

Also, I wonder if just removing and reinstalling the plugins for editors would do the trick…


Someone set a bounty on this; I don’t wanna.


Get this bounty!!!

#StackBounty: #zsh #autocomplete #tab-completion #globbing How do I get zsh tab completion to "vi **/foo<TAB>" to match…

Bounty: 150

How do I get zsh tab completion to cat **/foo<TAB> to match and complete the first file matching foo* in any subdirectory under the current directory?

For example, do this while inside a fresh test directory: (again, this is zsh)

% mkdir aaa bbb ccc
% touch aaa/foo bbb/foo ccc/foo
% cat **/f<TAB>

What I want when I hit <TAB> on that last line is for my screen to end up looking like this:

% cat aaa/foo_                 # filled in the first match; "_" is the cursor
aaa/foo  bbb/foo  ccc/foo      # and here is the list of all matches

I tried setopt GLOB_COMPLETE, but that didn’t do what I wanted.


Get this bounty!!!

#StackBounty: #django #autocomplete Autocomplete does nothing. What is wrong?

Bounty: 50

I have autocomplete code which does not work.

I have input field class Coordinate where when i type code it finds value from my DB that matches with geo_code and hence finds the input code country.

So when i type UK it matches with geo_code and then matches the last with the country so in this case UK is code i type it can be found in geo_code and country is United Kingdom. The code works, what i want to achieve is bring autocomplete to give suggestions while typing:

for examples: when i type U the field to bring suggestions in this format:

UK   United Kingdom
USA  United States of America

What i did so far:

In models.py i have:

class Coordinate(models.Model):
    code = models.CharField(max_length=150)

class Profiles(models.Model):
    geocode=models.CharField(max_length=200)
    country=models.CharField(max_length=500)

    class Meta:
        managed=False
        db_table='profiles_country'

    def __str__(self):
        return '{}'.format(self.geocode)

in forms.py:

from dal import autocomplete

class CoordinateForm(forms.ModelForm):
    code= forms.CharField(max_length=150, label='',widget= forms.TextInput)

    class Meta:
        model = Coordinate
        fields = ('__all__')
        widgets = {
            'code': autocomplete.ModelSelect2(url='coordinate-autocomplete',
            attrs={ 'theme': 'bootstrap'})}

    def clean_code(self):
            code=self.cleaned_data.get("code")
            if not Profiles.objects.filter(geocode=code).exists():
                raise forms.ValidationError ( "Not true")
            return code

in views.py:

from dal import autocomplete

def geoview(request):
    form = CoordinateForm(request.POST or None)
    if request.method == "POST":
        if form.is_valid():
            form1 = form.save(commit=False)
            code = form1.code
            dataview=Profiles.objects.get(geocode=code)

            context={'geodata':dataview ,}

            return render(request, 'cgeo/result.html', context)

    return render(request, 'cgeo/search.html', context={'form':form})


class CoordinateAutocomplete(autocomplete.Select2QuerySetView):
        def get_queryset(self):
            if not self.request.user.is_authenticated():
                return Profiles.objects.none()
            qs = Profiles.objects.all()
            if self.q:
                qs = qs.filter(name__istartswith=self.q)
            return qs

in main urls.py:

urlpatterns = [
    path('admin/', admin.site.urls),
    path('geo/', geoview, name='geo'),
    path('coordinate-autocomplete/', CoordinateAutocomplete.as_view(create_field='name'), name='coordinate-autocomplete'),]

in base.html

<!DOCTYPE html>
{% load static %}

<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">

    <link rel="stylesheet" href="{% static 'geoproj/css/main.css' %}">

  </head>
  <body>

    <div>{% block content %}{% endblock  %} 

         {% block javascripts %} {% endblock %} </div>

  </body>
</html>

in geo.html :

{% extends "base.html" %}
{% block content %}

{% if user.is_authenticated %}
            <form enctype="multipart/form-data" method="POST" >
                    {% csrf_token %}
                    {{ form}}
                    {{form.media }}
            <button class = "btn btn-primary" type="submit">OK</button></form>


{% endif %}

{% endblock content %}

{% block javascripts %} {% endblock %}

I don’t know where exactly is the problem. What excat js links to put as different sources put different links of js and still does not work for me.

I would appreciate you help to solve this case.


Get this bounty!!!

#StackBounty: #linux #ubuntu #autocomplete TextSuggest autocomplete error on Ubuntu 18.04.3

Bounty: 50

I’m having an issue with TextSuggest – an automcomplete tool for Linux. It only works once, after that the shortcut doesn’t open the autocomplete popup anymore. (nothing happens at all)

  • My Shortcut: SHIFT+CTRL+P
  • OS: Ubuntu 18.04.3 LTS.
  • I added textsuggest-server in the background to run on startup

Error message after I select a word from the TextSuggest menu and press enter:

    go@tom:~/Desktop/TextSuggest-Pkg$ textsuggest-server
Started server at org.textsuggest.server, PID: 7678…
time get_all_words([English, English]) = 0.001719
Processing 'previous'
    Using processor 'command' from '/usr/share/textsuggest/processors/command'
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 18446744073709551615) > this->size() (which is 0)
/usr/bin/textsuggest-server: line 3:  7678 Aborted                 (core dumped) LD_LIBRARY_PATH=/usr/share/textsuggest/libs /usr/share/textsuggest/textsuggest-server "$@"

error 2:
Started server at org.textsuggest.server, PID: 7811…
time get_all_words([English, English]) = 0.00155287
time get_all_words([English, English]) = 0.00150532
Processing 'previous'
    Using processor 'command' from '/usr/share/textsuggest/processors/command'
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 18446744073709551615) > this->size() (which is 0)
/usr/bin/textsuggest-server: line 3:  7811 Aborted                 (core dumped) LD_LIBRARY_PATH=/usr/share/textsuggest/libs /usr/share/textsuggest/textsuggest-server "$@"

Any ideas what could be the issue?


Get this bounty!!!

#StackBounty: #web-apps #collaboration #productivity #machine-learning #autocomplete Trainable Predictive Typing with Phrase suggestion…

Bounty: 50

I would like to find a program that suggests phrases that are commonly used by our business as the user starts typing them, similar to Gmail’s “Smart Compose” feature.

This could be an installed program that suggests phrases in any text input field (sort of like iOS’s keyboard, except for phrases instead of single words, and for MS Windows), or a web app where the person composes the report on a web page, then copies it to the appropriate place.

Background

  • Our business writes reports, all day, every day. We have about 500 people writing these reports.
  • The reports have a specific structure. Each paragraph has a specific thing it is supposed to report about.
  • Paragraphs are usually 1-2 sentences long.
  • The entire report is typically a half page long, but could be as long as three pages.
  • The reports are plain text. The formatting is handled by our inventory management system.

Requirements

  • The program can be trained using the text from our half million existing reports.
  • The program continues to learn from the reports we write and the phrases users are likely to accept.
  • The program’s learning takes place on a company-wide level, not at the user level, so predictive typing improves for everyone. This probably means a web app or server-side software.
  • The program has a interface where management can block phrases they want to stop appearing in reports.
  • The program has a built-in feedback tool that lets users hit a key to flag bad phrases to make them stop showing up. The bad phrases stop showing up for that user, and are reported to management for review.
  • The program can be operated exclusively using the keyboard. No need to touch the mouse.
  • Cost: maybe $2500 for a perpetual, company-wide license? I might be able to get approval for more if it’s something really phenomenal.

What I have looked at

  • Most of our users keep a separate document with commonly-used phrases they can copy and paste into their report, changing just a word or two as needed. The software you recommend would make this practice obsolete.
  • One person started using PhraseExpress a few years ago and loved it, so we recommended it to everyone, but so far I only know of three people (out of 500) who have started using it. It seems the learning curve is too steep (80% of our associates are independent contractors, so we can only suggest they use the software, not require it). It’s really more of a clipboard manager than predictive typing software. It requires the user to manage their own phrases and type abbreviations to insert a phrase, rather than suggesting phrases based on context and previous usage. I expect that something that adds on to what the user is already doing would have a much higher adoption rate.
  • Lightkey sounds good, but it sounds like its “collective wisdom” feature is a new feature that’s not mature yet. It’s not clear if it has a management interface or not. It’s a bit out of budget, but I could probably get approval for it if it strongly meets our requirements.
  • Typing Assistant and FastKeys seem to be for a single user, not an organization. They don’t seem to have a way to share their learning.
  • Other programs I looked at only suggested a single word, instead of suggesting whole phrases.

Related questions

Predictive text for personal use

These questions are about predictive text for a single user, not for company-wide predictive text.

Sharing report formatting company-wide

This question is about sharing formatting for reports, not about sharing phrases used in reports.


Get this bounty!!!

#StackBounty: #zsh #autocomplete zsh _arguments completion that gradually reveals options

Bounty: 50

I have at the moment a completion function that looks something like this (except way more entries)

_arguments 
  '-check[do a check]' 
  '-play[play a specific song]:songnumber' 
  '-test.n=[run test specified number of times]:n' 
  '-test.dir=[run test in a specific working dir]:dir: _path_files -/' 
  '-test.v[run tests verbose]' 
  '-log[delete all log files]' 
  '*:inputfiles: _files'

upon tabbing this leads to printout like that:

pseyfert@robusta:~ > program -⇥
option:
-check     -- do a check
-log       -- delete all log files
-play      -- play a specific song
-test.dir  -- run test in a specific working dir
-test.n    -- run test specified number of times
-test.v    -- run tests verbose

One pattern is that a considerable number of options starts with -test. and I am often not interested in them, so when looking for an option that I don’t know by heart, the entire -test. block is somewhat spam. I’d prefer to group the options to a printout like that:

pseyfert@robusta:~ > program -⇥
option:
-check     -- do a check
-log       -- delete all log files
-play      -- play a specific song
-test.     -- test options

and then when reaching -test. reveal what’s behind:

pseyfert@robusta:~ > program -test.⇥
option:
-test.dir  -- run test in a specific working dir
-test.n    -- run test specified number of times
-test.v    -- run tests verbose

I realized I can get in the right direction with a minus after the option

_arguments 
  '-check[do a check]' 
  '-play[play a specific song]:songnumber' 
  '-log[delete all log files]' 
  '-test.-[test options]:testopts: _testopts' 
  '*:inputfiles: _files'

such that no space gets added after -test. and a space will not be interpreted as “option continues”. What I lack in my repertoire is the _testopts function. I’m tempted to use _arguments again, but that requires leading - after the -test.. With _values I am not aware of a method to place the descriptions and don’t know how to continue into other functions like _path_files -/ above.

Are there any examples for gradual option revealing or hints how to best change the design of my completion?


Get this bounty!!!

#StackBounty: #ubuntu #zsh #git #autocomplete #oh-my-zsh How to use zsh tab completion on Git without origin?

Bounty: 50

I am using zsh with oh-my-zsh on Ubuntu 18.04.2. Currently, Git is installed at version 2.20.1.

Whenever I want to push a local branch to a remote (origin) I try to use the tab completion in the shell as follows:

git push origin fea<TAB>

The tab completion results in:

git push origin origin/feature

I cannot push to origin/feature, though. What I actually want is:

git push origin feature

The same applies to git checkout.

How can I configure the tab completion to correctly (?) complete the remote branch – or am I missing something?


Get this bounty!!!

#StackBounty: #bash #autocomplete #complete Escape slashes in bash complete

Bounty: 250

I try to use the bash complete builtin to show different options for a command.

I have problems when an option contains a path like in -F/dev/null.

Currently I’m using

#!/bin/bash

_xyz-completion ()
{
  local cur

  COMPREPLY=()   # Array variable storing the possible completions.
  cur=${COMP_WORDS[COMP_CWORD]}

  case "$cur" in
    -*)
    COMPREPLY=( $( compgen -W "-oOption1 -F/dev/null" -- $cur ) )
    ;;
  esac

  return 0
}

complete -F _xyz-completion -o filenames xyz

If -F was already typed, then a Tab completes it successfully.

But if only - was typed, then a Tab shows

null       -oOption1

But I expect to see

-F/dev/null       -oOption1

I tried already -F/dev/null, -F//dev//null, "-F/dev/null" and -F\/dev\/null

It seems to be only a display problem, as the completion itself works as expected.

I can’t see how to appropriate escape the slashes in `-F/dev/null`.


To comment the comments:

1)

Never mind, it’s a problem also if -F is replaced by a non-option such as -Q. – Benjamin W.

It’s not a problem, that the -F looks like a option for complete itself, as it even fails if I changed it to xOPTION1 xF/dev/null

2)

I’m wondering what compgen -W “-oOption1 -F/dev/null” — – displays for you.

It displays (as expected)

-oOption1
-F/dev/null

As mentioned, -F completes successfully to -F/dev/null


Get this bounty!!!