from Hacker News

Show HN: Strict interfaces and dep management for Python, written in Rust

by the1024 on 8/26/24, 4:58 PM with 12 comments

Tach is a pip package that lets you define module boundaries, automatically detect all cross-module dependencies, and then validate and enforce those dependencies.

It also supports strict interfaces for modules by overloading `__all__`.

The core static analysis is done in Rust, so all Tach commands run quickly.

The goal of Tach is to help eng teams maintain velocity while scaling quickly, something we've seen break down a number of times. Give it a try!

  • by claytonjy on 8/26/24, 9:57 PM

    Looks interesting, but I'm having a hard time understanding what this does that isn't covered by the ruff rules checking for uses of private functions or classes.

    It seems you can define an extra level of who's allowed to import what...but why would I want to add that on top rather than using standard conventions? Why would I want to let foo import baz, but not let bar import baz?

  • by anitil on 8/26/24, 11:27 PM

    Some related work from the same people, around how they sped up their AST analysis [0]. It looks like they have a few tools that would be very useful for wrangling existing python codebases and getting them under control.

    [0] https://www.gauge.sh/blog/python-extensions-should-be-lazy

  • by cdaringe on 8/27/24, 3:14 PM

    In TypeScript land, module boundaries currently enforceable using eslint with nx rules: https://nx.dev/nx-api/eslint-plugin/documents/enforce-module...
  • by skeledrew on 8/27/24, 5:12 PM

    Yet another tool that makes it harder to sync my projects and do ad-hoc coding on my phone, or anywhere else that I can't setup the Rust toolchain. That's all I'm seeing with this rustification of the Python ecosystem: a reduction in the breadth of practically supported targets for the language.