Skip to content

Commit 6b4ac7f

Browse files
committed
fix: linting via black
1 parent 0eedb6d commit 6b4ac7f

5 files changed

Lines changed: 70 additions & 51 deletions

File tree

bitshares/aio/price.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ def __repr__(self):
259259

260260

261261
class UpdateCallOrder(Price):
262-
""" This class inherits :class:`bitshares.price.Price` but has the ``base``
263-
and ``quote`` Amounts not only be used to represent the **call
264-
price** (as a ratio of base and quote).
262+
"""This class inherits :class:`bitshares.price.Price` but has the ``base``
263+
and ``quote`` Amounts not only be used to represent the **call
264+
price** (as a ratio of base and quote).
265265
266-
:param bitshares.aio.bitshares.BitShares blockchain_instance: BitShares instance
266+
:param bitshares.aio.bitshares.BitShares blockchain_instance: BitShares instance
267267
"""
268268

269269
async def __init__(self, call, **kwargs):

bitshares/bitshares.py

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ def htlc_create(
15661566
self,
15671567
amount,
15681568
to,
1569-
*args, # force remaining args to be named not positional
1569+
*args, # force remaining args to be named not positional
15701570
hash_type=None,
15711571
hash_hex=None,
15721572
expiration=60 * 60,
@@ -1575,7 +1575,8 @@ def htlc_create(
15751575
account=None,
15761576
**kwargs
15771577
):
1578-
"""Create an HTLC contract.
1578+
"""
1579+
Create an HTLC contract.
15791580
15801581
:param Amount amount: Amount to lock
15811582
:param str to: Recipient
@@ -1634,9 +1635,9 @@ def htlc_create(
16341635
elif hash_type == "sha256":
16351636
preimage_hash = hashlib.sha256(bytes(preimage, "utf-8")).hexdigest()
16361637
elif hash_type == "hash160":
1637-
preimage_hash = hexlify(ripemd160(
1638-
hashlib.sha256(bytes(preimage, "utf-8")).hexdigest()
1639-
)).decode("ascii")
1638+
preimage_hash = hexlify(
1639+
ripemd160(hashlib.sha256(bytes(preimage, "utf-8")).hexdigest())
1640+
).decode("ascii")
16401641
elif hash_hex is not None:
16411642
preimage_hash = hexlify(bytes.fromhex(hash_hex)).decode("ascii")
16421643
preimage_size = preimage_length
@@ -1657,9 +1658,9 @@ def htlc_create(
16571658
)
16581659
return self.finalizeOp(op, account, "active", **kwargs)
16591660

1660-
16611661
def htlc_redeem(self, htlc_id, preimage, encoding="utf-8", account=None, **kwargs):
1662-
"""Redeem an htlc contract
1662+
"""
1663+
Redeem an htlc contract.
16631664
16641665
:param str preimage: The preimage that unlocks the htlc
16651666
:param str encoding: "utf-8", ..., or "hex"
@@ -1674,7 +1675,7 @@ def htlc_redeem(self, htlc_id, preimage, encoding="utf-8", account=None, **kwarg
16741675
account = htlc["to"]
16751676
account = Account(account, blockchain_instance=self)
16761677

1677-
if encoding=="hex":
1678+
if encoding == "hex":
16781679
preimage_hex = hexlify(bytes.fromhex(preimage)).decode("ascii")
16791680
else:
16801681
preimage_hex = hexlify(bytes(preimage, encoding)).decode("ascii")
@@ -1690,9 +1691,9 @@ def htlc_redeem(self, htlc_id, preimage, encoding="utf-8", account=None, **kwarg
16901691
)
16911692
return self.finalizeOp(op, account, "active", **kwargs)
16921693

1693-
16941694
def create_voting_ticket(self, target_type, amount_to_lock, account=None, **kwargs):
1695-
""" Create a voting ticket
1695+
"""
1696+
Create a voting ticket.
16961697
16971698
:param int,str target_type: Lock period target. Should be a string from
16981699
operations.ticket_type_strings or the index of the intended
@@ -1723,10 +1724,11 @@ def create_voting_ticket(self, target_type, amount_to_lock, account=None, **kwar
17231724
)
17241725
return self.finalizeOp(op, account, "active", **kwargs)
17251726

1726-
1727-
def update_voting_ticket(self, ticket_id, new_target_type, amount_to_update,
1728-
account=None, **kwargs):
1729-
"""Update a voting ticket
1727+
def update_voting_ticket(
1728+
self, ticket_id, new_target_type, amount_to_update, account=None, **kwargs
1729+
):
1730+
"""
1731+
Update a voting ticket.
17301732
17311733
:param str ticket_id: Id (e.g. "1.18.xxx") of the ticket to update.
17321734
@@ -1751,7 +1753,7 @@ def update_voting_ticket(self, ticket_id, new_target_type, amount_to_update,
17511753
elif amount_to_update is not None:
17521754
raise ValueError("'amount_to_update' must be of type Amount or None")
17531755
else:
1754-
pass # None is a valid value for optional field
1756+
pass # None is a valid value for optional field
17551757

17561758
op = operations.Ticket_update_operation(
17571759
**{
@@ -1765,11 +1767,18 @@ def update_voting_ticket(self, ticket_id, new_target_type, amount_to_update,
17651767
)
17661768
return self.finalizeOp(op, account, "active", **kwargs)
17671769

1768-
1769-
def create_liquidity_pool(self, asset_a, asset_b, share_asset,
1770-
taker_fee_percent, withdrawal_fee_percent,
1771-
account=None, **kwargs):
1772-
"""Create a liquidity pool
1770+
def create_liquidity_pool(
1771+
self,
1772+
asset_a,
1773+
asset_b,
1774+
share_asset,
1775+
taker_fee_percent,
1776+
withdrawal_fee_percent,
1777+
account=None,
1778+
**kwargs
1779+
):
1780+
"""
1781+
Create a liquidity pool.
17731782
17741783
:param str asset_a: First asset in the pool pair.
17751784
:param str asset_b: Second asset in the pool pair.
@@ -1785,7 +1794,6 @@ def create_liquidity_pool(self, asset_a, asset_b, share_asset,
17851794
For percentages, meaningful range is [0.00, 100.00], where 1% is
17861795
represented as 1.0. Smallest non-zero value recognized by BitShares
17871796
chain is 0.01 for 0.01%.
1788-
17891797
"""
17901798
if not account:
17911799
if "default_account" in self.config:
@@ -1798,9 +1806,9 @@ def create_liquidity_pool(self, asset_a, asset_b, share_asset,
17981806
asset_b = Asset(asset_b)["id"]
17991807
share_asset = Asset(share_asset)["id"]
18001808

1801-
if not (taker_fee_percent >=0 and taker_fee_percent <= 100):
1809+
if not (taker_fee_percent >= 0 and taker_fee_percent <= 100):
18021810
raise ValueError("Percentages must be in range [0.00, 100.00].")
1803-
if not (withdrawal_fee_percent >=0 and withdrawal_fee_percent <= 100):
1811+
if not (withdrawal_fee_percent >= 0 and withdrawal_fee_percent <= 100):
18041812
raise ValueError("Percentages must be in range [0.00, 100.00].")
18051813
graphene_1_percent = 100
18061814
taker_fee_percent = int(taker_fee_percent * graphene_1_percent)
@@ -1820,7 +1828,6 @@ def create_liquidity_pool(self, asset_a, asset_b, share_asset,
18201828
)
18211829
return self.finalizeOp(op, account, "active", **kwargs)
18221830

1823-
18241831
def _find_liquidity_pool(self, pool):
18251832
# Ad-hoc helper for the liquidity pool verbs. It locates a pool id
18261833
# irrespective of whether 'pool' is already a pool id, or perhaps an
@@ -1842,14 +1849,13 @@ def _find_liquidity_pool(self, pool):
18421849
raise ValueError("Asset is not a share asset for a pool.")
18431850
return pool_id
18441851

1845-
18461852
def delete_liquidity_pool(self, pool, account=None, **kwargs):
1847-
"""Delete a liquidity pool
1853+
"""
1854+
Delete a liquidity pool.
18481855
18491856
:param str,Asset pool: The liquidity pool to delete. Can be the pool id
18501857
as a string, or can be an Asset, asset_id, or symbol of the
18511858
share asset for the pool.
1852-
18531859
"""
18541860
if not account:
18551861
if "default_account" in self.config:
@@ -1870,17 +1876,18 @@ def delete_liquidity_pool(self, pool, account=None, **kwargs):
18701876
)
18711877
return self.finalizeOp(op, account, "active", **kwargs)
18721878

1873-
1874-
def deposit_into_liquidity_pool(self, pool, amount_a, amount_b, account=None, **kwargs):
1875-
"""Deposit assets into a liquidity pool
1879+
def deposit_into_liquidity_pool(
1880+
self, pool, amount_a, amount_b, account=None, **kwargs
1881+
):
1882+
"""
1883+
Deposit assets into a liquidity pool.
18761884
18771885
:param str,Asset pool: The liquidity pool to use. Can be the pool id
18781886
as a string, or can be an Asset, asset_id, or symbol of the
18791887
share asset for the pool.
18801888
18811889
:param Amount amount_a:
18821890
:param Amount amount_b:
1883-
18841891
"""
18851892
if not account:
18861893
if "default_account" in self.config:
@@ -1893,7 +1900,7 @@ def deposit_into_liquidity_pool(self, pool, amount_a, amount_b, account=None, **
18931900

18941901
num_id_a = int(amount_a.asset["id"].split(".")[-1])
18951902
num_id_b = int(amount_b.asset["id"].split(".")[-1])
1896-
if(num_id_b < num_id_a):
1903+
if num_id_b < num_id_a:
18971904
amount_a, amount_b = amount_b, amount_a
18981905

18991906
op = operations.Liquidity_pool_deposit(
@@ -1908,17 +1915,16 @@ def deposit_into_liquidity_pool(self, pool, amount_a, amount_b, account=None, **
19081915
)
19091916
return self.finalizeOp(op, account, "active", **kwargs)
19101917

1911-
19121918
def withdraw_from_liquidity_pool(self, pool, share_amount, account=None, **kwargs):
1913-
"""Withdraw stake from a liquidity pool
1919+
"""
1920+
Withdraw stake from a liquidity pool.
19141921
19151922
:param str,Asset pool: The liquidity pool to use. Can be the pool id
19161923
as a string, or can be an Asset, asset_id, or symbol of the
19171924
share asset for the pool.
19181925
19191926
:param Amount share_amount: Amount of share asset to redeem. Must be a
19201927
quantity of the pool's share_asset.
1921-
19221928
"""
19231929
if not account:
19241930
if "default_account" in self.config:
@@ -1940,17 +1946,18 @@ def withdraw_from_liquidity_pool(self, pool, share_amount, account=None, **kwarg
19401946
)
19411947
return self.finalizeOp(op, account, "active", **kwargs)
19421948

1943-
1944-
def exchange_with_liquidity_pool(self, pool, amount_to_sell, min_to_receive, account=None, **kwargs):
1945-
"""Exchange assets against a liquidity pool
1949+
def exchange_with_liquidity_pool(
1950+
self, pool, amount_to_sell, min_to_receive, account=None, **kwargs
1951+
):
1952+
"""
1953+
Exchange assets against a liquidity pool.
19461954
19471955
:param str,Asset pool: The liquidity pool to use. Can be the pool id
19481956
as a string, or can be an Asset, asset_id, or symbol of the
19491957
share asset for the pool.
19501958
19511959
:param Amount amount_to_sell:
19521960
:param Amount min_to_receive:
1953-
19541961
"""
19551962
if not account:
19561963
if "default_account" in self.config:

bitshares/price.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ def __repr__(self):
308308

309309

310310
class UpdateCallOrder(Price):
311-
""" This class inherits :class:`bitshares.price.Price` but has the ``base``
312-
and ``quote`` Amounts not only be used to represent the **call
313-
price** (as a ratio of base and quote).
311+
"""This class inherits :class:`bitshares.price.Price` but has the ``base``
312+
and ``quote`` Amounts not only be used to represent the **call
313+
price** (as a ratio of base and quote).
314314
315-
:param bitshares.bitshares.BitShares blockchain_instance: BitShares instance
315+
:param bitshares.bitshares.BitShares blockchain_instance: BitShares instance
316316
"""
317317

318318
def __init__(self, call, **kwargs):

bitsharesbase/operations.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,15 @@ def __init__(self, *args, **kwargs):
10431043
)
10441044
)
10451045

1046-
ticket_type_strings = ['liquid', 'lock_180_days', 'lock_360_days', 'lock_720_days', 'lock_forever']
1046+
1047+
ticket_type_strings = [
1048+
"liquid",
1049+
"lock_180_days",
1050+
"lock_360_days",
1051+
"lock_720_days",
1052+
"lock_forever",
1053+
]
1054+
10471055

10481056
class Ticket_create_operation(GrapheneObject):
10491057
def __init__(self, *args, **kwargs):
@@ -1070,6 +1078,7 @@ def __init__(self, *args, **kwargs):
10701078
)
10711079
)
10721080

1081+
10731082
class Ticket_update_operation(GrapheneObject):
10741083
def __init__(self, *args, **kwargs):
10751084
if isArgsThisClass(self, args):
@@ -1119,7 +1128,10 @@ def __init__(self, *args, **kwargs):
11191128
("asset_b", ObjectId(kwargs["asset_b"], "asset")),
11201129
("share_asset", ObjectId(kwargs["share_asset"], "asset")),
11211130
("taker_fee_percent", Uint16(kwargs["taker_fee_percent"])),
1122-
("withdrawal_fee_percent", Uint16(kwargs["withdrawal_fee_percent"])),
1131+
(
1132+
"withdrawal_fee_percent",
1133+
Uint16(kwargs["withdrawal_fee_percent"]),
1134+
),
11231135
("extensions", Set([])),
11241136
]
11251137
)

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ exclude_lines =
3131

3232
[flake8]
3333
select = C,E,F,W,B,B950
34-
ignore = E501,F401,E203,W503
34+
ignore = E501,F401,E203,W503,B950,E722,B001
3535
exclude =
3636
# No need to traverse our git directory
3737
.git,
3838
# There's no value in checking cache directories
3939
__pycache__,
4040
# The conf file is mostly autogenerated, ignore it
4141
docs/conf.py,
42-
max-complexity = 15
42+
max-complexity = 20
4343
max-line-length = 88
4444

4545
[isort]

0 commit comments

Comments
 (0)