ref: DanielStutzbach/blist#90
blist is used for its sortedlist in ruletypes.py and appears to be abandonware - might I suggest that the SortedKeyList [0] from python-sortedcontainers [1] could replace it?
[0] http://www.grantjenks.com/docs/sortedcontainers/introduction.html#sorted-key-list
[1] https://github.com/grantjenks/python-sortedcontainers
It seems that the operation is guaranteed up to 3.6. Therefore, it seems that the operation of 3.9 is not guaranteed.
It's just a personal impression, but I think it's better to change to another library than to continue using blist.
Are you planning to make a pull request to change blist to python-sorted containers?
File to change
requirements.txt
setup.py
elastalert/ruletypes.py
ElastAlert shouldn't officially support Python 3.8 as it starts with Syntax Warning from Python 3.8.
SyntaxWarning: "is" with a literal. Did you mean "=="?
_Files that may need to be modified_
elastalert/
 __init__.py
 alerts.py
 create_index.py
 elastalert.py
 kibana_discover.py
 loaders.py
 opsgenie.py
 ruletypes.py
 test_rule.py
 util.py
tests/
 base_test.py
 elasticsearch_test.py
 kibana_discover_test.py
 loaders_test.py
 rules_test.py
 util_test.py
SyntaxWarning: "is not" with a literal. Did you mean "!="?
_Files that may need to be modified_
elastalert/
 alerts.py
 config.py
 create_index.py
 elastalert.py
 opsgenie.py
 ruletypes.py
 util.py
If you want to upgrade Python version, you may need to update the following files used by Travis CI
Need to add tests in Python 3.7 / 3.8 / 3.9 environment?
Dockerfile-test
travis.yml
@nsano-rururu - I can make a PR when i get some time for the replacement of blist. It won't be today but perhaps over the weekend.
wrt those syntaxwarnings, I had a quick grep though the source myself and it appears that most of those are checks against None, which seems like a bad warning rather than an actual syntax/logical issue. What did you use to get those warnings out? I can't replicate them with -Wdefault in a simple test file.
$ python -Wd <<EOF
foo = None
if foo is None:
pass
if foo is not None:
pass
if foo:
pass
if not foo:
pass
if foo == None:
pass
if foo != None:
pass
EOF
$ python -Wd <<EOF
foo = tuple()
if foo is ():
pass
if foo is not ():
pass
if foo:
pass
if not foo:
pass
if foo == ():
pass
if foo != ():
pass
EOF
<stdin>:2: SyntaxWarning: "is" with a literal. Did you mean "=="?
<stdin>:4: SyntaxWarning: "is not" with a literal. Did you mean "!="?
Those warnings for a literal tuple look right to me, and as I would expect using is against None is fine.
Then what about the situation?
I've not had the time to put up changes for this unfortunately. For the moment I've worked around the issue by pinning my container images to build from a python:3.8 base image. I've got a few higher priority things to get out of the way before I dig into this - happy for someone else to put up a PR in the meantime if it's affecting them as well.
I also had issues with blist with python 3.7. sortedcontainers worked well for me as per https://github.com/Yelp/elastalert/issues/2693
elastalert/ruletypes.py
from blist import sortedlist
 ↓
from sortedcontainers import SortedKeyList as sortedlist
requirements.txt
blist>=1.3.6
 ↓
sortedcontainers>=2.2.2
setup.py
'blist>=1.3.6'
 ↓
'sortedcontainers>=2.2.2'