Skip to content

Commit

Permalink
Merge branch 'main' into vega-datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned authored Dec 20, 2024
2 parents 75bf2ba + 1208c5d commit 9e1fd09
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 30 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: build

on: [push, pull_request]

env:
UV_SYSTEM_PYTHON: 1

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -16,33 +19,33 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[all, dev]"
run: uv pip install -e ".[dev, all]"
- name: Install specific jsonschema
# Only have to execute this if we don't want the latest jsonschema version
if: ${{ matrix.jsonschema-version != 'latest' }}
run: |
pip install jsonschema==${{ matrix.jsonschema-version }}
uv pip install jsonschema==${{ matrix.jsonschema-version }}
- name: Maybe uninstall optional dependencies
# We uninstall pyarrow and vegafusion for one job to test that we have not
# accidentally introduced a hard dependency on these libraries.
# Uninstalling for Python 3.9 is an arbitrary choice.
# Also see https://github.com/vega/altair/pull/3114
if: ${{ matrix.python-version == '3.9' }}
run: |
pip uninstall -y pyarrow vegafusion vegafusion-python-embed vl-convert-python anywidget
uv pip uninstall pyarrow vegafusion vegafusion-python-embed vl-convert-python anywidget
- name: Maybe install lowest supported pandas version
# We install the lowest supported pandas version for one job to test that
# it still works. Downgrade to the oldest versions of pandas and numpy that include
# Python 3.9 wheels, so only run this job for Python 3.9
if: ${{ matrix.python-version == '3.9' }}
run: |
pip install pandas==1.1.3 numpy==1.19.3
uv pip install pandas==1.1.3 numpy==1.19.3
- name: Test that schema generation has no effect
run: |
pip install vl-convert-python
uv pip install vl-convert-python
python tools/generate_schema_wrapper.py
# This gets the paths of all files which were either deleted, modified
# or are not yet tracked by Git
Expand All @@ -66,13 +69,13 @@ jobs:
fi
- name: Test with pytest
run: |
pytest --pyargs --numprocesses=logical --doctest-modules tests
uv run pytest --pyargs --numprocesses=logical --doctest-modules tests
- name: Validate Vega-Lite schema
run: |
# We install all 'format' dependencies of jsonschema as check-jsonschema
# only does the 'format' checks which are installed.
# We can always use the latest jsonschema version here.
# uri-reference check is disabled as the URIs in the Vega-Lite schema do
# not conform RFC 3986.
pip install 'jsonschema[format]' check-jsonschema --upgrade
check-jsonschema --check-metaschema altair/vegalite/v5/schema/vega-lite-schema.json --disable-formats uri-reference
uv pip install 'jsonschema[format]' check-jsonschema --upgrade
uv run check-jsonschema --check-metaschema altair/vegalite/v5/schema/vega-lite-schema.json --disable-formats uri-reference
14 changes: 9 additions & 5 deletions .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: docbuild

on: [push, pull_request]

env:
UV_SYSTEM_PYTHON: 1

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -11,15 +14,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
run: uv pip install -e ".[dev, all, doc]"
- name: Run doc:build-html
run: |
hatch run doc:build-html
mkdir -p doc/_images
uv run sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
- name: Run doc:doctest
run: |
hatch run doc:doctest
uv run sphinx-build -b doctest -d doc/_build/doctrees doc doc/_build/doctest
17 changes: 8 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ jobs:
runs-on: ubuntu-latest
name: ruff-mypy
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
# Installing all dependencies and not just the linters as mypy needs them for type checking
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
run: uv pip install -e ".[dev, all]" --system
- name: Lint with ruff
run: |
hatch run ruff check .
uv run ruff check
- name: Check formatting with ruff
run: |
hatch run ruff format --diff .
hatch run ruff format --check .
uv run ruff format --check --diff
- name: Lint with mypy
run: |
hatch run mypy altair tests
uv run mypy altair tests
2 changes: 1 addition & 1 deletion altair/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def numpy_is_subtype(dtype: Any, subtype: Any) -> bool:
import numpy as np

try:
return np.issubdtype(dtype, subtype)
return cast("bool", np.issubdtype(dtype, subtype))
except (NotImplementedError, TypeError):
return False

Expand Down
2 changes: 1 addition & 1 deletion altair/utils/mimebundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _validate_normalize_engine(

def _pngxy(data):
"""
read the (width, height) from a PNG header.
Read the (width, height) from a PNG header.
Taken from IPython.display
"""
Expand Down
2 changes: 1 addition & 1 deletion altair/utils/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def _format_params_as_table(param_dict_keys: Iterable[str]) -> str:
max_column_width = 80
# Output a square table if not too big (since it is easier to read)
num_param_names = len(param_names)
square_columns = int(ceil(num_param_names**0.5))
square_columns = ceil(num_param_names**0.5)
columns = min(max_column_width // max_name_length, square_columns)

# Compute roughly equal column heights to evenly divide the param names
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ all = [
]
dev = [
"hatch>=1.13.0",
"ruff>=0.6.0",
"ruff>=0.8.4",
"duckdb>=1.0",
"ipython[kernel]",
"pandas>=1.1.3",
Expand Down Expand Up @@ -347,6 +347,8 @@ ignore = [
"B905",
# mutable-class-default
"RUF012",
# used-dummy-variable
"RUF052",
# suppressible-exception
# https://github.com/vega/altair/pull/3431#discussion_r1629808660
"SIM105",
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_sanitize_dataframe_colnames():

# Test that non-string columns result in an error
df.columns = [4, "foo", "bar"]
with pytest.raises(ValueError, match="Dataframe contains invalid column name: 4."):
with pytest.raises(ValueError, match=r"Dataframe contains invalid column name: 4."):
sanitize_pandas_dataframe(df)


Expand Down
2 changes: 1 addition & 1 deletion tools/schemapi/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def _format_params_as_table(param_dict_keys: Iterable[str]) -> str:
max_column_width = 80
# Output a square table if not too big (since it is easier to read)
num_param_names = len(param_names)
square_columns = int(ceil(num_param_names**0.5))
square_columns = ceil(num_param_names**0.5)
columns = min(max_column_width // max_name_length, square_columns)

# Compute roughly equal column heights to evenly divide the param names
Expand Down

0 comments on commit 9e1fd09

Please sign in to comment.