Skip to content

Commit

Permalink
fix pylama warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao Li committed Dec 7, 2020
1 parent 118f236 commit 1ea5e49
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 50 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ init:
./venv/bin/pip install --upgrade pip wheel setuptools
./venv/bin/pip install -r requirements.txt --use-feature=2020-resolver

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

pylama:
./venv/bin/pylama src tests
./venv/bin/pylama src tests examples

lint: check
./venv/bin/python -m black --check src tests
Expand Down
4 changes: 1 addition & 3 deletions examples/intent_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# SPDX-License-Identifier: Apache-2.0


import secrets

from diem import identifier, utils, LocalAccount
from diem import identifier, utils


def test_intent_identifier():
Expand Down
4 changes: 1 addition & 3 deletions examples/p2p_transfer.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

import time, secrets, typing
import time

from diem import (
identifier,
jsonrpc,
diem_types,
stdlib,
testnet,
txnmetadata,
utils,
LocalAccount,
)

from .stubs import CustodialApp
Expand Down
2 changes: 1 addition & 1 deletion examples/stubs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0

import time, secrets, typing
import time, typing
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from diem import (
identifier,
Expand Down
30 changes: 3 additions & 27 deletions pylama.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

[pylama]
format = black
skip = **/*_pb2.py,**/*_pb2_grpc.py,lib/src/**/*.py
skip = **/*_pb2.py,*/serde_binary/__init__.py,*/stdlib/__init__.py,*/lcs/__init__.py,*/*_types/__init__.py
ignore=E501,E203,E401,E402

[pylama:pylint]
max_line_length = 120
Expand All @@ -16,29 +17,4 @@ max_line_length = 120

[pylama:*/__init__.py]
# W0611: imported but unused [pyflakes]
# W0401: unable to detect undefined names [pyflakes]
ignore = W0611,W0401

[pylama:*/*_types/__init__.py]
# E302 expected 2 blank lines, found 1 [pycodestyle]
# W0611: imported but unused [pyflakes]
# W0401: unable to detect undefined names [pyflakes]
# C901: too cmplex [pmccabe]
ignore = E302,W0611,W0401,C901

[pylama:*/lcs/__init__.py]
# E302 expected 2 blank lines, found 1 [pycodestyle]
# E721 do not compare types, use 'isinstance()' [pycodestyle]
# W0401: unable to detect undefined names [pyflakes]
# C901: too cmplex [pmccabe]
ignore = E302,E721,W0611,W0401,C901

[pylama:*/stdlib/__init__.py]
# E501 line too long (1803 > 120 characters) [pycodestyle]
# W0611: imported but unused [pyflakes]
ignore = E501,W0611

[pylama:test_*.py]
# W0401: unable to detect undefined names [pyflakes]
# E501: line too long [pycodestyle]
ignore = W0401,E501
ignore = W0611
4 changes: 2 additions & 2 deletions src/diem/jsonrpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests
import threading
import typing
import random, queue
import random
from concurrent.futures import Future, ThreadPoolExecutor, as_completed
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey

Expand Down Expand Up @@ -157,7 +157,7 @@ def send_request(
def _fallback_to_backup(self, primary: Future, backup: Future) -> typing.Dict[str, typing.Any]:
try:
return primary.result()
except Exception as e:
except Exception:
return backup.result()

def _first_success(self, primary: Future, backup: Future) -> typing.Dict[str, typing.Any]:
Expand Down
3 changes: 0 additions & 3 deletions src/diem/jsonrpc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"""

import typing


# AccountRole#type field values
ACCOUNT_ROLE_UNKNOWN: str = "unknown"
ACCOUNT_ROLE_CHILD_VASP: str = "child_vasp"
Expand Down
2 changes: 1 addition & 1 deletion src/diem/testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import requests
import typing, time

from . import diem_types, jsonrpc, utils, local_account, serde_types, auth_key, chain_ids, lcs, stdlib, LocalAccount
from . import diem_types, jsonrpc, utils, chain_ids, lcs, stdlib, LocalAccount


JSON_RPC_URL: str = "https://testnet.diem.com/v1"
Expand Down
2 changes: 1 addition & 1 deletion src/diem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import hashlib
import typing

from . import diem_types, serde_types, jsonrpc, stdlib
from . import diem_types, jsonrpc, stdlib


ACCOUNT_ADDRESS_LEN: int = diem_types.AccountAddress.LENGTH
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auth_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from diem import utils, AuthKey
from diem import AuthKey


def test_new_auth_key_from_public_key():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0


from diem import jsonrpc, testnet
from diem import jsonrpc
from concurrent.futures import ThreadPoolExecutor
import pytest, time

Expand Down Expand Up @@ -105,7 +105,7 @@ def test_raises_error_if_primary_and_backup_both_failed():
def gen_metadata_response(client, fail=None, snap=None):
def send_request(url, request, ignore_stale_response):
if fail == url:
raise StaleResponseError("error")
raise jsonrpc.StaleResponseError("error")

if snap == url:
time.sleep(0.1)
Expand Down
4 changes: 0 additions & 4 deletions tests/test_testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
LocalAccount,
)

import numpy as np
import time
import pytest

Expand Down Expand Up @@ -330,8 +329,6 @@ def test_get_parent_vasp_account():

def test_get_parent_vasp_account_not_found():
client = testnet.create_client()
faucet = testnet.Faucet(client)

parent_vasp = LocalAccount.generate()

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

def test_get_parent_vasp_account_with_non_vasp_account_address():
client = testnet.create_client()
faucet = testnet.Faucet(client)

with pytest.raises(ValueError):
client.get_parent_vasp_account(utils.TREASURY_ADDRESS)
Expand Down

0 comments on commit 1ea5e49

Please sign in to comment.