Skip to main content

fixo

Goals.

  • Light weight, semi-automatic rule-based tool to add type annotations to Python code bases.

  • Apply rule-based edits, and allow the user to pick and choose which edits to accept.

  • Edits are not represented as raw diffs, but as semantic changes to the Python source, which are far more likely to be stable through intermediate changes in the code.

  • The rules to match code and to perform edits can easily be user code.

  • Less than 1k lines of code with testing.

Design sketch

The input to the program would be the output of some other diagnostic tool, like pyrefly or mypy, outputs that are divided into messages, one complete message from the diagnostic tool to the user. In pyrefly it can just be a single line of text.

A message has a file name, a symbol name, and a line number, a column number for the start and end of position in the file.

For each message in the input, and for each rule that that message matches, the rule creates a proposed edit to the message's file, and then writes that edit as a line of JSON into the "edits file"

The user chooses selects which edits to use, initially by just editing the edits file, and soon with a little terminal interface that displays the proposed change in context of the Python source file.

Then the edits file is applied to the code base all at once.

How to write it?

Four main parts need to be written:

  1. Parsing the inputs into messages
  2. Matching messages against rules
  3. Creating an edit from a rule and a matching message
  4. Performing an edit

The hard part: it must easy be for developers to create and perform edits without knowing how to parse a Python file

As of October 1

All the fundamental classes exist and some tests of the trickiest parts of their functionality too - it mostly corresponds to the above.

Now we embark on three specific rules to apply to PyTorch

  1. Add a bool return type annotation to methods and functions that start with _?(is|has)_
  2. Add a bool type annotation to parameters that start with (is|has)_
  3. Add a torch.Tensor type annotation to function (but not method) parameters named self

Metadata

Release files for fixo 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fixo 0.3.0
File Size Uploaded
fixo-0.3.0.tar.gz 39.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fixo 0.3.0
File Interpreter ABI Platform
fixo-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.0 kB

Release files / fixo-0.3.0.tar.gz

Download URL fixo-0.3.0.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6e7aeca3fd860584af6af65046f7a9f84779c7ba7b5473b4e8d6c4ddab96e35e
BLAKE2b-256 checksum
How to use checksums
ac4418700783ba17d490ba77f5f82a52a28d5a3d7dd0a99c3b9f71d72aa153a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / fixo-0.3.0-py3-none-any.whl

Download URL fixo-0.3.0-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e2a6ccf57e2d360561cade6de093f03654adf3cb6b02046dd56428d90b61884
BLAKE2b-256 checksum
How to use checksums
ecba7726d61afd402e5118fc9aef3b17c176e7473a0c45816f1d1db5341e2b42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page