These 2 errors of pylint are wrong (W0104)

Hello, please reply to my address too, I am not subscribed to the mailing list. Click "reply all" or add my address when you reply to this message. min.py:41:4: W0104: Statement seems to have no effect (pointless-statement) min.py:42:4: W0104: Statement seems to have no effect (pointless-statement) for the code # This is line 39 try: bd.executemany ( "INSERT INTO [...]", data ) print( "- [...]" ) con.commit() print( "- [...]" ) con.close() print( "- [...]" ) sys.exit( 0 ) print( "- after sys.exit(0)" ) except: print( "- exc!" ) print( sys.exc_info() ) con.close() sys.exit( 2 ) *pylint *is saying that lines 41 and 42 are pointless, which is obviously false. So, this is a bug in it. I do not want to write that call in only one line to make my code easier to be read and understood. What you think? Please reply to my address too, I am not subscribed to the mailing list. Click "reply all" or add my address when you reply to this message. Thank you

What if you use: bd.executemany( "INSERT INTO [...]", data ) ? On Sat, Jul 2, 2022 at 3:00 PM Dedeco Balaco via code-quality < code-quality@python.org> wrote:
Hello,
please reply to my address too, I am not subscribed to the mailing list. Click "reply all" or add my address when you reply to this message.
min.py:41:4: W0104: Statement seems to have no effect (pointless-statement) min.py:42:4: W0104: Statement seems to have no effect (pointless-statement)
for the code
# This is line 39 try: bd.executemany ( "INSERT INTO [...]", data ) print( "- [...]" ) con.commit() print( "- [...]" ) con.close() print( "- [...]" ) sys.exit( 0 ) print( "- after sys.exit(0)" ) except: print( "- exc!" ) print( sys.exc_info() ) con.close() sys.exit( 2 )
*pylint *is saying that lines 41 and 42 are pointless, which is obviously false. So, this is a bug in it. I do not want to write that call in only one line to make my code easier to be read and understood. What you think?
Please reply to my address too, I am not subscribed to the mailing list. Click "reply all" or add my address when you reply to this message.
Thank you _______________________________________________ code-quality mailing list -- code-quality@python.org To unsubscribe send an email to code-quality-leave@python.org https://mail.python.org/mailman3/lists/code-quality.python.org/ Member address: strombrg@gmail.com

Hi, On Sat, Jul 02, 2022 at 06:00:35PM -0300, Dedeco Balaco via code-quality wrote:
bd.executemany ( "INSERT INTO [...]", data )
This does not do what you think it does. Your bd.executemany function never gets called. Compare to e.g. print ( "Hello World", 42 ) which will also not print anything: It refers to the "print" function (but not calling it), and then creates a tuple. Your code does the exact same thing. This is a bug in your code, and pylint is correct that those statements are pointless as-is. Florian -- me@the-compiler.org | https://www.qutebrowser.org https://bruhin.software/ | https://github.com/sponsors/The-Compiler/ GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc I love long mails! | https://email.is-not-s.ms/
participants (3)
-
Dan Stromberg
-
Dedeco Balaco
-
Florian Bruhin