Skip to main content

blank_python

Function blank_python 

Source
pub fn blank_python(src: &str) -> String
Expand description

Blank comments and the insides of string literals in PYTHON source, preserving length and line count.

The shapes that earn their handling here:

  • # comments and the three quote forms: '…', "…", and the triples;
  • prefixes (r, b, f, u and their pairs) read from the word the tracker just saw, because f"{breakpoint()}" interpolates CODE: like the JS blanker’s ${…}, blanking it would hide a banned call — a missed warning, the direction this hook must never fail in. {{ is text, and interpolations nest (f"{f'{x}'}"), so open ones are a stack of the literals to resume, not a flag;
  • a backslash always blanks the next character, raw or not: in Python a raw string still cannot end on a lone backslash, so r"\"… staying open mirrors the real parser;
  • an unterminated single-line string bails back to code at the newline rather than blanking the rest of the file.