semvec/pypi-packages huggingface dataset:
ast-predicates 1.0.2
A Python library for matching and querying Python AST nodes
Requires Python: >=3.12

# AST Predicates

A Python library for matching and querying Python AST nodes, inspired by [libcst's matcher API](https://libcst.readthedocs.io/en/latest/matchers_tutorial.html) but designed to work with Python's built-in `ast` module.

## Overview

AST Predicates provides a declarative way to search for and match patterns in [Python Abstract Syntax Trees](https://docs.python.org/3/library/ast.html) using the standard library's `ast` module. It offers a more ergonomic alternative to manual AST traversal and isinstance checks.

## Features

- **Declarative matching**: Define patterns using a clean, composable API
- **Type-safe matchers**: Match AST node types with optional attribute constraints
- **Flexible queries**: Support for wildcards, sequences, and logical operators
- **Built on stdlib**: Works with Python's built-in `ast` module - no additional dependencies
- **Familiar API**: Inspired by libcst matchers

## Installation

```bash
pip install ast-predicates
```

## Quick Start

```python
import ast
from ast_predicates import matches, Call, Name, Attribute

# Parse some code
tree = ast.parse("foo.bar(42)")

# Find function calls to methods named 'bar'
pattern = Call(func=Attribute(attr="bar"))

# Check if pattern matches
if matches(tree.body[0].value, pattern):
    print("Found a call to a 'bar' method!")
```

## Basic Usage

### Matching Node Types

```python
from ast_predicates import matches, FunctionDef

# Match any function definition
pattern = FunctionDef()

# Match function with specific name
pattern = FunctionDef(name="my_function")
```

### Wildcards and Sequences

```python
from pyast_matchers import DoNotCare, OneOf, AllOf

# Match any value (wildcard)
pattern = Call(func=Name(id=DoNotCare()))

# Match one of several possibilities
pattern = BinOp(op=OneOf(Add(), Sub()))

# Match all conditions
pattern = AllOf(
    FunctionDef(name="process"),
    FunctionDef(decorator_list=[...])
)
```

### Finding Matches in a Tree

```python
from pyast_matchers import find_all

tree = ast.parse(source_code)
pattern = Call(func=Name(id="print"))

# Find all matching nodes
matches = find_all(tree, pattern)
```

## License

MIT License - see LICENSE file for details.

## Roadmap

- [ ] Performance benchmarks
- [ ] Implement [TypeOf](https://libcst.readthedocs.io/en/latest/matchers.html#libcst.matchers.TypeOf) matcher
- [ ] Implement [DoesNotMatch](https://libcst.readthedocs.io/en/latest/matchers.html#libcst.matchers.DoesNotMatch) matcher
- [ ] Implement [MatchRegex](https://libcst.readthedocs.io/en/latest/matchers.html#libcst.matchers.MatchRegex) matcher
- [ ] Implement [ZeroOrMore](https://libcst.readthedocs.io/en/latest/matchers.html#libcst.matchers.ZeroOrMore) matcher
- [ ] Implement [ZeroOrOne](https://libcst.readthedocs.io/en/latest/matchers.html#libcst.matchers.ZeroOrOne) matcher
calapy 0.2.0.4
Personal Package
Requires Python: >=3.6
Keywords: basic, tools, toolkit, toolbox, kit, utilities

# CalaPy

CalaPy is an undocumented python library that Dr Carmelo Calafiore developed for personal use. It is a collection of
many python functions that Dr Carmelo tends to use in different projects.

In previous versions from 0.0.0 to 0.0.60, the name of this package was ccalafiore.

You can install CalaPy by pip as:

```
pip install calapy
```

## Contacts

Dr Carmelo Calafiore

Newcastle University

Newcastle, UK

[dr.carmelo.calafiore@gmail.com](mailto:dr.carmelo.calafiore@gmail.com)

[LinkedIn](https://www.linkedin.com/in/carmelo-calafiore-a07120269)

[GitHub](https://github.com/ccalafiore)