Skip to main content

Static exception inference for Python — powered by pyright.

Project description

araised

Static analysis tool that answers: what exceptions can this function raise?

Analyses explicit raise statements and common stdlib callables (dict[key], open(), json.loads(), etc.) using Pyright for type inference. Propagates through same-module and cross-file call chains with cycle detection.

Installation

pip install araised

To install the latest development version directly from the dev branch:

uv tool install git+https://github.com/amirouche/raises.py@dev

Requires Pyright (pip install pyright), which is pulled in automatically as a dependency.

CLI

araised module.path:callable [module.path:callable ...]

The target is module.path:callable, where callable is a bare function name or ClassName.method_name.

$ araised myapp.db:connect
myapp.db:connect
  builtins.KeyError        [dict.__getitem__, step 1]
  builtins.ValueError      [explicit raise, step 2]
  builtins.OSError         [builtins.open, step 1, via myapp.db:connect → myapp.db:_open_file]

Each line shows the exception, where it comes from, the analysis step, and the call chain (via) if it was propagated from a callee.

Multiple targets can be passed in one invocation:

$ araised myapp.db:connect myapp.db:disconnect

Programmatic API

import araised

entries = araised.analyse('myapp.db:connect')
for e in entries:
    print(e.exception, e.source, e.step, e.via)

analyse returns a list of RaisesEntry namedtuples:

Field Type Description
exception str Fully-qualified exception name, e.g. builtins.KeyError
source str What triggered it, e.g. dict.__getitem__ or explicit raise
step int 1 = inferred from type, 2 = explicit raise statement
via tuple[str, ...] Call chain leading to this exception (empty for direct)

Optional parameters:

araised.analyse(
    'myapp.db:connect',
    max_depth=3,        # max cross-file hops (default 3, 0 = no cross-file)
    max_union_width=3,  # max union members for dynamic dispatch (default 3)
)

Emacs

Load araised.el and call araised-at-point with point inside any Python function or method. It infers the target from the current file and def automatically, then shows results in a *araised* buffer.

(load "/path/to/araised.el")

;; optional keybinding
(add-hook 'python-mode-hook
          (lambda () (local-set-key (kbd "C-c r") #'araised-at-point)))

With point inside a function, M-x araised-at-point (or C-c r) prompts:

araised target: myapp.db:connect

Edit the target if needed, then press RET. Results appear in *araised*.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

araised-0.1.5.tar.gz (59.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

araised-0.1.5-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file araised-0.1.5.tar.gz.

File metadata

  • Download URL: araised-0.1.5.tar.gz
  • Upload date:
  • Size: 59.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for araised-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3d36c737687e9cd32ee0843c49bac137902f030d6db9d9c873449e65aa3e8cee
MD5 8b662e73d6dbb0d9a6eef698551114f8
BLAKE2b-256 a21499dc80893c3bb4096a7a742d08aa54912729fc673037de8dcb22cea91e7b

See more details on using hashes here.

File details

Details for the file araised-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: araised-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for araised-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e3ca8b2d436068781b0d4a7559484f2f8caa9f2c8646abc21ec2e79ee8529940
MD5 2aa1e5bff8a313bfdeb46677ed7fa4d0
BLAKE2b-256 7ed26e81ad39d0c1f81186f7791f205f52b9f4dd50717d064f6fae9564e055cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page