is_literal_block needs a prompt, an indented line, or every line matching one of the code shapes. A block of Python that is flush left, one or two lines long, and made of call syntax rather than assignment or import matches none of the three, so it comes out as prose.
Found by L01 and L02, which flag these as untranslated English when they are code that was correctly copied:
| File |
msgid |
tutorial/controlflow.po:873 |
case (Point(x1, y1), Point(x2, y2) as p2): ... |
tutorial/controlflow.po:1812 |
def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2): |
tutorial/controlflow.po:1349 |
parrot(1000) and five more calls, each with a trailing comment |
tutorial/controlflow.po:1373 |
parrot() and three more, each with a trailing comment |
whatsnew/3.10.po:1084 |
case (Point(x1, y1), Point(x2, y2) as p2): ... |
_TIGHT rejects parrot(1000) # 1 positional argument because the trailing comment puts spaces outside a comma, which is the rule that separates sorted(d.keys()) from (Contributed by Eddie Elizondo in :issue:35810.) and is worth keeping. def f(...) and case (...) are not calls at all, so nothing looks at them.
Two shapes would cover every one of these:
Both are whole-line anchors and both have to be measured against the corpus before landing, the same way the rules already there were. The risk is the one the module docstring names: a paragraph mistaken for code is an English sentence left in a Vietnamese page, and if and for are also English words.
Seven of the nine L01 findings and six of the 144 L02 findings go away when this lands. The remaining L01 entries are the three copyright lines, which are a policy question rather than a classifier one.
is_literal_blockneeds a prompt, an indented line, or every line matching one of the code shapes. A block of Python that is flush left, one or two lines long, and made of call syntax rather than assignment or import matches none of the three, so it comes out as prose.Found by
L01andL02, which flag these as untranslated English when they are code that was correctly copied:tutorial/controlflow.po:873case (Point(x1, y1), Point(x2, y2) as p2): ...tutorial/controlflow.po:1812def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):tutorial/controlflow.po:1349parrot(1000)and five more calls, each with a trailing commenttutorial/controlflow.po:1373parrot()and three more, each with a trailing commentwhatsnew/3.10.po:1084case (Point(x1, y1), Point(x2, y2) as p2): ..._TIGHTrejectsparrot(1000) # 1 positional argumentbecause the trailing comment puts spaces outside a comma, which is the rule that separatessorted(d.keys())from(Contributed by Eddie Elizondo in :issue:35810.)and is worth keeping.def f(...)andcase (...)are not calls at all, so nothing looks at them.Two shapes would cover every one of these:
def,class,case,match,if,for,while,with,tryfollowed by a space and ending in a colon or a colon and an ellipsis.#comment on a line that is otherwise code, by testing the part before the#against the existing rules rather than the whole line.Both are whole-line anchors and both have to be measured against the corpus before landing, the same way the rules already there were. The risk is the one the module docstring names: a paragraph mistaken for code is an English sentence left in a Vietnamese page, and
ifandforare also English words.Seven of the nine
L01findings and six of the 144L02findings go away when this lands. The remainingL01entries are the three copyright lines, which are a policy question rather than a classifier one.