Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pylint to catch unused args #2803

Merged
merged 3 commits into from
Jan 18, 2022
Merged

add pylint to catch unused args #2803

merged 3 commits into from
Jan 18, 2022

Conversation

ralexstokes
Copy link
Member

fixes #2761.

@@ -1832,7 +1832,7 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
##### Deposits

```python
def get_validator_from_deposit(state: BeaconState, deposit: Deposit) -> Validator:
def get_validator_from_deposit(deposit: Deposit) -> Validator:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does change the phase0 specs BUT no substantive change to functionality, just a code cleanup

@@ -514,7 +514,7 @@ def get_pow_block(hash: Bytes32) -> Optional[PowBlock]:
return PowBlock(block_hash=hash, parent_hash=Bytes32(), total_difficulty=uint256(0))


def get_execution_state(execution_state_root: Bytes32) -> ExecutionState:
def get_execution_state(_execution_state_root: Bytes32) -> ExecutionState:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this satisfy pylint by indicating it is intended to be unused, which seems like a fine solution to me while we are still iterating on the bellatrix auxillary code

lint: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
&& pylint --disable=all --enable unused-argument ./eth2spec/phase0 ./eth2spec/altair ./eth2spec/bellatrix \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pylint adds a bunch of stuff we are not following wrt style, so instead we disable=all and then only enable the thing we want, which is the unused-argument linter

@@ -521,7 +521,7 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
signing_root = compute_signing_root(deposit_message, domain)
# Initialize validator if the deposit signature is valid
if bls.Verify(pubkey, signing_root, deposit.data.signature):
state.validators.append(get_validator_from_deposit(state, deposit))
state.validators.append(get_validator_from_deposit(deposit))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update from phase0 as well

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the lack of test files changed, I suppose don't have a unit test for the function. Could use this as a chance to add a sanity call in there... but probably fine either way.

thanks!

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
It seems we can also consider enabling some more pylint checks later.

@ralexstokes
Copy link
Member Author

don't have a unit test

this utility function is simple enough that we would basically just be writing the implementation which doesn't add a lot of extra assurance imo

there is also plenty of transitive test coverage via things that use the Validator so i think it is fine w/o

@ralexstokes ralexstokes merged commit 02b3210 into ethereum:dev Jan 18, 2022
@ralexstokes ralexstokes deleted the clean-up-linter branch January 18, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double check linting settings
3 participants