diff --git a/vl-convert-python/pyproject.toml b/vl-convert-python/pyproject.toml index 2f74398..5e6b4c8 100644 --- a/vl-convert-python/pyproject.toml +++ b/vl-convert-python/pyproject.toml @@ -13,3 +13,67 @@ classifiers = [ [tool.maturin] sdist-include = ["*_thirdparty.*"] + +[tool.ruff] +target-version = "py310" +line-length = 88 +indent-width = 4 +exclude = [] + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = true +line-ending = "lf" +# https://docs.astral.sh/ruff/formatter/#docstring-formatting +docstring-code-format = true +docstring-code-line-length = 88 + +[tool.ruff.lint] +# https://docs.astral.sh/ruff/preview/ +preview = true + +# https://docs.astral.sh/ruff/settings/#lint_extend-safe-fixes +extend-safe-fixes = [ + # from __future__ import annotations # + # ---------------------------------- # + "UP006", + "UP007", + "UP008", + "TCH", + # unsorted-dunder-all + "RUF022", + # pydocstyle # + # ---------- # + # fits-on-one-line + "D200", + # escape-sequence-in-docstring + "D301", + # ends-in-period + "D400", +] +extend-select = [ + "ANN", + "D", + "D213", + "D400", + "E", + "F", + "FA", + "I001", + "RUF", + "TCH", + "TID", + "UP", + "W", +] +ignore = [ + # indent-with-spaces + "D206", + # multi-line-summary-first-line ((D213) is the opposite of this) + "D212", + # Line too long + "E501", +] +pydocstyle.convention = "numpy" +isort.split-on-trailing-comma = false \ No newline at end of file diff --git a/vl-convert-python/vl_convert.pyi b/vl-convert-python/vl_convert.pyi new file mode 100644 index 0000000..6ea9477 --- /dev/null +++ b/vl-convert-python/vl_convert.pyi @@ -0,0 +1,801 @@ +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from typing import Any, Literal, TypeAlias + + FormatLocaleName: TypeAlias = Literal[ + "ar-001", + "ar-AE", + "ar-BH", + "ar-DJ", + "ar-DZ", + "ar-EG", + "ar-EH", + "ar-ER", + "ar-IL", + "ar-IQ", + "ar-JO", + "ar-KM", + "ar-KW", + "ar-LB", + "ar-LY", + "ar-MA", + "ar-MR", + "ar-OM", + "ar-PS", + "ar-QA", + "ar-SA", + "ar-SD", + "ar-SO", + "ar-SS", + "ar-SY", + "ar-TD", + "ar-TN", + "ar-YE", + "ca-ES", + "cs-CZ", + "da-DK", + "de-CH", + "de-DE", + "en-CA", + "en-GB", + "en-IE", + "en-IN", + "en-US", + "es-BO", + "es-ES", + "es-MX", + "fi-FI", + "fr-CA", + "fr-FR", + "he-IL", + "hu-HU", + "it-IT", + "ja-JP", + "ko-KR", + "mk-MK", + "nl-NL", + "pl-PL", + "pt-BR", + "pt-PT", + "ru-RU", + "sl-SI", + "sv-SE", + "uk-UA", + "zh-CN", + ] + TimeFormatLocaleName: TypeAlias = Literal[ + "ar-EG", + "ar-SY", + "ca-ES", + "cs-CZ", + "da-DK", + "de-CH", + "de-DE", + "en-CA", + "en-GB", + "en-US", + "es-ES", + "es-MX", + "fa-IR", + "fi-FI", + "fr-CA", + "fr-FR", + "he-IL", + "hr-HR", + "hu-HU", + "it-IT", + "ja-JP", + "ko-KR", + "mk-MK", + "nb-NO", + "nl-BE", + "nl-NL", + "pl-PL", + "pt-BR", + "ru-RU", + "sv-SE", + "tr-TR", + "uk-UA", + "vi-VN", + "zh-CN", + "zh-TW", + ] + VegaThemes: TypeAlias = Literal[ + "carbong10", + "carbong100", + "carbong90", + "carbonwhite", + "dark", + "excel", + "fivethirtyeight", + "ggplot2", + "googlecharts", + "latimes", + "powerbi", + "quartz", + "urbaninstitute", + "vox", + ] + Renderer: TypeAlias = Literal["canvas", "hybrid", "svg"] + FormatLocale: TypeAlias = FormatLocaleName | dict[str, Any] + TimeFormatLocale: TypeAlias = TimeFormatLocaleName | dict[str, Any] + VlSpec: TypeAlias = str | dict[str, Any] + +__all__ = [ + "get_format_locale", + "get_local_tz", + "get_themes", + "get_time_format_locale", + "javascript_bundle", + "register_font_directory", + "svg_to_jpeg", + "svg_to_pdf", + "svg_to_png", + "vega_to_html", + "vega_to_jpeg", + "vega_to_pdf", + "vega_to_png", + "vega_to_scenegraph", + "vega_to_svg", + "vega_to_url", + "vegalite_to_html", + "vegalite_to_jpeg", + "vegalite_to_pdf", + "vegalite_to_png", + "vegalite_to_scenegraph", + "vegalite_to_svg", + "vegalite_to_url", + "vegalite_to_vega", +] + +def get_format_locale(name: FormatLocaleName) -> dict[str, Any]: + """ + Get the d3-format locale dict for a named locale. + + See https://github.com/d3/d3-format/tree/main/locale for available names + + Parameters + ---------- + name + d3-format locale name (e.g. 'it-IT') + + Returns + ------- + d3-format locale dict + """ + ... + +def get_local_tz() -> str | None: + """ + Get the named local timezone that Vega uses to perform timezone calculations. + + Returns + ------- + Named local timezone (e.g. "America/New_York"), or None if the local timezone + cannot be determined. + """ + ... + +def get_themes() -> dict[VegaThemes, dict[str, Any]]: + """ + Get the config dict for each built-in theme. + + Returns + ------- + dict from theme name to config object. + """ + ... + +def get_time_format_locale(name: TimeFormatLocaleName) -> dict[str, Any]: + """ + Get the d3-time-format locale dict for a named locale. + + See https://github.com/d3/d3-time-format/tree/main/locale for available names + + Parameters + ---------- + name + d3-time-format locale name (e.g. 'it-IT') + + Returns + ------- + d3-time-format locale dict. + """ + ... + +def javascript_bundle(snippet: str, vl_version: str | None) -> str: + """ + Create a JavaScript bundle containing the Vega Embed, Vega-Lite, and Vega libraries. + + Optionally, a JavaScript snippet may be provided that references Vega Embed + as `vegaEmbed`, Vega-Lite as `vegaLite`, Vega and `vega`, and the lodash.debounce + function as `lodashDebounce`. + + The resulting string will include these JavaScript libraries and all of their + dependencies. + This bundle result is suitable for inclusion in an HTML