Skip to main content

CLI tool for finding Python function definitions using ty's LSP server

Project description

ty-find

A command-line tool for Python code navigation using ty's LSP server. Uses a daemon-backed architecture to keep LSP connections warm between commands (~50-100ms after initial startup).

Usage with Claude Code

Add this to your project's CLAUDE.md to enable type-aware code navigation:

### Python Symbol Navigation (ty-find)

IMPORTANT: Use `tyf` instead of Grep for Python symbol lookups.
Grep matches in comments, strings, and docs — tyf is type-aware and precise.
Run `tyf --help` to see all commands. Run `tyf <cmd> --help` for details.

All commands accept multiple symbols in one call — always batch to save tool invocations:

- Symbol overview (definition + type + refs): `tyf inspect Sym1 Sym2 Sym3`
- Find definition: `tyf find Sym1 Sym2 Sym3`
- All usages before refactoring: `tyf refs Sym1 Sym2` or `tyf refs -f file.py -l LINE -c COL`
- File outline: `tyf list file.py`

Grep is still appropriate for string literals, config values, TODOs, and non-symbol text.

Why ty-find over grep?

  • Find symbol usages - grep matches in docs, comments, and strings; tyf returns only actual code references
  • Rename refactoring - grep may miss or over-match; tyf is type-aware and precise

Installation

Prerequisite: ty type checker (uv add --dev ty)

From PyPI

pip install ty-find

# Or with uv
uv add --dev ty-find

From Git (Pre-Release)

Requires the Rust toolchain to build from source:

pip install "ty-find @ git+https://github.com/mojzis/ty-find.git"

# Or with uv
uv add --dev "ty-find @ git+https://github.com/mojzis/ty-find.git"

From Source

git clone https://github.com/mojzis/ty-find.git
cd ty-find
cargo install --path .

Note: Windows support is limited — see Platform Support below.

Platform Support

ty-find builds and installs on all platforms, but the background daemon requires Unix domain sockets and is only available on Unix systems (Linux, macOS).

Command Linux / macOS Windows
find --file Yes Yes
find (no file) Yes No
find --fuzzy Yes No
inspect Yes No
refs Yes No
list Yes No
daemon Yes No

On Windows, daemon-dependent commands exit with a clear error message. Adding the package as a dependency won't break your project on Windows — it just won't have full functionality. PRs for Windows named-pipe support are welcome!

Usage

Inspect (Definition + Type Info + References)

All-in-one command — searches the workspace by symbol name, no file needed. Supports multiple symbols in a single call:

tyf inspect calculate_sum

# Inspect multiple symbols at once (results grouped by symbol)
tyf inspect calculate_sum UserService Config

# Narrow to a specific file
tyf inspect calculate_sum --file src/math.py

# JSON output for scripting
tyf --format json inspect UserService

Find Symbol by Name

Searches the workspace for a symbol's definition. Supports multiple symbols in a single call. Use --fuzzy for partial/prefix matching with richer output (kind + container):

tyf find calculate_sum

# Find multiple symbols at once (results grouped by symbol)
tyf find calculate_sum multiply divide

# Narrow to a specific file (text-based search + goto_definition)
tyf find function_name --file myfile.py

# Fuzzy/prefix match (returns symbol kind + container info)
tyf find handle_ --fuzzy

Find References

# By position (exact, pipeable from list)
tyf refs -f myfile.py --line 10 --column 5

# By name
tyf refs my_function MyClass

# Mixed and piped
tyf refs file.py:10:5 my_func
... | tyf refs --stdin

Document Outline

tyf list src/services/user.py

Daemon Management

The daemon starts automatically on first use. Manual control:

tyf daemon start    # Start manually
tyf daemon status   # Check status
tyf daemon stop     # Stop

Output Formats

All commands support --format (placed before the subcommand): human (default), json, csv, paths.

tyf --format json inspect MyClass
tyf --format csv find User --fuzzy

Architecture

CLI Command → Daemon Client (auto-connects) → Unix Socket
→ Daemon Server (5min idle timeout) → LSP Client Pool → ty LSP Server

The daemon keeps LSP connections warm: first command takes 1-2s, subsequent commands 50-100ms.

Development

cargo build --release
cargo test
cargo clippy
cargo fmt --check

# Verbose logging
RUST_LOG=ty_find=debug cargo run -- find hello_world

Troubleshooting

# Check ty is installed
ty --version

# Debug daemon issues
tyf daemon status
RUST_LOG=ty_find=debug tyf daemon start

# Restart daemon
tyf daemon stop && tyf daemon start

Contributing

Contributions welcome! Please open an issue to discuss major changes.

License

MIT License - see LICENSE file for details.

Credits

Built with ty - Astral's Python type checker.

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

ty_find-0.2.1.tar.gz (938.4 kB view details)

Uploaded Source

Built Distributions

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

ty_find-0.2.1-py3-none-win_amd64.whl (791.2 kB view details)

Uploaded Python 3Windows x86-64

ty_find-0.2.1-py3-none-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

ty_find-0.2.1-py3-none-macosx_11_0_arm64.whl (959.0 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file ty_find-0.2.1.tar.gz.

File metadata

  • Download URL: ty_find-0.2.1.tar.gz
  • Upload date:
  • Size: 938.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ty_find-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f99971e66066dbaa3ef074c617e30b232d0f9d96b1f0d531c7ede779b46126a2
MD5 5be4db219bb906f6bc814721659ff6ed
BLAKE2b-256 487b761f4b2fe84ccbfbabfa14f93e5f951eb27d25a505fafa2e3e2ffecf7a45

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.2.1.tar.gz:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ty_find-0.2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: ty_find-0.2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 791.2 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ty_find-0.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6eafcf560ffc5bc6b552290e5a04bd2f6a7d4ed403ef0df6c6d8c80c37d0d188
MD5 2190fbba6e4ceb516587f01542e1f0a0
BLAKE2b-256 1ab33f11db304fd8ec553a74592c133a1eb465e819d25a188f93bb6d30824ec4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.2.1-py3-none-win_amd64.whl:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ty_find-0.2.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ty_find-0.2.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9de455059dec4ab547ccc59cc961bd1251509294b555d3a079c5082708d7ec58
MD5 42e337616dd9bbeb770ae2f07ad26166
BLAKE2b-256 9a54b65a18cc3e410cda73f869c23e582b8224c6baec5864a8655b21cdcd61d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.2.1-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ty_find-0.2.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ty_find-0.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af6d0736da4a551a1411e241ac4b56e5c39cce2a45ee026ef64d55b281f4c709
MD5 cb701aec5bbf93d83001dcff8e11a660
BLAKE2b-256 e5d2d886b329c9e7dc3658efd6244ed7f922148469d4f6d9148202a8ece3f426

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.2.1-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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