{"id":27031,"library":"gritql","title":"GritQL","description":"GritQL is a query language for searching and transforming code. The `gritql` package provides Python bindings to run GritQL queries programmatically. Version 0.2.0 is experimental and under active development.","status":"active","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/getgrit/gritql","tags":["code-search","codemod","pattern-matching","AST"],"install":[{"cmd":"pip install gritql","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The library exposes a single class `GritQuery` for compiling and executing queries.","wrong":"","symbol":"GritQuery","correct":"from gritql import GritQuery"}],"quickstart":{"code":"from gritql import GritQuery\n\n# Compile a simple query\nquery = GritQuery('`console.log`')\n\n# Run against a code snippet (returns True if matched)\nresult = query.run('console.log(\"hello\")')\nprint(result)  # True\n\n# With file path\nresult = query.run('console.log(\"hello\")', path='test.js')\nprint(result)  # True\n","lang":"python","description":"Basic usage: compile a GritQL pattern and run it against a string or file."},"warnings":[{"fix":"Pin to exact version: `pip install gritql==0.2.0`. Check changelog before upgrading.","message":"API instability: The Python API is still experimental (0.x) and may change without notice. Expect breaking changes in minor versions.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"If you need match metadata, consider using the GritQL CLI tool directly with subprocess.","message":"Query result is boolean only: `run()` returns `True` if the pattern matched, not a match object or location info. To get detailed matches, you may need to use the CLI or Rust API.","severity":"gotcha","affected_versions":"all"},{"fix":"Install the GritQL CLI: `curl -fsSL https://docs.grit.io/install | bash` or download from GitHub releases.","message":"Requires installed GritQL binary: The Python bindings expect a `grit` binary on PATH. Without it, import succeeds but `GritQuery()` will fail at runtime with a `FileNotFoundError`.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install the GritQL CLI by running the install script or downloading the binary and adding it to your PATH.","cause":"The Python bindings call the `grit` binary under the hood. If it's not installed or not on PATH, this error occurs.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'grit'"},{"fix":"Run `pip install gritql` to install the package.","cause":"The `gritql` package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'gritql'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}