The open builtin can open files in different modes, which are provided as a combination of characters. Using an invalid sequence of
characters will at best make open fail, or worse, it will have an undefined behavior (ex: it might ignore some characters).
A valid mode:
This rule raises an issue when an invalid "mode" is provided to the open builtin.
# In python 3 the following fails
# In python 2.7.16 on MacOs, "open" will just ignore the "w" flag
with open("test.txt", "aw") as f: # Noncompliant
pass
with open("test.txt", "a") as f:
pass