agentleFS
MigoXLabMigoXLab/dingo/.cursor/rules/python-conventions.mdc

dingo / rules

Cursor rule757 starsChanged 7 months agoApache-2.0View on GitHub

Python coding conventions for the Dingo SDK

  • Installs packages

We split this python-conventions.mdc into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow PEP 8 (enforced by pre-commit hooks)

    line 13
  2. Distinctive:

    Use type hints for function signatures

    line 14
  3. Very specific:

    Use @classmethod for evaluator eval() methods

    line 15
  4. Very specific:

    Prefer getattr(obj, 'field', default) over direct attribute access for optional Data fields

    line 16
  5. Very specific:

    Use log.warning() / log.error() from dingo.utils for logging

    line 75
  6. Very specific:

    Test files: test/scripts/ mirroring dingo/ structure

    line 80
  7. Distinctive:

    Use pytest fixtures and parametrize for multiple test cases

    line 81
  8. Very specific:

    Test data in test/data/

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
python-conventions.mdc
---
description: Python coding conventions for the Dingo SDK
globs:
  - dingo/**/*.py
  - mcp_server.py
  - test/**/*.py
---

# Python Conventions

## Code Style

- Follow PEP 8 (enforced by pre-commit hooks)
- Use type hints for function signatures
- Use `@classmethod` for evaluator `eval()` methods
- Prefer `getattr(obj, 'field', default)` over direct attribute access for optional Data fields

## Import Rules

- **Core deps** (numpy, pydantic, requests, etc.): top-level imports OK
- **Optional deps** (pyarrow, transformers, boto3, sqlalchemy, cv2, fasttext, etc.): **must** use lazy imports inside methods with clear `ImportError` messages:

```python
# Correct — lazy import with helpful error
def load_data(self):
    try:
        import pyarrow.parquet as pq
    except ImportError:
        raise ImportError("pyarrow is required for Parquet support. Install: pip install dingo-python[parquet]")

# Wrong — top-level import of optional dep
import pyarrow.parquet as pq
```

## Evaluator Patterns

### Rule Evaluator

```python
@Model.rule_register('QUALITY_BAD_CATEGORY', ['default', 'pretrain'])
class RuleMyCheck(BaseRule):
    _required_fields = [RequiredField.CONTENT]

    @classmethod
    def eval(cls, input_data: Data) -> EvalDetail:
        res = EvalDetail(metric=cls.__name__)
        # evaluation logic
        if problem_found:
            res.status = True
            res.label = [f"{cls.metric_type}.{cls.__name__}"]
            res.reason = ["Description of the issue"]
        else:
            res.label = [QualityLabel.QUALITY_GOOD]
        return res
```

### LLM Evaluator

```python
@Model.llm_register('LLMMyEvaluator')
class LLMMyEvaluator(BaseOpenAI):
    prompt = """Your evaluation prompt here..."""

    @classmethod
    def build_messages(cls, input_data: Data) -> List:
        return [
            {'role': 'system', 'content': cls.prompt},
            {'role': 'user', 'content': input_data.content}
        ]
```

## Error Handling

- Evaluators should not raise exceptions for bad input data; return `EvalDetail` with appropriate error label instead
- Use `log.warning()` / `log.error()` from `dingo.utils` for logging
- External API calls: always handle timeouts and connection errors

## Testing

- Test files: `test/scripts/` mirroring `dingo/` structure
- Use pytest fixtures and parametrize for multiple test cases
- Test data in `test/data/`

Download now (ZIP)

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository7 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.