Skip to content
Snippets Groups Projects
Commit 5fef5484 authored by Moul's avatar Moul
Browse files

Introduce Pylint rules and fix pylint reports

parent ea9ad53a
No related branches found
No related tags found
No related merge requests found
......@@ -48,5 +48,6 @@ ignore_missing_imports = true
line-length = 101
target-version = "py37"
select = ["W", "I", "UP", "YTT", "B", "A", "DTZ", "T10",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID", "PL",
"COM", "C4", "PT", "RET", "SIM", "PTH", "PGH", "PL", "TRY", "RUF"]
ignore = ["PLR2004", "PLR0913"]
......@@ -39,16 +39,15 @@ def checksum_command(pubkey_checksum: str) -> None:
if has_auth_method():
key = auth_method()
click.echo(gen_pubkey_checksum(key.pubkey))
else:
if not pubkey_checksum:
sys.exit(MESSAGE)
elif re.search(re.compile(PUBKEY_DELIMITED_PATTERN), pubkey_checksum[0]):
click.echo(gen_pubkey_checksum(pubkey_checksum[0]))
elif re.search(re.compile(PUBKEY_CHECKSUM_PATTERN), pubkey_checksum[0]):
pubkey, checksum = pubkey_checksum[0].split(":")
if checksum == gen_checksum(pubkey):
click.echo("The checksum is valid")
else:
click.echo("The checksum is invalid")
elif not pubkey_checksum:
sys.exit(MESSAGE)
elif re.search(re.compile(PUBKEY_DELIMITED_PATTERN), pubkey_checksum[0]):
click.echo(gen_pubkey_checksum(pubkey_checksum[0]))
elif re.search(re.compile(PUBKEY_CHECKSUM_PATTERN), pubkey_checksum[0]):
pubkey, checksum = pubkey_checksum[0].split(":")
if checksum == gen_checksum(pubkey):
click.echo("The checksum is valid")
else:
sys.exit("Error: Wrong public key format")
click.echo("The checksum is invalid")
else:
sys.exit("Error: Wrong public key format")
......@@ -265,7 +265,7 @@ def transaction_amount(
# In case one amount is passed with multiple recipients
# generate list containing multiple time the same amount
if len(amounts_list) == 1 and len(outputAddresses) > 1:
amounts_list = [amounts_list[0]] * len(outputAddresses)
return [amounts_list[0]] * len(outputAddresses)
return amounts_list
......
......@@ -52,7 +52,7 @@ class MutuallyExclusiveOption(click.Option):
if self.mutually_exclusive.intersection(opts) and self.name in opts:
arguments = ", ".join(self.mutually_exclusive)
raise click.UsageError(
f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`.",
message=f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`.",
)
return super().handle_parse_result(ctx, opts, args)
......@@ -13,6 +13,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import contextlib
import time
import urllib
from typing import Dict, List, Optional, Tuple
......@@ -70,10 +71,8 @@ def identities_from_pubkeys(pubkeys: List[str], uids: bool) -> List:
identities = []
for pubkey in uniq_pubkeys:
time.sleep(BMA_SLEEP)
try:
with contextlib.suppress(HTTPError):
identities.append(identity_of(pubkey))
except HTTPError:
pass
return identities
......
......@@ -118,7 +118,7 @@ def test_transaction_amount_errors(
monkeypatch.setattr(m_tools, "get_ud_value", patched_get_ud_value)
# check program exit on error
with pytest.raises(SystemExit) as pytest_exit:
with pytest.raises(SystemExit) as pytest_exit: # noqa: PT012
# read output to check error.
transfer.transaction_amount(amounts, UDs_amounts, outputAddresses)
assert expected == capsys.readouterr()
......
......@@ -110,7 +110,7 @@ J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX",
],
)
def test_is_pubkey_and_check_errors(uid_pubkey, expected, capsys):
with pytest.raises(SystemExit) as pytest_exit:
with pytest.raises(SystemExit) as pytest_exit: # noqa: PT012
public_key.is_pubkey_and_check(uid_pubkey)
assert capsys.readouterr() == expected
assert pytest_exit.type == SystemExit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment