## [v1.0.0](https://git.duniter.org/clients/python/duniterpy/-/milestones/12) (21st August 2021)
## [v1.0.0](https://git.duniter.org/clients/python/duniterpy/-/milestones/12) (21st August 2021)
**See below the main changes for the v1.0**
**See below the main changes for the v1.0**
No changes since the rc1.
No changes since the rc1.
## [v1.0.0rc1](https://git.duniter.org/clients/python/duniterpy/-/milestones/12) (25th July 2021)
## [v1.0.0rc1](https://git.duniter.org/clients/python/duniterpy/-/milestones/12) (25th July 2021)
**See below the main changes for the v1.0**
**See below the main changes for the v1.0**
### Fixes
### Fixes
- #152, #170, !159: Fix `ESUserEndpoint` regex
- #152, #170, !159: Fix `ESUserEndpoint` regex
- Fix datapod domain name in `request_data_elasticsearch` example
- Fix datapod domain name in `request_data_elasticsearch` example
### Development Environment
### Development Environment
- #149, !161: Change workflow by changing from `master` and default `dev` branches to a single `main` branch
- #149, !161: Change workflow by changing from `master` and default `dev` branches to a single `main` branch
- Add changelog link to PyPI
- Add changelog link to PyPI
### Documentation
### Documentation
- !160: Fix autodoc generation by running it into Poetry virtualenv
- !160: Fix autodoc generation by running it into Poetry virtualenv
- !158: Allow to trigger the documentation job without having the release stage completed
- !158: Allow to trigger the documentation job without having the release stage completed
...
@@ -47,11 +55,14 @@ TL;DR: The key changes are the `Documents` refactoring, the removal of the async
...
@@ -47,11 +55,14 @@ TL;DR: The key changes are the `Documents` refactoring, the removal of the async
The inclusion of the examples into the package, and the introduction of `pre-commit` tool for development purposes.
The inclusion of the examples into the package, and the introduction of `pre-commit` tool for development purposes.
### This release breaks backward compatibility!
### This release breaks backward compatibility!
From this version, only major releases might break backward compatibility.
From this version, only major releases might break backward compatibility.
For 1.x minor versions, only `DeprecationWarning` will occur.
For 1.x minor versions, only `DeprecationWarning` will occur.
### Features
### Features
#### Documents refactoring
#### Documents refactoring
Major refactoring have been done on `Document` and its sub-classes.
Major refactoring have been done on `Document` and its sub-classes.
All documents are now internally using a `signature` attribute which is a string and no longer a list of strings, except for the `Transaction` document which can handle multi-signatures.
All documents are now internally using a `signature` attribute which is a string and no longer a list of strings, except for the `Transaction` document which can handle multi-signatures.
It is no longer possible to pass the `signature` as argument at instantiation since it doesn’t make sense in the document life cycle.
It is no longer possible to pass the `signature` as argument at instantiation since it doesn’t make sense in the document life cycle.
...
@@ -60,21 +71,31 @@ The document version and the currency arguments are now set optional and default
...
@@ -60,21 +71,31 @@ The document version and the currency arguments are now set optional and default
The methods to check the signature·s have been moved as specific methods into the documents classes.
The methods to check the signature·s have been moved as specific methods into the documents classes.
- #95, !144: Remove `signatures` argument from all `__init__()`’s documents subclasses:
- #95, !144: Remove `signatures` argument from all `__init__()`’s documents subclasses:
-`Document` constructor is `Document(version: int, currency: str)`
-`Document` constructor is `Document(version: int, currency: str)`
- All `Document` subclasses can be directly signed when the optional `signing_key` argument is passed
- All `Document` subclasses can be directly signed when the optional `signing_key` argument is passed
- #172 `version` argument is now optional and have a proper default value per document type
- #172 `version` argument is now optional and have a proper default value per document type
-`currency` argument is now optional and defaults to `G1_CURRENCY_CODENAME`
-`currency` argument is now optional and defaults to `G1_CURRENCY_CODENAME`
```
signing_key: SigningKey = None,
signing_key: SigningKey = None,
version: int = VERSION,
version: int = VERSION,
currency: str = G1_CURRENCY_CODENAME,
currency: str = G1_CURRENCY_CODENAME,
```
- Introduce `Identity.from_bma_lookup_response()` to simplify examples
- Introduce `Identity.from_bma_lookup_response()` to simplify examples
- Refactor `Document.signatures``List` as `Document.signature``str`
- Refactor `Document.signatures``List` as `Document.signature``str`
-`VerifyingKey.verify_document()` has been removed in favour of `Document.check_signature(pubkey)`
-`VerifyingKey.verify_document()` has been removed in favour of `Document.check_signature(pubkey)`
- Set `time` argument optional in `SimpleTransaction`
- Set `time` argument optional in `SimpleTransaction`
- #173, !150, !156: Make Transaction easier with single and multi-sign:
- #173, !150, !156: Make Transaction easier with single and multi-sign:
-`Transaction(signing_keys: Optional[Union[SigningKey, List[SigningKey]]] = None)` allows single signature or multi-signatures when created
-`Transaction(signing_keys: Optional[Union[SigningKey, List[SigningKey]]] = None)` allows single signature or multi-signatures when created
-`Transaction.sign()` and `multi_sign()` now append signature to allow different key owner to sign additionally the Tx doc
-`Transaction.sign()` and `multi_sign()` now append signature to allow different key owner to sign additionally the Tx doc
- Introduce `Transaction.check_signature()` and `check_signatures()`
- Introduce `Transaction.check_signature()` and `check_signatures()`
...
@@ -82,6 +103,7 @@ The methods to check the signature·s have been moved as specific methods into t
...
@@ -82,6 +103,7 @@ The methods to check the signature·s have been moved as specific methods into t
- #178, !152: `Membership`: Make `membership_type` argument optional defaulting to `IN`
- #178, !152: `Membership`: Make `membership_type` argument optional defaulting to `IN`
- #175, !155: Rename `timestamp` and `blockstamp` attributes and arguments depending on their content:
- #175, !155: Rename `timestamp` and `blockstamp` attributes and arguments depending on their content:
-`timestamp` for time in seconds
-`timestamp` for time in seconds
-`block_id` for `BlockID` type
-`block_id` for `BlockID` type
-`BlockUID` has been renamed to `BlockID` and `BlockID.block_uid()` to `get_block_id()`
-`BlockUID` has been renamed to `BlockID` and `BlockID.block_uid()` to `get_block_id()`
...
@@ -89,6 +111,7 @@ The methods to check the signature·s have been moved as specific methods into t
...
@@ -89,6 +111,7 @@ The methods to check the signature·s have been moved as specific methods into t
- #163, !137: `Revocation.from_signed_raw()` now stores the block ID into a `BlockID` object
- #163, !137: `Revocation.from_signed_raw()` now stores the block ID into a `BlockID` object
#### Network
#### Network
The asynchronous property has been dropped to improve DuniterPy accessibility to new comers.
The asynchronous property has been dropped to improve DuniterPy accessibility to new comers.
Improvements have been made on the endpoints handling.
Improvements have been made on the endpoints handling.
...
@@ -104,11 +127,13 @@ Improvements have been made on the endpoints handling.
...
@@ -104,11 +127,13 @@ Improvements have been made on the endpoints handling.
- !138: Add `flags` and `path` attributes into `GVAEndpoint.eq()` and `hash()` computations
- !138: Add `flags` and `path` attributes into `GVAEndpoint.eq()` and `hash()` computations
#### Key handling
#### Key handling
- #150, !130: Introduce DUBP Mnemonic SigningKey feature with `SigningKey.from_dubp_mnemonic()`
- #150, !130: Introduce DUBP Mnemonic SigningKey feature with `SigningKey.from_dubp_mnemonic()`
- #161, !142: Add DUBP Mnemonic example
- #161, !142: Add DUBP Mnemonic example
- #181, !154: `CRCPubkey` class moved from `documents` to `key` package
- #181, !154: `CRCPubkey` class moved from `documents` to `key` package
#### Others
#### Others
- #160, !134: Include `examples` into the Python package:
- #160, !134: Include `examples` into the Python package:
- They can be run into Python shell
- They can be run into Python shell
- Read new examples usage documentation in the [README.md](README.md#Examples)
- Read new examples usage documentation in the [README.md](README.md#Examples)
...
@@ -116,6 +141,7 @@ Improvements have been made on the endpoints handling.
...
@@ -116,6 +141,7 @@ Improvements have been made on the endpoints handling.
- !147: Update `websocket-client` and `attrs` to major releases
- !147: Update `websocket-client` and `attrs` to major releases
### Development Environment
### Development Environment
`pre-commit` tool has been introduce to run our development tools as pre-commit hooks to check when committing a change.
`pre-commit` tool has been introduce to run our development tools as pre-commit hooks to check when committing a change.
`isort`, a tool that sorts the imports automatically, has been introduced.
`isort`, a tool that sorts the imports automatically, has been introduced.
...
@@ -127,15 +153,17 @@ Improvements have been made on the endpoints handling.
...
@@ -127,15 +153,17 @@ Improvements have been made on the endpoints handling.
- !132: Add support `pylint` v2.8.0
- !132: Add support `pylint` v2.8.0
#### CI/CD
#### CI/CD
- #166, !140: Fix MR based pipelines which do not trigger the tools jobs when there is a code change
- #166, !140: Fix MR based pipelines which do not trigger the tools jobs when there is a code change
- #169, !146: Fix with a token for `gitlab-ci-lint` hook, which was no longer working since GitLab CI lint API requires authentication
- #169, !146: Fix with a token for `gitlab-ci-lint` hook, which was no longer working since GitLab CI lint API requires authentication
- #177: Run `pre-commit` into tools jobs
- #177: Run `pre-commit` into tools jobs
### Fixes
### Fixes
- #134, !141: Fix license header showed into the documentation by using `#` comments rather than docstrings
- #134, !141: Fix license header showed into the documentation by using `#` comments rather than docstrings
Create and push a feature or bugfix release out of the `main` branch.
Create and push a feature or bugfix release out of the `main` branch.
Name this branch after the ticket number `###`.
Name this branch after the ticket number `###`.
Open a merge request out of this branch to the `main` branch:
Open a merge request out of this branch to the `main` branch:
```bash
```bash
main <− ###_feature_branch
main <− ###_feature_branch
```
```
## Pre-commit
## Pre-commit
We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing.
We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing.
We are using it for `black` formatting, `isort` imports sorting, `pylint` code linting, `pyupgrade` syntax upgrader, `mypy` typing, and `gitlab-ci` linting.
We are using it for `black` formatting, `isort` imports sorting, `pylint` code linting, `pyupgrade` syntax upgrader, `mypy` typing, and `gitlab-ci` linting.
Install `pre-commit` from your distribution. In case it is an outdated version, install it from `pip`:
Install `pre-commit` from your distribution. In case it is an outdated version, install it from `pip`:
```bash
```bash
sudo apt install pre-commit
sudo apt install pre-commit
pip install--user pre-commit
pip install--user pre-commit
```
```
To install the `git-hooks`, run:
To install the `git-hooks`, run:
```bash
```bash
duniterpy> pre-commit install
duniterpy> pre-commit install
```
```
Then each time you commit changes, the hooks will perform checks.
Then each time you commit changes, the hooks will perform checks.
To manually run one of the tool above, run (eg for `isort`):
To manually run one of the tool above, run (eg for `isort`):
```bash
```bash
duniterpy> pre-commit run --all-files isort
duniterpy> pre-commit run --all-files isort
```
```
To run all checks on all files:
To run all checks on all files:
```bash
```bash
duniterpy> pre-commit run -a
duniterpy> pre-commit run -a
```
```
### Authorization for GitLab CI linter hook
### Authorization for GitLab CI linter hook
`pre-commit run -a (gitlab-ci-linter)` is failing due to authorization required for CI lint API accesses.
`pre-commit run -a (gitlab-ci-linter)` is failing due to authorization required for CI lint API accesses.
When running this command, just ignore this failed hook.
When running this command, just ignore this failed hook.
In case you want to commit a `.gitlab-ci.yml` edition, this hook will prevent the commit creation.
In case you want to commit a `.gitlab-ci.yml` edition, this hook will prevent the commit creation.
You can [skip the hooks](https://stackoverflow.com/a/7230886) with `git commit -m "msg" --no-verify`.
You can [skip the hooks](https://stackoverflow.com/a/7230886) with `git commit -m "msg" --no-verify`.
This is fine for occasional `.gitlab-ci.yml` editions. In case you would like to edit this file more often and have it checked, ask a maintainer to provide you with `GITLAB_PRIVATE_TOKEN` environment variable that can be set into a shell configuration.
This is fine for occasional `.gitlab-ci.yml` editions. In case you would like to edit this file more often and have it checked, ask a maintainer to provide you with `GITLAB_PRIVATE_TOKEN` environment variable that can be set into a shell configuration.
With Bash, in `$HOME/.bashrc` add the following:
With Bash, in `$HOME/.bashrc` add the following:
```bash
```bash
export GITLAB_PRIVATE_TOKEN=""
export GITLAB_PRIVATE_TOKEN=""
```
```
With Fish, in `$HOME/.config/fish/config.fish` add the following:
With Fish, in `$HOME/.config/fish/config.fish` add the following:
```fish
```fish
set -xg GITLAB_PRIVATE_TOKEN ""
set -xg GITLAB_PRIVATE_TOKEN ""
```
```
Check out #169 for more details.
Check out #169 for more details.
### Black formatting
### Black formatting
We are using [Black](https://github.com/psf/black) formatter tool.
We are using [Black](https://github.com/psf/black) formatter tool.
Run Black on a Python file to format it:
Run Black on a Python file to format it:
```bash
```bash
poetry run black duniterpy/file.py
poetry run black duniterpy/file.py
```
```
With `pre-commit`, Black is called on staged files, so the commit should fail in case black would make changes.
With `pre-commit`, Black is called on staged files, so the commit should fail in case black would make changes.
You will have to add Black changes in order to commit your changes.
You will have to add Black changes in order to commit your changes.
## Tests
## Tests
We are using [`pytest` framework](https://docs.pytest.org/).
We are using [`pytest` framework](https://docs.pytest.org/).
- Run all tests with:
- Run all tests with:
```bash
```bash
duniterpy> poetry run pytest
duniterpy> poetry run pytest
```
```
- Run specific tests by specifying the path to a file:
- Run specific tests by specifying the path to a file:
```bash
```bash
duniterpy> poetry run pytest tests/helpers/test_ws2p.py
duniterpy> poetry run pytest tests/helpers/test_ws2p.py
```
```
- You can even specify a test from the selected file:
- You can even specify a test from the selected file:
```bash
```bash
duniterpy> poetry run pytest tests/helpers/test_ws2p.py::test_generate_ws2p_endpoint
duniterpy> poetry run pytest tests/helpers/test_ws2p.py::test_generate_ws2p_endpoint