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 find SymbolName                                  # Find symbol definition across workspace
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:

ty-find inspect calculate_sum

# 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:

ty-find find calculate_sum

# 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

Documentation

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.6.tar.gz (79.7 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.6-py3-none-manylinux_2_39_x86_64.whl (986.4 kB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

ty_find-0.1.6-py3-none-macosx_11_0_arm64.whl (854.3 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: ty_find-0.1.6.tar.gz
  • Upload date:
  • Size: 79.7 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.6.tar.gz
Algorithm Hash digest
SHA256 acf3dfa974b365e9a5ecb0a146e662717454e98251aad6bb655fb20610522ead
MD5 6f3ee927dc3adc006ab9d2cd1b8aee50
BLAKE2b-256 bfbf07f362482070ac75593b4ffa73bb51fe048e97a5c708c37859f5da8e3c43

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ty_find-0.1.6-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5aeeb595b2e467881f4729ab512b54cf7d7b2e96f433940cf16f3bd661566358
MD5 655b70179c39e74f74c54323012df123
BLAKE2b-256 3b815ca24824f03f3c4ad32772b172ef48f46ce43a81d395d4faa34020180cc2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ty_find-0.1.6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 216c608624880928e4c1146722cfd97151a6e9b96a6b529a0fd9345c3ee335e5
MD5 cbc0b55057bc05b11c3d7e7d1f3efacc
BLAKE2b-256 d709ad0a73c605ef4749cfdfd6daa2c12b2bacafe26beeec738ccacc0bc70960

See more details on using hashes here.

Provenance

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