makerdao / spells-mainnet

Staging repo for MakerDAO weekly executive spells
GNU Affero General Public License v3.0
107 stars 43 forks source link

Subprocess run with ignored non-zero exit #325

Open philipjonsen opened 1 year ago

philipjonsen commented 1 year ago

DESCRIPTION subprocess.run uses a default of check=False, which means that a nonzero exit code will be ignored by default, instead of raising an exception.

You can ignore this issue if this behaviour is intended.

BAD PRACTICE

Nonzero exit code will be ignored here

subprocess.run(['notify-send', '-u', 'critical', msg]) RECOMMENDED

Exception will be raised for nonzero exit code

subprocess.run(['notify-send', '-u', 'critical', msg], check=True) # some comment

Using subprocess.run without explicitly set check is not recommended.

scripts/verify.py

53 exit('contract name not found.') 54 55print('Obtaining chain... ') 56seth_chain = subprocess.run(['seth', 'chain'], capture_output=True) 57chain = seth_chain.stdout.decode('ascii').replace('\n', '') 58print(chain) 59

Using subprocess.run without explicitly set check is not recommended.

scripts/verify.py

74action = 'verifysourcecode' 75code_format = 'solidity-single-file' 76 77flatten = subprocess.run([ 78 'hevm', 79 'flatten', 80 '--source-file',

Using subprocess.run without explicitly set check is not recommended.

archive/2022-12-09-DssSpell/scripts/verify.py

74action = 'verifysourcecode' 75code_format = 'solidity-single-file' 76 77flatten = subprocess.run([ 78 'hevm', 79 'flatten', 80 '--source-file',

Using subprocess.run without explicitly set check is not recommended

archive/2022-12-09-DssSpell/scripts/verify.py

53 exit('contract name not found.') 54 55print('Obtaining chain... ') 56seth_chain = subprocess.run(['seth', 'chain'], capture_output=True) 57chain = seth_chain.stdout.decode('ascii').replace('\n', '') 58print(chain) 59

scripts/verify.py

53 exit('contract name not found.') 54 55print('Obtaining chain... ') 56seth_chain = subprocess.run(['seth', 'chain'], capture_output=True) 57chain = seth_chain.stdout.decode('ascii').replace('\n', '') 58print(chain) 59

Using subprocess.run without explicitly set check is not recommended. scripts/verify.py

74action = 'verifysourcecode' 75code_format = 'solidity-single-file' 76 77flatten = subprocess.run([ 78 'hevm', 79 'flatten', 80 '--source-file',