Skip to content

Commit

Permalink
Enable pyink on tests, fix VSCode pyink config.
Browse files Browse the repository at this point in the history
Turns on checking pyink formatting for test files.

Also disables a bad Python version for pyink.
Black and Pyink do not support python 3.12.5, but uvx automatically
selects this version occasionally, which breaks autoformatting in
VSCode.
  • Loading branch information
danieldjohnson committed Nov 21, 2024
1 parent ccbc211 commit dd9e7ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
# Check formatting
- name: Check pyink formatting
run: uv run pyink treescope --check
run: uv run pyink treescope tests --check

- name: Run pylint
run: uv run pylint treescope
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"editor.detectIndentation": false,
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.path": ["uvx", "pyink"],
"black-formatter.path": ["uvx", "--python=>=3.9,!=3.12.5", "pyink"],
"pylint.enabled": true,
}
1 change: 1 addition & 0 deletions tests/fixtures/treescope_examples_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class ObjectWithCustomHandlerThatThrowsDeferred:

def __treescope_repr__(self, path, subtree_renderer):
del path, subtree_renderer

def _internal_main_thunk(layout_decision):
del layout_decision
raise RuntimeError("Simulated deferred treescope_repr failure!")
Expand Down
4 changes: 3 additions & 1 deletion tests/representation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ class RepresentationPartsTest(parameterized.TestCase):
expected_text_roundtrip_collapsed='some text with characters < > &',
expected_text_roundtrip_expanded='some text with characters < > &',
expected_html='some text with characters &lt; &gt; &amp;',
expected_html_at_beginning='some text with characters &lt; &gt; &amp;',
expected_html_at_beginning=(
'some text with characters &lt; &gt; &amp;'
),
),
dict(
testcase_name='siblings',
Expand Down
6 changes: 3 additions & 3 deletions treescope/_internal/html_encapsulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ def encapsulate_streaming_html(
stream = io.StringIO()

if stealable:
stealer_content = _prep_html_js_and_strip_comments(STEALER_TEMPLATE).replace(
"{__REPLACE_ME_WITH_CONTAINER_ID_CLASS__}", unique_id_class
)
stealer_content = _prep_html_js_and_strip_comments(
STEALER_TEMPLATE
).replace("{__REPLACE_ME_WITH_CONTAINER_ID_CLASS__}", unique_id_class)
yield HTMLOutputSegment(
html_src=stealer_content,
segment_type=SegmentType.FINAL_OUTPUT_STEALER,
Expand Down

0 comments on commit dd9e7ce

Please sign in to comment.