agentleFS
apacheapache/ranger/.cursor/rules/ranger-python.mdc

ranger / rules

Cursor rule1.1k starsChanged 3 months agoApache-2.0View on GitHub

Apache Ranger Python client and test conventions (apache-ranger on PyPI)

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

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep changes minimal; follow naming, imports, and spacing of the file you edit.

    line 36
  2. Very specific:

    Use compact dict literals — one line per top-level field when still readable (sample_pdp_client.py).

    line 62
  3. Very specific:

    Prefer assertRaises, assertIsNone, assertIsInstance over bare try/except.

    line 80
  4. Distinctive:

    Only add tests for real coercion, exports, or API wiring.

    line 83

≈ “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
ranger-python.mdc
---
description: Apache Ranger Python client and test conventions (apache-ranger on PyPI)
globs: intg/**/*.py,ranger-examples/sample-client/**/*.py
alwaysApply: false
---

<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

# Ranger Python client (`apache-ranger`)

**Authoritative package root:** `intg/src/main/python/` — packaging via `setup.py` there only. Do not add duplicate `setup.py` scripts elsewhere.

**Python version:** `apache-ranger` targets **Python 3.13+** (`python_requires` in `setup.py`).

## Style and structure

- Preserve the ASF license header on new files (match neighboring modules).
- Match existing layout: `apache_ranger/client/` for HTTP clients, `apache_ranger/model/` for typed models, `utils.py` for coercion helpers.
- Reuse `type_coerce` / `type_coerce_attrs()` — accept dict-like input and coerce to model types; do not duplicate parsing logic.
- Keep changes minimal; follow naming, imports, and spacing of the file you edit.

## Vertical alignment

Within a **consecutive block** of related lines, align `=` (and dict values after `:` where keys share one dict):

```python
self.status_code = status_code
self.response    = response
self.content     = content

from apache_ranger.exceptions           import RangerServiceException
from apache_ranger.model.ranger_service import RangerService

RangerAuthzRequest({
    "requestId": "req-1",
    "user":      RangerUserInfo({"name": "alice"}),
    "access":    RangerAccessInfo({...}),
    "context":   RangerAccessContext({...}),
})
```

Apply alignment only within the block; do not pad unrelated single assignments. Reference points: `exceptions.py`, `sample_pdp_client.py`, `test_ranger_client.py`.

## Model and sample data

Use **compact dict literals** — one line per top-level field when still readable (`sample_pdp_client.py`). Avoid verbose nesting when a flat line is clear.

## Unit tests

Primary test file: `intg/src/test/python/test_ranger_client.py`

Run from `intg/`:

```bash
PYTHONPATH=src/main/python python -B src/test/python/test_ranger_client.py
```

Split tests **by client** — one `unittest.TestCase` per area (`TestRangerClient`, `TestGDSClient`, `TestPDPClient`).

Fixtures: shared data as **class-level constants** (`URL`, `AUTH`, `AUTHZ_REQUEST`); single-use data inline in the test method.

Assertions and mocking:

- Prefer `assertRaises`, `assertIsNone`, `assertIsInstance` over bare `try/except`.
- Assert **current** client behavior — not obsolete error text or exceptions.
- Mock at the boundary: `Session` for Admin HTTP, `client_http.call_api` for GDS/PDP.
- Only add tests for real coercion, exports, or API wiring.

## References

- `intg/src/main/python/README.md` — published API surface and quickstarts
- `ranger-examples/sample-client/src/main/python/` — Admin, GDS, PDP, KMS usage examples

Download now (ZIP)

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 1 mentionApr 2026: 4 mentionsMay 2026: 0 mentionsJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 2 mentionsSep 2026: 1 mentionOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the apache/ranger repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about apache/ranger

The biggest 5 of 33 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 33

Talked about on GitHub and Stack Overflow (33 times).

On GitHub · 28

23 more on GitHub
  • 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 repository2 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.