Skip to content

Latest commit

 

History

History
231 lines (163 loc) · 8.54 KB

CONTRIBUTING.md

File metadata and controls

231 lines (163 loc) · 8.54 KB

Contributing

Introduction

We appreciate your interest in considering contributing to redis-py. Community contributions mean a lot to us.

Contributions we need

You may already know how you'd like to contribute, whether it's a fix for a bug you encountered, or a new feature your team wants to use.

If you don't know where to start, consider improving documentation, bug triaging, and writing tutorials are all examples of helpful contributions that mean less work for you.

Before you start

For anything bigger than a small bug fix, a typo or a docs change, open an issue or a discussion first. Describe the problem and the change you plan. Wait for a maintainer to agree with the approach before you write the code. This avoids work on changes we cannot accept, for example a change that breaks the public API or duplicates work already in progress.

Search the open issues and pull requests first, because someone may already be working on the same thing.

AI-driven contributions

Redis-py defines a set of agent skills that may simplify your contribution by enriching the agent's context with necessary information and repository best practices. Skills are well-structured instructions for common recurring tasks (e.g., adding support for a new Redis command API). They live in .agents/skills/, and .claude/skills links to the same directory. AGENTS.md lists them.

To see or run the available skills:

Claude CLI

claude /skills

Augment CLI

The Augment CLI discovers the same skills from .agents/skills/ and .claude/skills/. See the Augment skills documentation for how to run them.

Your First Contribution

Unsure where to begin contributing? You can start by looking through help-wanted issues.

Never contributed to open source before? Here are a couple of friendly tutorials:

Getting Started

Here's how to get started with your code contribution:

  1. Create your own fork of redis-py

  2. Do the changes in your fork

  3. Create a virtualenv and install the development dependencies from the dev_requirements.txt file:

    python -m venv .venv
    source .venv/bin/activate
    pip install -r dev_requirements.txt
    pip install -e '.[jwt]'
    
  4. If you need a development environment, run invoke devenv. Note: this relies on docker-compose to build environments, and assumes that you have a version supporting docker profiles.

  5. While developing, make sure the tests pass by running invoke tests

  6. If you like the change and think the project could use it, send a pull request

To see what else is part of the automation, run invoke -l

The Development Environment

Running invoke devenv installs the development dependencies specified in the dev_requirements.txt. It starts all of the dockers used by this project, and leaves them running. These can be easily cleaned up with invoke clean. NOTE: it is assumed that the user running these tests, can execute docker and its various commands.

  • A master Redis node
  • A Redis replica node
  • Three sentinel Redis nodes
  • A redis cluster
  • An stunnel docker, fronting the master Redis node

The replica node, is a replica of the master node, using the leader-follower replication feature.

The sentinels monitor the master node in a sentinel high-availability configuration.

Testing

Call invoke tests to run all tests, or invoke all-tests to run linters tests as well. With the 'tests' and 'all-tests' targets, all Redis and RedisCluster tests will be run.

It is possible to run only Redis client tests (with cluster mode disabled) by using invoke standalone-tests; similarly, RedisCluster tests can be run by using invoke cluster-tests.

Each run of tests starts and stops the various dockers required. Sometimes things get stuck, an invoke clean can help.

Linting

Call invoke linters to run linters without also running tests.
Call invoke linters-fix to run linters and automatically fix issues.

Documentation

If relevant, update the code documentation, via docstrings, or in /docs.

You can check how the documentation looks locally by running invoke build-docs and loading the generated HTML files in a browser.

Historically there is a mix of styles in the docstrings, but the preferred way of documenting code is by applying the Google style. Type hints should be added according to PEP484, and should not be repeated in the docstrings.

Docker Tips

Following are a few tips that can help you work with the Docker-based development environment.

To get a bash shell inside of a container:

$ docker run -it <service> /bin/bash

Containers run a minimal Debian image that probably lacks tools you want to use. To install packages, first get a bash session (see previous tip) and then run:

$ apt update && apt install <package>

To follow logs from a development service, run the following from the repository root:

$ docker compose logs -f <service>

For example, docker compose logs -f redis follows the standalone Redis service. The service name comes from docker-compose.yml; docker logs instead expects a container name or ID, such as redis-standalone.

Troubleshooting

If you get any errors when running make dev or make test, make sure that you are using supported versions of Docker.

Please try at least versions of Docker.

  • Docker 19.03.12

How to Report a Bug

Security Vulnerabilities

NOTE: If you find a security vulnerability, do NOT open an issue. Follow the security policy instead.

Everything Else

When filing an issue, make sure to answer these five questions:

  1. What version of redis-py are you using?
  2. What version of redis are you using?
  3. What did you do?
  4. What did you expect to see?
  5. What did you see instead?

Suggest a feature or enhancement

If you'd like to contribute a new feature, make sure you check our issue list to see if someone has already proposed it. Work may already be underway on the feature you want or we may have rejected a feature like it already.

If you don't see anything, open a new issue that describes the feature you would like and how it should work.

Pull request process

  • Title. We squash-merge pull requests, so the PR title becomes the commit message on master. Write it as one sentence in the imperative mood that describes the user-visible change, for example Fix search payloads being dropped on RESP3. A conventional prefix such as fix:, feat: or perf(cluster): is common but optional.
  • Description. Fill in the PR template. Explain what changed and why, and link the issue the PR fixes, for example Fixes #1234.
  • Tests. Every behavior change needs tests. redis-py has a sync and an asyncio client, so a change to one usually needs the same change and the same tests in the other (tests/ and tests/test_asyncio/).
  • Docs. Update docstrings and /docs when you change or add public API.
  • Changelog. You do not need to edit a changelog. Maintainers label each PR, and the release notes are generated from the merged PRs and their labels.
  • Compatibility. We do not ship breaking changes in minor or patch releases. If your change breaks the public API, say so in the description, and expect it to wait for the next major release.

Code review

The core team regularly looks at pull requests. We will provide feedback as soon as possible. Reviewers check that the change is correct, matches Redis semantics, keeps the sync and asyncio clients aligned, does not break the public API, does not hurt performance, and is tested and documented.

After receiving our feedback, please respond within two weeks. After that time, we may close your PR if it isn't showing any activity. Separately, the stale workflow marks issues and pull requests stale after a year without activity and closes them 30 days later. Issues labeled needs-information follow a shorter timeline.

Security and license