Skip to content

Commit

Permalink
Update contributing guidelines in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel1rf committed May 4, 2024
1 parent 336a16c commit 94b8f20
Showing 1 changed file with 100 additions and 27 deletions.
127 changes: 100 additions & 27 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ poker hands.

The library requires Python 3.

- from release on PyPI
* from release on PyPI

```shell
pip install phevaluator
```
```shell
pip install phevaluator
```

- from source code
* from source code

```shell
pip install .
```
```shell
pip install .
```

## Using the library

Expand All @@ -51,37 +51,110 @@ The function can take both numbers and card strings (with a format like: 'Ah' or

## Test

- The pre-calculated tables (`phevaluator.tables`) are tested by comparing them
* The pre-calculated tables (`phevaluator.tables`) are tested by comparing them
with the tables generated by test codes.
- The functionality of the evaluators is tested by comparing with the JSON files
* The functionality of the evaluators is tested by comparing with the JSON files
generated by the original C++ evaluator.
- The functionality of the other modules is tested by its purposes.
* The functionality of the other modules is tested by its purposes.

```shell
python3 -m unittest discover -v
```

## Development
## Contributing

- install from source code with `editable mode`
Thank you for your interest in contributing to the Python package of PHEvaluator!
To ensure a smooth contribution process, please follow the guidelines below.

```shell
pip install -e .
```
### Requirements

The installed package reflects changes to files inside the `phevaluator`
folder automatically.
* Python 3.8
* [Ruff](https://docs.astral.sh/ruff/) for linting and formatting
* [mypy](https://mypy-lang.org/) for type checking

- recommended to format with [`black`](https://github.com/psf/black) before commit
### Code style

check where to correct (without formatting)
* Follow the [Black code style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html).
* Write type hints following [PEP 484](https://www.python.org/dev/peps/pep-0484/).
* Include docstrings following [PEP 257](https://www.python.org/dev/peps/pep-0257/).
* Lint and format code using `Ruff`.

```shell
black . --diff --color
```
### Development Setup

format all
#### Option 1: Setup with pre-commit (recommended)

```shell
black .
```
* Install `pre-commit`:

```shell
pip install pre-commit
```

* Install `pre-commit` hooks:

```shell
pre-commit install
```

#### Option 2: Setup without pre-commit

* Install `Ruff`:

```shell
pip install ruff
```

* Install `mypy`:

```shell
pip install mypy
```

### Checking Changes

You can install the package from the source code in `editable` mode:

```shell
pip install -e .
```

This allows the installed package to automatically reflect changes made in the `phevaluator`
folder.

### Committing Changes

The configurations for Ruff and mypy can be found in [pyproject.toml](pyproject.toml).

#### Option 1: Commit with pre-commit

When you commit your changes, `pre-commit` will automatically run the linters, formatters,
type checker, and unit tests.

#### Option 2: Commit without pre-commit

* Lint code with `Ruff`:

```shell
ruff check
```

* Format code with `Ruff`:

```shell
ruff format
```

* Type check with `mypy`:

```shell
mypy .
```

* Run unit tests:

```shell
python3 -m unittest discover -v
```

Please ensure that your code passes all the checks and tests before submitting a
pull request. If you have any questions, need further assistance, or want to report
a bug or suggest an enhancement, feel free to [open an issue](https://github.com/HenryRLee/PokerHandEvaluator/issues).

0 comments on commit 94b8f20

Please sign in to comment.