Skip to content

Commit 63aface

Browse files
authored
Merge branch 'main' into definitions-generation
2 parents 98c267d + a12b672 commit 63aface

File tree

16 files changed

+247
-29
lines changed

16 files changed

+247
-29
lines changed

.darglint

Lines changed: 0 additions & 4 deletions
This file was deleted.

.flake8

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ ignore = D205,D212,D415,E203,W503
1111
# https://black.readthedocs.io/en/stable/the_black_code_style.html#line-length
1212
max-line-length = 88
1313

14+
# This is for pydocstyle - to allow docstrings in __init__ functions
15+
# This rule was used for easier migration from darglint
16+
# TODO: remove this rule
17+
allow-init-docstring=True
18+
1419
per-file-ignores =
1520
# For tests, disable type annotation and docstring linting.
16-
tests/*: ANN D DAR
21+
tests/*: ANN D DOC
1722

1823
# Select other tools to enable.
1924

@@ -25,7 +30,7 @@ per-file-ignores =
2530

2631
# D enables docstrings warnings from pydocstyle.
2732

28-
# DAR enables docstring style linting via darglint.
33+
# DOC enables docstring style linting via pydoclint.
2934

3035
# F are errors reported by pyflakes, a tool which parses source files
3136
# and finds invalid Python code.
@@ -35,4 +40,4 @@ per-file-ignores =
3540

3641
# W and E are warnings and errors reported by pycodestyle, which checks
3742
# your Python code against some of the style conventions in PEP 8.
38-
select = ABS,ANN,DAR,BLK,D,E,F,I,W
43+
select = ABS,ANN,DOC,BLK,D,E,F,I,W

.github/workflows/unit_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
- name: Lint
5151
run: |
52-
poetry run flake8 xrpl tests snippets --darglint-ignore-regex="^_(.*)"
52+
poetry run poe lint
5353
5454
- name: Type-check
5555
run: |

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
types: [python]
2222
- id: flake8
2323
name: flake8
24-
entry: poetry run flake8 --darglint-ignore-regex="^_(.*)"
24+
entry: poetry run flake8
2525
language: system
2626
types: [python]
2727
- id: mypy

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
- Add `nfts_by_issuer` clio-only API definition
4444
- Included `ctid` field in the `tx` request.
4545
- `from_xrpl` method accepts input dictionary keys exclusively in the proper XRPL format.
46+
- Support for DynamicNFT amendment (XLS-46)
4647

4748
### Fixed
4849
- Added support for `XChainModifyBridge` flag maps (fixing an issue with `NFTokenCreateOffer` flag names)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ To run linting and other checks, `xrpl-py` uses [`pre-commit`](https://pre-commi
6666
To run the linter:
6767

6868
```bash
69-
poetry run flake8 xrpl tests --darglint-ignore-regex="^_(.*)"
69+
poetry run poe lint
7070
```
7171

7272
### Running Tests

poetry.lock

Lines changed: 50 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ base58 = "^2.1.0"
2828
ECPy = "^1.2.5"
2929
typing-extensions = "^4.2.0"
3030
httpx = ">=0.18.1,<0.29.0"
31-
websockets = ">=11,<14"
31+
websockets = ">=11"
3232
Deprecated = "^1.2.13"
3333
types-Deprecated = "^1.2.9"
3434
pycryptodome = "^3.16.0"
@@ -43,7 +43,10 @@ isort = "^5.11.5"
4343
flake8-isort = "^6.0.0"
4444
flake8-annotations = "^3.1.1"
4545
flake8-absolute-import = "^1.0"
46-
darglint = "^1.5.8"
46+
pydoclint = [
47+
{ version = "<=0.5.12", python = "<3.9" },
48+
{ version = "^0.5.13", python = ">=3.9" }
49+
]
4750
sphinx-rtd-theme = "^3.0.2"
4851
aiounittest = "^1.4.0"
4952
coverage = "^7.2.7"
@@ -74,6 +77,7 @@ precision = 2
7477
[tool.poe.tasks]
7578
test_unit = "coverage run -m unittest discover tests/unit"
7679
test_integration = "coverage run -m unittest discover tests/integration"
80+
lint = "poetry run flake8 xrpl tests snippets"
7781

7882
[tool.poe.tasks.test]
7983
cmd = "python3 -m unittest ${FILE_PATHS}"

tests/unit/models/transactions/test_better_transaction_flags.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def test_nftoken_mint_flags(self):
8787
TF_ONLY_XRP=True,
8888
TF_TRANSFERABLE=True,
8989
TF_TRUSTLINE=True,
90+
TF_MUTABLE=True,
9091
),
9192
)
9293
self.assertTrue(actual.has_flag(flag=0x00000001))
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from unittest import TestCase
2+
3+
from xrpl.models.exceptions import XRPLModelException
4+
from xrpl.models.transactions.nftoken_modify import NFTokenModify
5+
6+
_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ"
7+
_SEQUENCE = 19048
8+
_FEE = "0.00001"
9+
_URI = "ABC"
10+
_NFTOKEN_ID = "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003"
11+
12+
13+
class TestNFTokenModify(TestCase):
14+
def test_nftoken_miss(self):
15+
with self.assertRaises(XRPLModelException) as error:
16+
NFTokenModify(
17+
account=_ACCOUNT,
18+
owner=_ACCOUNT,
19+
sequence=_SEQUENCE,
20+
fee=_FEE,
21+
uri=_URI,
22+
)
23+
self.assertEqual(
24+
error.exception.args[0],
25+
"{'nftoken_id': 'nftoken_id is not set'}",
26+
)
27+
28+
def test_uri_empty(self):
29+
with self.assertRaises(XRPLModelException) as error:
30+
NFTokenModify(
31+
account=_ACCOUNT,
32+
owner=_ACCOUNT,
33+
sequence=_SEQUENCE,
34+
fee=_FEE,
35+
nftoken_id=_NFTOKEN_ID,
36+
uri="",
37+
)
38+
self.assertEqual(
39+
error.exception.args[0],
40+
"{'uri': 'URI must not be empty string'}",
41+
)
42+
43+
def test_uri_too_long(self):
44+
with self.assertRaises(XRPLModelException) as error:
45+
NFTokenModify(
46+
account=_ACCOUNT,
47+
owner=_ACCOUNT,
48+
sequence=_SEQUENCE,
49+
fee=_FEE,
50+
nftoken_id=_NFTOKEN_ID,
51+
uri=_URI * 1000,
52+
)
53+
self.assertEqual(
54+
error.exception.args[0],
55+
"{'uri': 'URI must not be longer than 512 characters'}",
56+
)
57+
58+
def test_uri_not_hex(self):
59+
with self.assertRaises(XRPLModelException) as error:
60+
NFTokenModify(
61+
account=_ACCOUNT,
62+
owner=_ACCOUNT,
63+
sequence=_SEQUENCE,
64+
fee=_FEE,
65+
nftoken_id=_NFTOKEN_ID,
66+
uri="not-hex-encoded",
67+
)
68+
self.assertEqual(
69+
error.exception.args[0],
70+
"{'uri': 'URI must be encoded in hex'}",
71+
)
72+
73+
def test_valid(self):
74+
obj = NFTokenModify(
75+
account=_ACCOUNT,
76+
owner=_ACCOUNT,
77+
sequence=_SEQUENCE,
78+
fee=_FEE,
79+
uri=_URI,
80+
nftoken_id=_NFTOKEN_ID,
81+
)
82+
self.assertTrue(obj.is_valid())

0 commit comments

Comments
 (0)