Why is AutocompleteInput `min_characters` restricted to only positive integers (>0)?

My usage of AutocompleteInput is to suggest single charachter completions for csv_separators (e.g. ,, ;, t). I’d like to set min_characters=0.
I get
ValueError: failed to validate AutocompleteInput(id='2174', ...).min_characters: expected positive integer, got 0.
(panel v0.12.5)

Suprisingly the limitation is not existing in the documentation: AutocompleteInput — Panel 0.12.6 documentation. Any idea why it works here or why it shouldn’t in the main code?
Thanks!

The error you get comes from Bokeh directly and indeed this widget comes from the Bokeh library where min_characters is an option that accepts positive integers only.

min_characters sets the minimum number of characters after which autocomplete is triggered and viewed. With a value of 0 autocomplete would be triggered when the widget is active (click on the input area) which sorts of defeat the purpose of having an autocomplete option.

Why don’t you use a Select widget instead of an AutocompleteInput?

As for the Panel documentation, it’s written manually and so doesn’t always reflect the state of the source code. It’d be great if one day we could find a way to improve that by generating it automatically and having it nicely rendered :slight_smile: In the mean time pull requests are more than welcomed to improve the documentation!

Thanks for your reply.
Select is not applicable for me, as I really require the input to be whatever (e.g. csv_separator) value needed. The autocompletion is a very nice feature since it gives valid suggestions and thus also works as built-in documentation :slight_smile:.
I agree that setting min_characters to zero, makes it look like a Select widget, with fixed options although it isn’t, so yes, that’s a drawback.

The funny thing with the documentation is, that the gui there actually accepts and works with min_charachters=0: check the Controls section below. I’m guessing it’s using a different panel version?

Anyway, I guess I’ll have to suggest changing the PositiveInt on the Bokeh side then. Thanks.

Yes sure you could open an issue on Bokeh’s Github to see what they think about allowing min_characters to be set to 0!

Yes you’re right the GUI that’s automatically generated from the controls method allows to set any integer since this is how min_characters is defined on Panel’s side:

    min_characters = param.Integer(default=2, doc="""
        The number of characters a user must type before
        completions are presented.""")

We should add bounds to this parameter.

If I get it correctly what you want is to use autocompletion to suggest a subset of CSV separators but your users are allowed to provide a separator that isn’t part of your suggestions. In that case you could use a TextInput with a max_length of 1 and suggest potential options in the placeholder.