Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ coverage:
patch:
default:
target: 80%

ignore:
- "apps/"
7 changes: 1 addition & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ jobs:
numpy-version: '<2.0'
- python-version: "3.13"
pandas-version: pre
polars: true
- python-version: "3.13"
uninstall_non_essential_dependencies: true
- python-version: "3.10"
Expand Down Expand Up @@ -110,16 +109,12 @@ jobs:
if: matrix.typeguard-version != 'latest'
run: pip install 'typeguard${{ matrix.typeguard-version }}'

- name: Install polars
if: matrix.polars
run: pip install -e .[polars]

- name: Install shiny
run: pip install "shiny>=1.0" shinywidgets

- name: Uninstall non-essential dependencies
if: matrix.uninstall_non_essential_dependencies
run: pip uninstall jinja2 dash anywidget streamlit shiny shinywidgets -y
run: pip uninstall polars jinja2 dash anywidget streamlit shiny shinywidgets -y

- name: Install a Jupyter Kernel
run: python -m ipykernel install --name itables --user
Expand Down
36 changes: 13 additions & 23 deletions packages/dt_for_itables/add_host_to_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,21 @@ def process_rule(match):
return re.sub(pattern, process_rule, css_content)


if __name__ == "__main__":

def main():
parser = argparse.ArgumentParser(
description="Add :host to each :root selector in a CSS file."
)
parser.add_argument("css_file", help="Path to the CSS file to modify")
args = parser.parse_args()
def main(argv):
parser = argparse.ArgumentParser(
description="Add :host to each :root selector in a CSS file."
)
parser.add_argument("css_file", help="Path to the CSS file to modify")
args = parser.parse_args(argv[1:])

try:
with open(args.css_file, "r") as file:
css_content = file.read()
with open(args.css_file, "r") as file:
css_content = file.read()

modified_content = add_host_to_root(css_content)
modified_content = add_host_to_root(css_content)

with open(args.css_file, "w") as file:
file.write(modified_content)
with open(args.css_file, "w") as file:
file.write(modified_content)

print(f"Successfully updated {args.css_file}")
return 0
except FileNotFoundError:
print(f"Error: File {args.css_file} not found.")
return 1
except Exception as e:
print(f"Error processing file: {e}")
return 1

sys.exit(main())
if __name__ == "__main__":
sys.exit(main(sys.argv))
14 changes: 13 additions & 1 deletion packages/dt_for_itables/test_add_host_to_root.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from add_host_to_root import add_host_to_root
from add_host_to_root import add_host_to_root, main


def test_add_host_to_root_example():
Expand Down Expand Up @@ -66,3 +66,15 @@ def test_add_host_to_root_complex_selectors():
:root[data-theme="light"] .element, :host[data-theme="light"] .element { background-color: white; }
"""
assert add_host_to_root(original_css) == expected_css


def test_main_function(tmp_path):
"""Test the main function modifies the file as expected."""
css_content = ":root { color: red; }"
expected_content = ":root, :host { color: red; }"
css_file = tmp_path / "test.css"
css_file.write_text(css_content)

main(["add_host_to_root.py", str(css_file)])
result = css_file.read_text()
assert result == expected_content
19 changes: 15 additions & 4 deletions tests/test_documentation_notebooks_run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import subprocess
import sys
from pathlib import Path

import jupytext
Expand Down Expand Up @@ -34,15 +36,24 @@ def test_run_documentation_notebooks(notebook):
pytest.skip("Polars is not available")
if "pandas_style" in notebook.stem and pd_style is None:
pytest.skip("Pandas Style is not available")
if "shiny" in notebook.stem:
pytest.skip("shinywidgets makes the widget.md notebook fail")
if "marimo" in notebook.stem or "widget" in notebook.stem:
pytest.importorskip("anywidget")

org_options = dir(opt)

nb = jupytext.read(notebook)
py_notebook = jupytext.writes(nb, "py:percent")
if "shiny" in notebook.stem:
# we can't use exec as shinywidgets makes the widget.md notebook fail
result = subprocess.run(
[sys.executable, "-c", py_notebook], capture_output=True, text=True
)
if result.returncode != 0:
if "ModuleNotFoundError: No module named 'shinywidgets'" in result.stderr:
pytest.skip("shinywidgets is not available")
assert result.returncode == 0, result.stderr
return

org_options = dir(opt)

exec(py_notebook, {})

new_options = set(dir(opt)).difference(org_options)
Expand Down
Loading