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 `ty-find` instead of Grep for Python symbol lookups.
Grep matches in comments, strings, and docs — ty-find is type-aware and precise.
Run `ty-find --help` to see all commands. Run `ty-find <cmd> --help` for details.

- Symbol overview (definition + type + refs): `ty-find inspect SymbolName`
- Find definition: `ty-find find SymbolName`
- All usages before refactoring: `ty-find references SymbolName` or `ty-find references -f file.py -l LINE -c COL`
- Type info: `ty-find hover file.py -l LINE -c COL`
- File outline: `ty-find document-symbols 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; 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 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
definition Yes Yes
find --file Yes Yes
interactive Yes Yes
find (no file) Yes No
inspect Yes No
hover Yes No
references Yes No
workspace-symbols Yes No
document-symbols 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:

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

# By position (exact, pipeable from document-symbols)
ty-find references -f myfile.py --line 10 --column 5

# By name (parallel search)
ty-find references my_function MyClass

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.11.tar.gz (105.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.1.11-py3-none-win_amd64.whl (789.1 kB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

ty_find-0.1.11-py3-none-macosx_11_0_arm64.whl (915.3 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: ty_find-0.1.11.tar.gz
  • Upload date:
  • Size: 105.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.1.11.tar.gz
Algorithm Hash digest
SHA256 a01191853b41d54cfe070e80027f694d6a1ec6cdecbfb86c4beaba179b4e6e9d
MD5 ec44a9dfd5f80a7fe86c1c11cffc248a
BLAKE2b-256 7b63a757c7c640a657977fbc2302e52f4f6ec556d86f538dbc51314e7bdb4b43

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.1.11.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.11-py3-none-win_amd64.whl.

File metadata

  • Download URL: ty_find-0.1.11-py3-none-win_amd64.whl
  • Upload date:
  • Size: 789.1 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.1.11-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 cd231d102a90ea823761d3c7998e459a44d563f305bb94ef3bceed9f8e9e1370
MD5 7c82dc56c25483fe7890b4006071fa38
BLAKE2b-256 3163f60dcd9279a008eddb1a9c8f58d3e22dde48eed56c225d00b7c995fee1d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.1.11-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.1.11-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ty_find-0.1.11-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 73aff0e325a0c19b6b1b6caefc92497237befe074c1824177ef50701338365fd
MD5 a1ecda6429ac99d952a303bb34b05447
BLAKE2b-256 cb65071e779e2a2605747d2dc4d3b0d07a42cb5a84df24d5edf6b9455c368f6c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ty_find-0.1.11-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9aada125309ed6c03775fa2c46ef498ab1424c1ae76e0e6c9af40e22dbe04f1e
MD5 84e5128b4d99179b0437f1a77c4433e8
BLAKE2b-256 e13c46f4a052d9a5db2fb1c83f85d31a23e6148cfd3c27332521e3f75dfdb9fd

See more details on using hashes here.

Provenance

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