jurismarches / luqum

A lucene query parser generating ElasticSearch queries and more !
Other
188 stars 40 forks source link

Stop using print in code #57

Closed impredicative closed 4 years ago

impredicative commented 4 years ago

print should not be used in production code as below. It is unprofessional.

https://github.com/jurismarches/luqum/blob/55c9cdc29ffaf0ea387dfc8a0c61161f19af71b3/luqum/parser.py#L181-L184

An exception can be raised.

There isn't even a good reason to silently skip certain characters, e.g. forward slash. Why can't it be processed? It should be a valid character.

alexgarel commented 4 years ago

Hi @impredicative you're perfectly right about that the fact that it should not be a print, in fact there is a FIXME above.

At the time it was not implemented because a way to handle errors like this was to be thought. This kind of detail is the reason why luqum is not "1.0" yet.

Please feel free to propose what to do instead of the print ! (shall we raise ?).

There isn't even a good reason to silently skip certain characters, e.g. forward slash. Why can't it be processed? It should be a valid character.

You're welcome to submit a new bug with the expression that produce the error. We will keep this ticket for print removal.

impredicative commented 4 years ago

Personally I might raise an IllegalCharacterException(InconsistentQueryException) exception from exceptions.py, but the developers of this package would know better.