btclib-org / btclib

btclib: a python3 library for 'bitcoin cryptography'
https://btclib.org
MIT License
97 stars 42 forks source link

adopted mypy --strict #87

Closed fametrano closed 1 year ago

sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.09%.

Quality metrics Before After Change
Complexity 4.73 ⭐ 4.70 ⭐ -0.03 👍
Method Length 87.77 🙂 87.54 🙂 -0.23 👍
Working memory 9.04 🙂 9.02 🙂 -0.02 👍
Quality 65.17% 🙂 65.26% 🙂 0.09% 👍
Other metrics Before After Change
Lines 14540 14577 37
Changed files Quality Before Quality After Quality Change
btclib/alias.py 75.39% ⭐ 75.39% ⭐ 0.00%
btclib/amount.py 86.45% ⭐ 86.30% ⭐ -0.15% 👎
btclib/b32.py 72.21% 🙂 72.21% 🙂 0.00%
btclib/b58.py 84.69% ⭐ 84.69% ⭐ 0.00%
btclib/base58.py 77.85% ⭐ 77.85% ⭐ 0.00%
btclib/bech32.py 75.40% ⭐ 75.68% ⭐ 0.28% 👍
btclib/hashes.py 85.32% ⭐ 85.31% ⭐ -0.01% 👎
btclib/network.py 72.58% 🙂 72.83% 🙂 0.25% 👍
btclib/number_theory.py 59.06% 🙂 59.06% 🙂 0.00%
btclib/to_prv_key.py 61.84% 🙂 61.84% 🙂 0.00%
btclib/to_pub_key.py 70.77% 🙂 70.77% 🙂 0.00%
btclib/utils.py 82.00% ⭐ 81.99% ⭐ -0.01% 👎
btclib/bip32/bip32.py 65.49% 🙂 65.51% 🙂 0.02% 👍
btclib/bip32/der_path.py 79.93% ⭐ 80.03% ⭐ 0.10% 👍
btclib/bip32/key_origin.py 88.58% ⭐ 88.58% ⭐ 0.00%
btclib/bip32/slip132.py 81.81% ⭐ 81.81% ⭐ 0.00%
btclib/block/block.py 85.09% ⭐ 85.24% ⭐ 0.15% 👍
btclib/block/block_header.py 73.83% 🙂 74.17% 🙂 0.34% 👍
btclib/ec/__init__.py 84.72% ⭐ 60.66% 🙂 -24.06% 👎
btclib/ec/curve.py 60.56% 🙂 60.56% 🙂 0.00%
btclib/ec/curve_group.py 69.74% 🙂 69.74% 🙂 0.00%
btclib/ec/curve_group_2.py 49.29% 😞 49.29% 😞 0.00%
btclib/ec/curve_group_f.py 77.64% ⭐ 77.64% ⭐ 0.00%
btclib/ec/libsecp256k1.py 96.02% ⭐ 97.89% ⭐ 1.87% 👍
btclib/ecc/__init__.py 99.17% ⭐ 94.35% ⭐ -4.82% 👎
btclib/ecc/bms.py 62.88% 🙂 62.89% 🙂 0.01% 👍
btclib/ecc/borromean.py 39.99% 😞 45.27% 😞 5.28% 👍
btclib/ecc/dh.py 67.59% 🙂 67.59% 🙂 0.00%
btclib/ecc/dsa.py 66.80% 🙂 66.81% 🙂 0.01% 👍
btclib/ecc/sign_to_contract.py 74.80% 🙂 74.80% 🙂 0.00%
btclib/ecc/ssa.py 67.39% 🙂 67.39% 🙂 0.00%
btclib/mnemonic/__init__.py 67.67% 🙂 67.20% 🙂 -0.47% 👎
btclib/mnemonic/bip39.py 81.53% ⭐ 81.53% ⭐ 0.00%
btclib/mnemonic/electrum.py 74.07% 🙂 74.08% 🙂 0.01% 👍
btclib/mnemonic/entropy.py 62.69% 🙂 62.80% 🙂 0.11% 👍
btclib/mnemonic/mnemonic.py 81.72% ⭐ 81.72% ⭐ 0.00%
btclib/psbt/psbt.py 60.50% 🙂 60.51% 🙂 0.01% 👍
btclib/psbt/psbt_in.py 56.75% 🙂 56.77% 🙂 0.02% 👍
btclib/psbt/psbt_out.py 75.66% ⭐ 75.68% ⭐ 0.02% 👍
btclib/psbt/psbt_utils.py 81.82% ⭐ 81.82% ⭐ 0.00%
btclib/script/script.py 65.67% 🙂 65.67% 🙂 0.00%
btclib/script/script_pub_key.py 78.12% ⭐ 78.12% ⭐ 0.00%
btclib/script/sig_hash.py 48.74% 😞 48.74% 😞 0.00%
btclib/script/taproot.py 65.01% 🙂 65.01% 🙂 0.00%
btclib/script/witness.py 88.52% ⭐ 88.52% ⭐ 0.00%
btclib/tx/out_point.py 86.12% ⭐ 86.12% ⭐ 0.00%
btclib/tx/tx.py 80.35% ⭐ 80.51% ⭐ 0.16% 👍
btclib/tx/tx_in.py 87.25% ⭐ 87.30% ⭐ 0.05% 👍
btclib/tx/tx_out.py 88.08% ⭐ 88.08% ⭐ 0.00%
docs/source/conf.py 89.02% ⭐ 91.68% ⭐ 2.66% 👍
tests/test_amount.py 78.81% ⭐ 78.81% ⭐ 0.00%
tests/test_b32.py 80.22% ⭐ 80.22% ⭐ 0.00%
tests/test_b58.py 69.29% 🙂 69.29% 🙂 0.00%
tests/test_to_key.py 28.04% 😞 28.04% 😞 0.00%
tests/bip32/test_slip132.py 56.30% 🙂 56.30% 🙂 0.00%
tests/ec/test_curve.py 60.83% 🙂 60.75% 🙂 -0.08% 👎
tests/ec/test_curve_group.py 61.90% 🙂 61.90% 🙂 0.00%
tests/ec/test_curve_group_2.py 64.89% 🙂 64.86% 🙂 -0.03% 👎
tests/ec/test_curve_group_f.py 70.29% 🙂 70.29% 🙂 0.00%
tests/ec/test_sec_point.py 59.84% 🙂 59.84% 🙂 0.00%
tests/ecc/test_borromean.py 58.52% 🙂 61.03% 🙂 2.51% 👍
tests/ecc/test_dh.py 56.61% 🙂 56.61% 🙂 0.00%
tests/ecc/test_ssa.py 30.97% 😞 30.97% 😞 0.00%
tests/mnemonic/test_entropy.py 62.61% 🙂 62.61% 🙂 0.00%
tests/mnemonic/test_mnemonic.py 84.18% ⭐ 84.18% ⭐ 0.00%
tests/psbt/test_psbt.py 74.03% 🙂 74.03% 🙂 0.00%
tests/psbt/test_psbt_out.py 76.81% ⭐ 76.81% ⭐ 0.00%
tests/script/test_script.py 83.25% ⭐ 83.25% ⭐ 0.00%
tests/script/test_script_pub_key.py 69.36% 🙂 69.36% 🙂 0.00%
tests/script/test_witness.py 75.85% ⭐ 75.85% ⭐ 0.00%
tests/tx/test_tx.py 60.10% 🙂 60.10% 🙂 0.00%

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
tests/ecc/test_ssa.py test_threshold 31 😞 1867 ⛔ 33 ⛔ 9.52% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/psbt/psbt_in.py PsbtIn.parse 16 🙂 279 ⛔ 32 ⛔ 23.33% ⛔ Try splitting into smaller methods. Extract out complex expressions
btclib/ecc/borromean.py sign 18 🙂 338 ⛔ 20 ⛔ 23.44% ⛔ Try splitting into smaller methods. Extract out complex expressions
btclib/ec/curve_group_2.py mult_sliding_window 26 😞 220 ⛔ 15 😞 27.37% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/script/sig_hash.py taproot 13 🙂 314 ⛔ 18 ⛔ 29.54% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!