Symbex

Latest version: v1.4

Safety actively analyzes 627364 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

1.4

New output options: `--json`, `--nl`, `--csv` and `--tsv`. These can be used to produce structured output which can be consumed by other tools such as [sqlite-utils](https://sqlite-utils.datasette.io/en/stable/cli.html#inserting-json-data) or [llm embed-multi](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-embed-multi). [40](https://github.com/simonw/symbex/issues/40)

To generate and store [embeddings](https://llm.datasette.io/en/stable/embeddings/index.html) for all of your symbols, run this:
bash
symbex '*' '*:*' --nl | \
llm embed-multi symbols - \
--format nl --database embeddings.db --store

This produces an `embeddings.db` database containing your code and its embeddings.

You can then run searches using [llm similar](https://llm.datasette.io/en/stable/embeddings/cli.html#llm-similar):
bash
llm similar symbols -d embeddings.db -c 'test csv' | jq

1.3.1

- Function and class signatures output by this tool now include the trailing `:`. [39](https://github.com/simonw/symbex/issues/39)

1.3

Three new filters: [38](https://github.com/simonw/symbex/issues/38)
- `--private`: return only symbols that have a `_` prefix (excluding `__*__` methods which are treated as public)
- `--public`: the opposite of private - just symbols that don't have a `_` prefix, but still returns `__*__` methods
- `--dunder`: return just symbols matching `__*__` - should usually be used with `*.*` to filter for class methods, e.g. `symbex '*.*' --dunder`

1.2

- New `--unasync` filter option, for searching for just functions that are not `async def` functions. [37](https://github.com/simonw/symbex/issues/37)

1.1

- New `--check` option, which will return a non-zero exit code if the tool finds any matching symbols. This is designed to be used with Continuous Integration tools, where it can do things like detect if any functions have been added without docstrings by running `symbex --function --undocumented --check`.

`--check` will not output anything by default. Add `--count` to output a count of matching symbols, or `-s/--signatures` to output the signatures of the matching symbols.
- New `--rexec SHELL_COMMAND` option, which can specify a shell command to be run for a single matching symbol in order to replace its body with the output of that command. This can be used with [LLM](https://llm.datasette.io/) to use language models to modify code in-place, for example:

bash
symbex my_function \
--rexec "llm --system 'add type hints and a docstring'"


This will add type hints and a generated docstring to the `my_function` function.

1.0

New `--replace` option for piping replacement code to standard input and having `symbex` modify a file in place to replace the matched symbol with the new implementation. [31](https://github.com/simonw/symbex/issues/31)

This is designed to be used with [LLM](https://llm.datasette.IO/), a command-line utility for the executing prompts against Large Language Models such as ChatGPT and GPT-4.

Example usage, to add type hints to the specified function:
bash
symbex fetch_articles -n \
| llm --system 'add type hints' \
| symbex fetch_articles --replace

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.