Skip to content

Commit a0bc50f

Browse files
committed
Infra: Automatically trim trailing commas & whitespace in header values
1 parent ebed4ce commit a0bc50f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pep_sphinx_extensions/pep_processor/transforms/pep_headers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ def apply(self) -> None:
102102
# Mark unneeded fields
103103
fields_to_remove.append(field)
104104

105+
# Remove any trailing commas and whitespace in the headers
106+
if para and isinstance(para[-1], nodes.Text):
107+
last_node = para[-1]
108+
if last_node.astext().strip() == ",":
109+
last_node.parent.remove(last_node)
110+
else:
111+
para[-1] = last_node.rstrip().rstrip(",")
112+
105113
# Remove unneeded fields
106114
for field in fields_to_remove:
107115
field.parent.remove(field)

0 commit comments

Comments
 (0)