run pylint directly (#12100)

* run pylint directly

* fixup
This commit is contained in:
Kyle Altendorf 2022-06-27 11:53:04 -04:00 committed by GitHub
parent cec19e02de
commit 5aaf07a686
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 7 deletions

View file

@ -62,6 +62,10 @@ jobs:
run: | run: |
mypy mypy
- name: Lint source with pylint
run: |
pylint benchmarks build_scripts chia tests tools *.py
- name: Build source distribution - name: Build source distribution
run: | run: |
python -m build --sdist --outdir dist . python -m build --sdist --outdir dist .

View file

@ -53,7 +53,7 @@ to configure how the tests are run. For example, for more logging: change the lo
```bash ```bash
sh install.sh -d sh install.sh -d
. ./activate . ./activate
black . && isort benchmarks build_scripts chia tests tools *.py && mypy && flake8 benchmarks build_scripts chia tests tools *.py black . && isort benchmarks build_scripts chia tests tools *.py && mypy && flake8 benchmarks build_scripts chia tests tools *.py && pylint benchmarks build_scripts chia tests tools *.py
py.test tests -v --durations 0 py.test tests -v --durations 0
``` ```
@ -61,6 +61,7 @@ The [black library](https://black.readthedocs.io/en/stable/) is used as an autom
The [flake8 library](https://readthedocs.org/projects/flake8/) helps ensure consistent style. The [flake8 library](https://readthedocs.org/projects/flake8/) helps ensure consistent style.
The [Mypy library](https://mypy.readthedocs.io/en/stable/) is very useful for ensuring objects are of the correct type, so try to always add the type of the return value, and the type of local variables. The [Mypy library](https://mypy.readthedocs.io/en/stable/) is very useful for ensuring objects are of the correct type, so try to always add the type of the return value, and the type of local variables.
The [isort library](https://isort.readthedocs.io) is used to sort, group and validate imports in all python files. The [isort library](https://isort.readthedocs.io) is used to sort, group and validate imports in all python files.
The [pylint library](https://pylint.pycqa.org/en/stable/) is used to further lint all python files.
If you want verbose logging for tests, edit the `tests/pytest.ini` file. If you want verbose logging for tests, edit the `tests/pytest.ini` file.

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import asyncio import asyncio
import contextlib import contextlib
import dataclasses import dataclasses

View file

@ -1651,7 +1651,7 @@ def blue_boxed_end_of_slot(sub_slot: EndOfSubSlotBundle):
def validate_sub_epoch_sampling(rng, sub_epoch_weight_list, weight_proof): def validate_sub_epoch_sampling(rng, sub_epoch_weight_list, weight_proof):
tip = weight_proof.recent_chain_data[-1] tip = weight_proof.recent_chain_data[-1]
weight_to_check = _get_weights_for_sampling(rng, tip.weight, weight_proof.recent_chain_data) weight_to_check = _get_weights_for_sampling(rng, tip.weight, weight_proof.recent_chain_data)
sampled_sub_epochs: dict[int, bool] = {} sampled_sub_epochs: Dict[int, bool] = {}
for idx in range(1, len(sub_epoch_weight_list)): for idx in range(1, len(sub_epoch_weight_list)):
if _sample_sub_epoch(sub_epoch_weight_list[idx - 1], sub_epoch_weight_list[idx], weight_to_check): if _sample_sub_epoch(sub_epoch_weight_list[idx - 1], sub_epoch_weight_list[idx], weight_to_check):
sampled_sub_epochs[idx - 1] = True sampled_sub_epochs[idx - 1] = True

View file

@ -54,7 +54,7 @@ def lock_config(root_path: Path, filename: Union[str, Path]) -> Iterator[None]:
# should probably be removed and this function made private. # should probably be removed and this function made private.
config_path = config_path_for_filename(root_path, filename) config_path = config_path_for_filename(root_path, filename)
lock_path: Path = config_path.with_name(config_path.name + ".lock") lock_path: Path = config_path.with_name(config_path.name + ".lock")
with FileLock(lock_path): with FileLock(lock_path): # pylint: disable=E0110
yield yield

View file

@ -91,13 +91,13 @@ def get_nft_info_from_puzzle(nft_coin_info: NFTCoinInfo) -> NFTInfo:
uncurried_nft: UncurriedNFT = UncurriedNFT.uncurry(nft_coin_info.full_puzzle) uncurried_nft: UncurriedNFT = UncurriedNFT.uncurry(nft_coin_info.full_puzzle)
data_uris: List[str] = [] data_uris: List[str] = []
for uri in uncurried_nft.data_uris.as_python(): for uri in uncurried_nft.data_uris.as_python(): # pylint: disable=E1133
data_uris.append(str(uri, "utf-8")) data_uris.append(str(uri, "utf-8"))
meta_uris: List[str] = [] meta_uris: List[str] = []
for uri in uncurried_nft.meta_uris.as_python(): for uri in uncurried_nft.meta_uris.as_python(): # pylint: disable=E1133
meta_uris.append(str(uri, "utf-8")) meta_uris.append(str(uri, "utf-8"))
license_uris: List[str] = [] license_uris: List[str] = []
for uri in uncurried_nft.license_uris.as_python(): for uri in uncurried_nft.license_uris.as_python(): # pylint: disable=E1133
license_uris.append(str(uri, "utf-8")) license_uris.append(str(uri, "utf-8"))
nft_info = NFTInfo( nft_info = NFTInfo(

View file

@ -182,12 +182,14 @@ ignored-modules=blspy,
chiabip158, chiabip158,
chiapos, chiapos,
chiavdf, chiavdf,
chia_rs,
cryptography, cryptography,
aiohttp, aiohttp,
keyring, keyring,
keyrings.cryptfile, keyrings.cryptfile,
bitstring, bitstring,
clvm_tools, clvm_tools,
clvm_tools_rs,
setproctitle, setproctitle,
clvm, clvm,
colorlog, colorlog,

View file

@ -44,6 +44,7 @@ dev_dependencies = [
"build", "build",
"coverage", "coverage",
"pre-commit", "pre-commit",
"pylint",
"pytest", "pytest",
"pytest-asyncio>=0.18.1", # require attribute 'fixture' "pytest-asyncio>=0.18.1", # require attribute 'fixture'
"pytest-monitor; sys_platform == 'linux'", "pytest-monitor; sys_platform == 'linux'",

View file

@ -161,7 +161,7 @@ class TestCompression(TestCase):
def test_spend_byndle_coin_spend(self): def test_spend_byndle_coin_spend(self):
for i in range(0, 10): for i in range(0, 10):
sb: SpendBundle = make_spend_bundle(i) sb: SpendBundle = make_spend_bundle(i)
cs1 = SExp.to(spend_bundle_to_coin_spend_entry_list(sb)).as_bin() cs1 = SExp.to(spend_bundle_to_coin_spend_entry_list(sb)).as_bin() # pylint: disable=E1101
cs2 = spend_bundle_to_serialized_coin_spend_entry_list(sb) cs2 = spend_bundle_to_serialized_coin_spend_entry_list(sb)
assert cs1 == cs2 assert cs1 == cs2