Skip to content

fix packaging and md syntax issues #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 68 additions & 42 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ If you want to contribute code to `xrpl-py`, the following sections describe how

To make it easy to manage your Python environment with `xrpl-py`, including switching between versions, install `pyenv` and follow these steps:

* Install [`pyenv`](https://github.com/pyenv/pyenv):
- Install [`pyenv`](https://github.com/pyenv/pyenv):

brew install pyenv
```sh
brew install pyenv
```

For other installation options, see the [`pyenv` README](https://github.com/pyenv/pyenv#installation).
For other installation options, see the [`pyenv` README](https://github.com/pyenv/pyenv#installation).

* Use `pyenv` to install the optimized version for `xrpl-py` (currently 3.9.1):
- Use `pyenv` to install the optimized version for `xrpl-py` (currently 3.9.1):

pyenv install 3.9.1
```sh
pyenv install 3.9.1
```

* Set the [global](https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-global) version of Python with `pyenv`:
- Set the [global](https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-global) version of Python with `pyenv`:

pyenv global 3.9.1
```sh
pyenv global 3.9.1
```

### Set up shell environment

Expand All @@ -29,22 +35,40 @@ To enable autocompletion and other functionality from your shell, add `pyenv` to
These steps assume that you're using a [Zsh](http://zsh.sourceforge.net/) shell. For other shells, see the [`pyenv` README](https://github.com/pyenv/pyenv#basic-github-checkout).


* Add `pyenv init` to your Zsh shell:
- Add `pyenv init` to your Zsh shell:

echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
```sh
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
```

* Source or restart your terminal:
- Source or restart your terminal:

. ~/.zshrc
```sh
. ~/.zshrc
```

### Manage dependencies and virtual environments

To simplify managing library dependencies and the virtual environment, `xrpl-py` uses [`poetry`](https://python-poetry.org/docs).

* [Install `poetry`](https://python-poetry.org/docs/#osx-linux-bashonwindows-install-instructions):
- [Install `poetry 1.2.2`](https://python-poetry.org/docs/#installing-with-the-official-installer):

```sh
curl -sSL https://install.python-poetry.org | python3 - --version 1.2.2
```

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
poetry install
**Note**: If you have an old version of poetry installed on your machine, you can run the following commands to completely remove poetry from your machine:

```sh
curl -sSL https://install.python-poetry.org | python3 - --uninstall
```

However, configurations files of an old version of poetry won't be removed by running the previous command. Therefore, you should manually delete them from your machine(in case you are using a linux flavor):

```sh
rm -rf /home/${USER}/.poetry
rm -rf /home/${USER}/.pyenv/shims/poetry
```

### Set up `pre-commit` hooks

Expand All @@ -53,77 +77,79 @@ To run linting and other checks, `xrpl-py` uses [`pre-commit`](https://pre-commi
**Note:** You only need to install `pre-commit` if you want to contribute code to `xrpl-py`.


* Install `pre-commit`:

pip3 install pre-commit
pre-commit install
- Install `pre-commit`:

```sh
pip3 install pre-commit
pre-commit install
```
### Run the linter

To run the linter:

```bash
```sh
poetry run flake8 ./xrpl
```

### Running Tests

#### Individual Tests

```bash
```sh
# Works for single or multiple unit/integration tests
# Ex: poetry run poe test tests/unit/models/test_response.py tests/integration/transactions/test_account_delete.py
poetry run poe test FILE_PATHS
```

#### Unit Tests

```bash
```sh
poetry run poe test_unit
```

#### Integration Tests

To run integration tests, you'll need a standalone rippled node running with WS port `6006` and JSON RPC port `5005`. You can run a docker container for this:
```bash
```sh
docker run -p 5005:5005 -p 6006:6006 -it natenichols/rippled-standalone:latest
```

To actually run the tests:

```bash
```sh
poetry run poe test_integration
```

#### Code Coverage

To run both unit and integration tests and see code coverage:
```bash
```sh
poetry run poe test_coverage
```

To see manually code coverage after running unit tests or integration tests:
```bash
```sh
poetry run coverage report
```

#### Running tests with different Python versions

To switch your python version before running tests:

```bash
```sh
pyenv local 3.9
poetry env use python3.9
poetry install
```

Replace `python3.9` with whatever version of Python you want to use (you must have it installed with `pyenv` for it to work).


## Generate reference docs

You can see the complete reference documentation at [`xrpl-py` docs](https://xrpl-py.readthedocs.io/en/latest/index.html). You can also generate them locally using `poetry` and `sphinx`:

```bash
```sh
# Go to the docs/ folder
cd docs/

Expand All @@ -134,7 +160,7 @@ poetry run make html

To see the output:

```bash
```sh
# Go to docs/_build/html/
cd docs/_build/html/

Expand All @@ -146,10 +172,10 @@ open index.html
1. If adding functionality to a new part of the library, create new file with a class that inherits `IntegrationTestCase` from `tests.integration.integration_test_case` to store all individual tests under (ex: `class TestWallet(IntegrationTestCase)`). Otherwise, add to an existing file.
2. Create an async function for each test case (unless the test is only being used for the sync client)
3. Include the `@test_async_and_sync` decorator to test against all client types, unless you specifically only want to test with one client. You can also use the decorator to:
* Limit tests to sync/async only
* Limit the number of retries
* Use Testnet instead of a standalone network
* Import modules for sync equivalents of any async functions used
- Limit tests to sync/async only
- Limit the number of retries
- Use Testnet instead of a standalone network
- Import modules for sync equivalents of any async functions used
4. Be sure to reuse pre-made values, `WALLET`, `DESTINATION`, `TESTNET_WALLET`, `TESTNET_DESTINATION`, `OFFER`, and `PAYMENT_CHANNEL`, from `tests/integrations/reusable_values.py`
5. Be sure to use condensed functions, like `submit_transaction_async` and `sign_and_reliable_submission_async`, from `tests/integrations/it_utils.py`

Expand All @@ -163,12 +189,12 @@ Use [this repo](https://github.com/RichardAH/xrpl-codec-gen) to generate a new `

### Editing the Code

* Your changes should have unit and/or integration tests.
* Your changes should pass the linter.
* Your code should pass all the unit and integration tests on Github (which check all versions of Python).
* Open a PR against `master` and ensure that all CI passes.
* Get a full code review from one of the maintainers.
* Merge your changes.
- Your changes should have unit and/or integration tests.
- Your changes should pass the linter.
- Your code should pass all the unit and integration tests on GitHub (which check all versions of Python).
- Open a PR against `master` and ensure that all CI passes.
- Get a full code review from one of the maintainers.
- Merge your changes.

### Release

Expand All @@ -181,15 +207,15 @@ Use [this repo](https://github.com/RichardAH/xrpl-codec-gen) to generate a new `
4. Make sure that this local installation works as intended, and that the changes are reflected properly.
4. Run `poetry publish --dry-run` and make sure everything looks good.
5. Publish the update by running `poetry publish`.
* This will require entering PyPI login info.
6. Create a new Github release/tag off of this branch.
- This will require entering PyPI login info.
6. Create a new GitHub release/tag off of this branch.
7. Send an email to [xrpl-announce](https://groups.google.com/g/xrpl-announce).

## Mailing Lists
We have a low-traffic mailing list for announcements of new `xrpl-py` releases. (About 1 email every couple of weeks)

+ [Subscribe to xrpl-announce](https://groups.google.com/g/xrpl-announce)
- [Subscribe to xrpl-announce](https://groups.google.com/g/xrpl-announce)

If you're using the XRP Ledger in production, you should run a [rippled server](https://github.com/ripple/rippled) and subscribe to the ripple-server mailing list as well.

+ [Subscribe to ripple-server](https://groups.google.com/g/ripple-server)
- [Subscribe to ripple-server](https://groups.google.com/g/ripple-server)
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

30 changes: 30 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
[mypy]
mypy_path = xrpl/
exclude = dist
ignore_errors = False
ignore_missing_imports = True
warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True
no_implicit_optional = True
strict_equality = True
strict_concatenate = True

# Strongly recommend enabling this
check_untyped_defs = True

disallow_subclassing_any = False
disallow_untyped_decorators = True
disallow_any_generics = True

# forcing use of type annotations
disallow_untyped_calls = True
disallow_incomplete_defs = True
disallow_untyped_defs = True

no_implicit_reexport = True

strict = True
warn_return_any = False

# This fix mypy confusion between module_name and xrpl.module_name
explicit_package_bases = True
namespace_packages = True
Loading