Skip to content

Commit a6fbf5d

Browse files
pwilkinCISC
andauthored
Apply suggestions from code review
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
1 parent 3225d17 commit a6fbf5d

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

scripts/jinja/jinja-tester.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ def highlight_current_line(self):
242242
if not self.isReadOnly():
243243
selection = QTextEdit.ExtraSelection()
244244
line_color = QColorConstants.Yellow.lighter(160)
245-
selection.format.setBackground(line_color) # type: ignore
246-
selection.format.setProperty(QTextFormat.Property.FullWidthSelection, True) # type: ignore
247-
selection.cursor = self.textCursor() # type: ignore
248-
selection.cursor.clearSelection() # type: ignore
245+
selection.format.setBackground(line_color) # pyright: ignore[reportAttributeAccessIssue]
246+
selection.format.setProperty(QTextFormat.Property.FullWidthSelection, True) # pyright: ignore[reportAttributeAccessIssue]
247+
selection.cursor = self.textCursor() # pyright: ignore[reportAttributeAccessIssue]
248+
selection.cursor.clearSelection() # pyright: ignore[reportAttributeAccessIssue]
249249
extra_selections.append(selection)
250250
self.setExtraSelections(extra_selections)
251251

@@ -263,8 +263,8 @@ def highlight_position(self, lineno: int, col: int, color: QColor):
263263
)
264264

265265
extra = QTextEdit.ExtraSelection()
266-
extra.format.setBackground(color.lighter(160)) # type: ignore
267-
extra.cursor = cursor # type: ignore
266+
extra.format.setBackground(color.lighter(160)) # pyright: ignore[reportAttributeAccessIssue]
267+
extra.cursor = cursor # pyright: ignore[reportAttributeAccessIssue]
268268

269269
self.setExtraSelections(self.extraSelections() + [extra])
270270

@@ -275,8 +275,8 @@ def highlight_line(self, lineno: int, color: QColor):
275275
cursor.select(QTextCursor.SelectionType.LineUnderCursor)
276276

277277
extra = QTextEdit.ExtraSelection()
278-
extra.format.setBackground(color.lighter(160)) # type: ignore
279-
extra.cursor = cursor # type: ignore
278+
extra.format.setBackground(color.lighter(160)) # pyright: ignore[reportAttributeAccessIssue]
279+
extra.cursor = cursor # pyright: ignore[reportAttributeAccessIssue]
280280

281281
self.setExtraSelections(self.extraSelections() + [extra])
282282

@@ -312,6 +312,19 @@ def __init__(self):
312312
json_label = QLabel("Context (JSON)")
313313
json_layout.addWidget(json_label)
314314
self.json_edit = CodeEditor()
315+
self.json_edit.setPlainText("""
316+
{
317+
"add_generation_prompt": true,
318+
"bos_token": "",
319+
"eos_token": "",
320+
"messages": [
321+
{
322+
"role": "user",
323+
"content": "What is the capital of Poland?"
324+
}
325+
]
326+
}
327+
""".strip())
315328
json_layout.addWidget(self.json_edit)
316329
input_layout.addLayout(json_layout)
317330

@@ -471,6 +484,7 @@ def format_template(self):
471484
context = json.loads(args.context)
472485
# Add missing variables
473486
context.setdefault("bos_token", "")
487+
context.setdefault("eos_token", "")
474488
context.setdefault("add_generation_prompt", False)
475489

476490
env = ImmutableSandboxedEnvironment()

0 commit comments

Comments
 (0)