{"id":5371,"library":"plotly-stubs","title":"Plotly Type Stubs","description":"plotly-stubs is a stub-only package providing static type annotations for the Plotly Python graphing library. It enables type checkers like Mypy to validate Plotly-related code, improving code quality and maintainability. Currently, it is in 'Beta' development status.","status":"active","version":"0.1.3","language":"en","source_language":"en","source_url":"https://github.com/ClaasRostock/plotly-stubs.git","tags":["typing","stubs","plotly","type hints","mypy"],"install":[{"cmd":"pip install plotly-stubs","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This package provides type stubs for 'plotly'; the 'plotly' library itself is required for actual runtime execution of plotting code.","package":"plotly","optional":false}],"imports":[{"note":"Common Plotly figure object, type hints provided by stubs.","symbol":"Figure","correct":"from plotly.graph_objects import Figure"},{"note":"Often used with Plotly Express; stubs enhance type checking for dataframe interactions. Requires `pandas-stubs`.","symbol":"DataFrame","correct":"import pandas as pd\nfrom pandas import DataFrame"},{"note":"Plotly Express, a high-level API. Stubs enable type checking on its functions and return types.","symbol":"px","correct":"import plotly.express as px"}],"quickstart":{"code":"import plotly.express as px\nimport pandas as pd\nfrom plotly.graph_objects import Figure # Type hint for the return\n\ndef create_population_chart(df: pd.DataFrame) -> Figure:\n    \"\"\"Creates a population scatter plot using Plotly Express.\"\"\"\n    fig = px.scatter(\n        df,\n        x=\"gdpPercap\",\n        y=\"lifeExp\",\n        size=\"pop\",\n        color=\"continent\",\n        hover_name=\"country\",\n        log_x=True,\n        size_max=60\n    )\n    return fig\n\n# Example usage (assuming 'gapminder' dataset is available, e.g., from px.data.gapminder())\n# df_gapminder = px.data.gapminder()\n# fig = create_population_chart(df_gapminder)\n# fig.show()","lang":"python","description":"To use plotly-stubs, simply install it alongside `plotly`. Type checkers will automatically pick up the stub files. The example demonstrates a function that creates a Plotly figure with type hints, leveraging the stubs for static analysis."},"warnings":[{"fix":"Ensure `plotly` is installed: `pip install plotly`.","message":"The `plotly-stubs` package provides *only* type hints. For actual runtime execution of plotting code, the `plotly` library itself must be installed (e.g., `pip install plotly`). `plotly-stubs` does not install `plotly` as a dependency.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your development environment uses Python 3.11 or later. Check `python --version`.","message":"The `plotly-stubs` package strictly requires Python >=3.11 and <3.15. While the core `plotly` library might support older Python versions, using `plotly-stubs` will enforce this Python version constraint during development and type checking.","severity":"breaking","affected_versions":"All versions"},{"fix":"Monitor the project's GitHub for updates and be prepared for potential changes in type signatures or coverage. Report missing types to the repository.","message":"As of `plotly-stubs` version 0.1.3, the project is still in 'Beta' development status. This implies that the API for type stubs might evolve, and complete coverage for all `plotly` features may not yet be available or fully stable.","severity":"gotcha","affected_versions":"All versions up to 0.1.3"},{"fix":"Consult the `Dash` documentation and community forums for specific workarounds or updates regarding `Dash`'s type annotations. Consider adding `ignore_missing_imports = true` for `dash.*` in `mypy` configuration if issues persist.","message":"When using `plotly` with `Dash`, users have reported issues with `Dash` version 3.0 introducing breaking type annotations that do not comply with `mypy`, leading to `Untyped decorator` errors for `dash.callback`. This can indirectly affect the perceived type-completeness when `plotly-stubs` is used in a `Dash` application.","severity":"gotcha","affected_versions":"Dash 3.x"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}