Skip to content

Start here

Install and set up

Astrolabe needs Python 3.12 or later, mypy 1.13 or later, and Polars 1.43.2.

Terminal window
uv add git+https://github.com/thomasblanchet/astrolabe

Run this command in the directory of your project:

Terminal window
uv run astrolabe init

The command changes pyproject.toml:

  • It adds the plugin to [tool.mypy] and sets allow_redefinition = true.
  • It writes a [tool.astrolabe] table with every setting at its default, each with a comment.

The command keeps the comments and the format of the file. A second run changes nothing. To see the changes before it writes them, add --dry-run. See CLI for the other options.

If mypy reads its configuration from mypy.ini, .mypy.ini or the [mypy] section of setup.cfg, the command changes nothing. It shows the lines to add to that file.

Add these lines to pyproject.toml:

pyproject.toml
[tool.mypy]
plugins = ["astrolabe.plugin"]
allow_redefinition = true

The plugin needs allow_redefinition = true. The type of an expression that a loop builds settles only when mypy lets the loop rebind its variable. If the setting is off, the plugin logs a warning.

Run mypy as before:

Terminal window
mypy .

The errors of the plugin show wherever mypy runs: in the terminal, in an editor that runs mypy, in pre-commit hooks and in CI. Each error ends with a code in brackets, for example [unknown-column]. See Error codes.

Next, type your first frame in the Quickstart.