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:

### Code Navigation (ty-find)
Use `ty-find` for type-aware Python code navigation - more accurate than grep for symbols.
Requires `ty` on PATH (`uv add --dev ty`).

**Commands** (use relative paths from repo root):
ty-find inspect SymbolName                               # Definition + type info + references in one shot
ty-find inspect Foo Bar Baz                              # Inspect multiple symbols in one call
ty-find find SymbolName                                  # Find symbol definition across workspace
ty-find find Foo Bar Baz                                 # Find multiple symbols in one call
ty-find references path/to/file.py -l LINE -c COL       # Find all usages of symbol at position
ty-find definition path/to/file.py -l LINE -c COL       # Go to definition at position
ty-find hover path/to/file.py -l LINE -c COL            # Get type info at position
ty-find workspace-symbols --query "ClassName"            # Search symbols across codebase
ty-find document-symbols path/to/file.py                 # Get file outline

**When to use:**
- Quick overview of any symbol: `ty-find inspect SymbolName` (one command for everything)
- Before renaming/refactoring: `ty-find references` to find all usages
- Understanding unfamiliar code: `ty-find hover` for type info
- Finding class/function definitions: `ty-find find SymbolName`

**Output formats:** Add `--format json` before subcommand for programmatic use.

Why ty-find over grep?

  • Find symbol usages - grep matches in docs, comments, and strings; ty-find returns only actual code references
  • Rename refactoring - grep may miss or over-match; ty-find 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 is not currently supported. PRs 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:

ty-find inspect calculate_sum

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

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

# JSON output for scripting
ty-find --format json inspect UserService

Find Symbol by Name

Searches the workspace for a symbol's definition. Supports multiple symbols in a single call:

ty-find find calculate_sum

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

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

Hover (Type Information)

ty-find hover src/main.py --line 45 --column 12

# JSON output for scripting
ty-find --format json hover src/main.py -l 45 -c 12 | jq '.result.contents.value'

Go to Definition

ty-find definition myfile.py --line 10 --column 5

Find References

ty-find references myfile.py --line 10 --column 5

Workspace Symbol Search

ty-find workspace-symbols --query "UserService"

Document Outline

ty-find document-symbols src/services/user.py

Interactive Mode

ty-find interactive

Daemon Management

The daemon starts automatically on first use. Manual control:

ty-find daemon start    # Start manually
ty-find daemon status   # Check status
ty-find daemon stop     # Stop

Output Formats

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

ty-find --format json hover myfile.py -l 10 -c 5
ty-find --format csv workspace-symbols --query "User"

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 -- hover test.py -l 1 -c 1

Troubleshooting

# Check ty is installed
ty --version

# Debug daemon issues
ty-find daemon status
RUST_LOG=ty_find=debug ty-find daemon start

# Restart daemon
ty-find daemon stop && ty-find 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.1.7.tar.gz (75.8 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.1.7-py3-none-manylinux_2_39_x86_64.whl (1.0 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

ty_find-0.1.7-py3-none-macosx_11_0_arm64.whl (864.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: ty_find-0.1.7.tar.gz
  • Upload date:
  • Size: 75.8 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.1.7.tar.gz
Algorithm Hash digest
SHA256 bb70542d79a3ae144aeaf6fe39d8002af9a237fa5d4f47853e0fdfc410a7854b
MD5 102bde1975471851e759e76c133b41c5
BLAKE2b-256 9f2d2358a8e6d05933e9553e18ad54b740b8d349865b18288c070931f2534ef9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.1.7.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.1.7-py3-none-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for ty_find-0.1.7-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 0acee526cdd4866f03b56eb83b3ed4a8addb1fbe12b4403f5c018337808101aa
MD5 bc6a52fa5bf4b293c99cd91f5ea0e1b2
BLAKE2b-256 f812adf8910c016eb42585a903c78c400963b6777bc4ffff9c4d10afd665dff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.1.7-py3-none-manylinux_2_39_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.1.7-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ty_find-0.1.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74e363373d97a364192b4af5932c9ffdf8fc76e9c5f2a94b436bc5decd0feb05
MD5 a77b5436bfade38c6f0705fcbaca81e7
BLAKE2b-256 7bf3a39e4d0298e581007a64d028db43013232513a41cc248974be058123a011

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.1.7-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