Skip to content

Commit 1ea5e49

Browse files
author
Xiao Li
committed
fix pylama warnings
1 parent 118f236 commit 1ea5e49

12 files changed

+15
-50
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ init:
77
./venv/bin/pip install --upgrade pip wheel setuptools
88
./venv/bin/pip install -r requirements.txt --use-feature=2020-resolver
99

10-
check:
10+
check: pylama
1111
./venv/bin/pyre --search-path venv/lib/python3.9/site-packages check
1212

1313
pylama:
14-
./venv/bin/pylama src tests
14+
./venv/bin/pylama src tests examples
1515

1616
lint: check
1717
./venv/bin/python -m black --check src tests

examples/intent_identifier.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44

5-
import secrets
6-
7-
from diem import identifier, utils, LocalAccount
5+
from diem import identifier, utils
86

97

108
def test_intent_identifier():

examples/p2p_transfer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Copyright (c) The Diem Core Contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import time, secrets, typing
4+
import time
55

66
from diem import (
77
identifier,
8-
jsonrpc,
98
diem_types,
109
stdlib,
1110
testnet,
1211
txnmetadata,
1312
utils,
14-
LocalAccount,
1513
)
1614

1715
from .stubs import CustodialApp

examples/stubs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) The Diem Core Contributors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import time, secrets, typing
4+
import time, typing
55
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
66
from diem import (
77
identifier,

pylama.ini

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
[pylama]
55
format = black
6-
skip = **/*_pb2.py,**/*_pb2_grpc.py,lib/src/**/*.py
6+
skip = **/*_pb2.py,*/serde_binary/__init__.py,*/stdlib/__init__.py,*/lcs/__init__.py,*/*_types/__init__.py
7+
ignore=E501,E203,E401,E402
78

89
[pylama:pylint]
910
max_line_length = 120
@@ -16,29 +17,4 @@ max_line_length = 120
1617

1718
[pylama:*/__init__.py]
1819
# W0611: imported but unused [pyflakes]
19-
# W0401: unable to detect undefined names [pyflakes]
20-
ignore = W0611,W0401
21-
22-
[pylama:*/*_types/__init__.py]
23-
# E302 expected 2 blank lines, found 1 [pycodestyle]
24-
# W0611: imported but unused [pyflakes]
25-
# W0401: unable to detect undefined names [pyflakes]
26-
# C901: too cmplex [pmccabe]
27-
ignore = E302,W0611,W0401,C901
28-
29-
[pylama:*/lcs/__init__.py]
30-
# E302 expected 2 blank lines, found 1 [pycodestyle]
31-
# E721 do not compare types, use 'isinstance()' [pycodestyle]
32-
# W0401: unable to detect undefined names [pyflakes]
33-
# C901: too cmplex [pmccabe]
34-
ignore = E302,E721,W0611,W0401,C901
35-
36-
[pylama:*/stdlib/__init__.py]
37-
# E501 line too long (1803 > 120 characters) [pycodestyle]
38-
# W0611: imported but unused [pyflakes]
39-
ignore = E501,W0611
40-
41-
[pylama:test_*.py]
42-
# W0401: unable to detect undefined names [pyflakes]
43-
# E501: line too long [pycodestyle]
44-
ignore = W0401,E501
20+
ignore = W0611

src/diem/jsonrpc/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import requests
1010
import threading
1111
import typing
12-
import random, queue
12+
import random
1313
from concurrent.futures import Future, ThreadPoolExecutor, as_completed
1414
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
1515

@@ -157,7 +157,7 @@ def send_request(
157157
def _fallback_to_backup(self, primary: Future, backup: Future) -> typing.Dict[str, typing.Any]:
158158
try:
159159
return primary.result()
160-
except Exception as e:
160+
except Exception:
161161
return backup.result()
162162

163163
def _first_success(self, primary: Future, backup: Future) -> typing.Dict[str, typing.Any]:

src/diem/jsonrpc/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
1414
"""
1515

16-
import typing
17-
18-
1916
# AccountRole#type field values
2017
ACCOUNT_ROLE_UNKNOWN: str = "unknown"
2118
ACCOUNT_ROLE_CHILD_VASP: str = "child_vasp"

src/diem/testnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import requests
2424
import typing, time
2525

26-
from . import diem_types, jsonrpc, utils, local_account, serde_types, auth_key, chain_ids, lcs, stdlib, LocalAccount
26+
from . import diem_types, jsonrpc, utils, chain_ids, lcs, stdlib, LocalAccount
2727

2828

2929
JSON_RPC_URL: str = "https://testnet.diem.com/v1"

src/diem/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import hashlib
99
import typing
1010

11-
from . import diem_types, serde_types, jsonrpc, stdlib
11+
from . import diem_types, jsonrpc, stdlib
1212

1313

1414
ACCOUNT_ADDRESS_LEN: int = diem_types.AccountAddress.LENGTH

tests/test_auth_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
5-
from diem import utils, AuthKey
5+
from diem import AuthKey
66

77

88
def test_new_auth_key_from_public_key():

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44

5-
from diem import jsonrpc, testnet
5+
from diem import jsonrpc
66
from concurrent.futures import ThreadPoolExecutor
77
import pytest, time
88

@@ -105,7 +105,7 @@ def test_raises_error_if_primary_and_backup_both_failed():
105105
def gen_metadata_response(client, fail=None, snap=None):
106106
def send_request(url, request, ignore_stale_response):
107107
if fail == url:
108-
raise StaleResponseError("error")
108+
raise jsonrpc.StaleResponseError("error")
109109

110110
if snap == url:
111111
time.sleep(0.1)

tests/test_testnet.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
LocalAccount,
1313
)
1414

15-
import numpy as np
1615
import time
1716
import pytest
1817

@@ -330,8 +329,6 @@ def test_get_parent_vasp_account():
330329

331330
def test_get_parent_vasp_account_not_found():
332331
client = testnet.create_client()
333-
faucet = testnet.Faucet(client)
334-
335332
parent_vasp = LocalAccount.generate()
336333

337334
with pytest.raises(jsonrpc.AccountNotFoundError):
@@ -340,7 +337,6 @@ def test_get_parent_vasp_account_not_found():
340337

341338
def test_get_parent_vasp_account_with_non_vasp_account_address():
342339
client = testnet.create_client()
343-
faucet = testnet.Faucet(client)
344340

345341
with pytest.raises(ValueError):
346342
client.get_parent_vasp_account(utils.TREASURY_ADDRESS)

0 commit comments

Comments
 (0)