@@ -241,5 +241,24 @@ info =
241241 " clean_dir = re . sub( r'[^a-zA-Z0-9]' , '' , dir_to_list )" ,
242242 " subprocess . run ( [ \"ls\" , \"-l\" , clean_dir ] )"
243243 ]
244- ]
244+ ] ,
245+ expected : [
246+ String . raw ` clean_dir = re.sub(r'[^a-zA-Z0-9]', '', dir_to_list)` ,
247+ String . raw ` subprocess.run(["ls", "-l", clean_dir])`
248+ ] ,
249+ // In Python, newline and carriage return are whitespace but are *meaningful*
250+ // outside of (...). So we match specifically on space (\x20) instead.
251+ // This makes our patterns harder to read, unfortunately.
252+ // It's conventional to use raw strings in Python for regexes, so we allow
253+ // and encourage them, but we'll accept *not* using raw strings since they
254+ // don't add value in this situation.
255+ correct : [
256+ String . raw `[\n\r]*\x20\x20clean_dir\x20*=\x20*re\x20*\.\x20*sub\x20*\(
257+ r?('\[\^a-zA-Z0-9\]'|"\[\^a-zA-Z0-9\]") ,
258+ r?(''|"") , dir_to_list \) \s*` ,
259+ String . raw `[\n\r]*\x20\x20subprocess\x20*\.\x20*run\x20*\(
260+ \[ ('ls'|"ls") , ('-l'|"-l") , clean_dir \]
261+ ( , shell = False )? \) \s*`
262+ ] ,
263+ debug : true ,
245264}
0 commit comments