Skip to content

Commit 2883754

Browse files
committed
UNPICK added AGENTS.md, copilot-instructions.md
1 parent 98f4773 commit 2883754

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed

.github/copilot-instructions.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Copilot Instructions
2+
3+
## Python Code Style
4+
5+
When generating Python code for the DataFusion Python project, adhere to the following style guidelines:
6+
7+
1. Follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide
8+
2. Comply with Ruff lint rules, specifically:
9+
10+
- Use double quotes for string literals
11+
- Use explicit relative imports (e.g., `from .module import Class`)
12+
- Limit line length to 88 characters (Black formatter standard) (prevent E501, W505)
13+
- Use type hints for function parameters and return values
14+
- Avoid unused imports
15+
- Use f-strings instead of `.format()` or `%` formatting
16+
- Avoid unnecessary `else` statements after `return`
17+
- Use `isinstance()` instead of comparing types directly
18+
- Keep docstrings concise and follow Google-style docstring format
19+
- Assign exception message strings to variables before raising (prevent EM101)
20+
21+
```python
22+
# Correct:
23+
msg = "Invalid input value"
24+
raise ValueError(msg)
25+
26+
# Incorrect:
27+
raise ValueError("Invalid input value")
28+
```
29+
30+
3. Include comprehensive docstrings for:
31+
32+
- Modules
33+
- Classes
34+
- Functions/methods
35+
36+
4. For tests:
37+
- Use meaningful test function names that describe what is being tested
38+
- Group related tests in classes
39+
- Use pytest style assertions instead of unittest style
40+
41+
## Rust Code Style
42+
43+
When generating Rust code for DataFusion, follow these guidelines:
44+
45+
1. Do not add unnecessary parentheses around `if` conditions:
46+
47+
- Correct: `if some_condition`
48+
- Incorrect: `if (some_condition)`
49+
50+
2. Follow the standard Rust style conventions from rustfmt
51+
52+
### Code Organization
53+
54+
- Keep functions concise and focused on a single task
55+
- Aim for functions under 40-50 lines of code
56+
- Break long or complex operations into smaller, well-named helper functions
57+
- Before creating new utility functions, check if existing helper functions in the codebase can be reused or extended
58+
- Consider adding parameters to existing functions rather than creating similar parallel implementations
59+
- Don't overengineer; avoid creating abstractions that are not needed
60+
- Look for similar patterns in the codebase and follow established conventions
61+
62+
## Comments
63+
64+
- Add meaningful comments for complex logic
65+
- Avoid obvious comments
66+
- Start inline comments with a capital letter
67+
68+
## Example Style
69+
70+
```python
71+
from typing import Optional, List
72+
73+
def process_data(data: List[str], max_length: Optional[int] = None) -> List[str]:
74+
"""Process a list of string data.
75+
76+
Args:
77+
data: List of strings to process
78+
max_length: Optional maximum length for each string
79+
80+
Returns:
81+
List of processed strings
82+
83+
Raises:
84+
ValueError: If invalid data is provided
85+
"""
86+
if not data:
87+
raise ValueError("Empty data list provided")
88+
89+
result = []
90+
for item in data:
91+
# Skip empty items
92+
if not item.strip():
93+
continue
94+
95+
processed = item.strip().lower()
96+
if max_length is not None and len(processed) > max_length:
97+
processed = processed[:max_length]
98+
99+
result.append(processed)
100+
101+
return result
102+
```

AGENTS.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Repository instructions for datafusion-python
2+
3+
## Style and Linting
4+
- Python formatting and linting is handled by **ruff**.
5+
- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) and these key
6+
ruff rules:
7+
- Use double quotes for string literals
8+
- Use explicit relative imports such as `from .module import Class`
9+
- Limit lines to 88 characters
10+
- Provide type hints for parameters and return values
11+
- Avoid unused imports
12+
- Prefer f-strings over other string formatting
13+
- Avoid `else` blocks after `return`
14+
- Use `isinstance()` instead of direct type comparison
15+
- Keep docstrings concise in Google format
16+
- Assign exception messages to variables before raising
17+
- All modules, classes, and functions should include docstrings.
18+
- Tests must use descriptive function names, pytest style assertions, and be
19+
grouped in classes when appropriate.
20+
- Rust code must pass `cargo fmt`, `cargo clippy`, and `cargo tomlfmt`.
21+
- Install the pre-commit hooks with `pre-commit install` and run them with
22+
`pre-commit run --files <file1> <file2>` or `pre-commit run --all-files`.
23+
24+
Install the required Rust components before running pre-commit:
25+
26+
```bash
27+
rustup component add rustfmt clippy
28+
```
29+
30+
If installation is blocked by a proxy, see the [offline installation guide](https://rust-lang.github.io/rustup/installation/other.html).
31+
32+
- The same checks can be run manually using the scripts in `ci/scripts`:
33+
- `./ci/scripts/python_lint.sh`
34+
- `./ci/scripts/rust_fmt.sh`
35+
- `./ci/scripts/rust_clippy.sh`
36+
- `./ci/scripts/rust_toml_fmt.sh`
37+
38+
## Rust Code Style
39+
40+
When generating Rust code for DataFusion, follow these guidelines:
41+
42+
1. Do not add unnecessary parentheses around `if` conditions:
43+
- Correct: `if some_condition`
44+
- Incorrect: `if (some_condition)`
45+
46+
2. Do not use `expect()` or `panic!()` except in tests - use proper error handling with `Result` types
47+
48+
3. Follow the standard Rust style conventions from rustfmt
49+
50+
## Code Organization
51+
- Keep functions focused and under about 50 lines.
52+
- Break complex tasks into well-named helper functions and reuse existing
53+
helpers when possible.
54+
- Prefer adding parameters to existing functions rather than creating new
55+
versions with similar behavior.
56+
- Avoid unnecessary abstractions and follow established patterns in the
57+
codebase.
58+
59+
## Comments
60+
- Add meaningful comments for complex logic and avoid obvious comments.
61+
- Start inline comments with a capital letter.
62+
63+
## Running Tests
64+
1. Ensure submodules are initialized:
65+
```bash
66+
git submodule update --init
67+
```
68+
2. Create a development environment and install dependencies:
69+
```bash
70+
uv sync --dev --no-install-package datafusion
71+
```
72+
3. Build the Python extension:
73+
```bash
74+
uv run --no-project maturin develop --uv
75+
```
76+
4. Execute the test suite:
77+
```bash
78+
uv run --no-project pytest -v .
79+
```
80+
81+
## Building Documentation
82+
- Documentation dependencies can be installed with the `docs` group:
83+
```bash
84+
uv sync --dev --group docs --no-install-package datafusion
85+
```
86+
- Build the docs with:
87+
```bash
88+
uv run --no-project maturin develop --uv
89+
uv run --no-project docs/build.sh
90+
```
91+
- The generated HTML appears under `docs/build/html`.

0 commit comments

Comments
 (0)