-
Notifications
You must be signed in to change notification settings - Fork 419
chore(tooling): Update static checks #1428
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
Changes from 19 commits
2cadcba
6b56fd2
04dbacf
98d5485
7e120be
39dfd3f
0af276b
aa096ba
56650ee
6b5af3c
7ba0544
a24b99f
755b804
c5586b9
a00af88
5014333
09c069c
5c06d96
fde14ab
e5ab72f
06b62ec
1da0e96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1 @@ | ||
| """ | ||
| Cryptographic primitives used in Ethereum. | ||
| """ | ||
| """Cryptographic primitives used in Ethereum.""" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| """ | ||
| The Blake2 Implementation | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| """ | ||
| """The Blake2 Implementation.""" | ||
|
|
||
| import struct | ||
| from dataclasses import dataclass | ||
| from typing import Final, List, Tuple | ||
|
|
@@ -21,6 +19,7 @@ def spit_le_to_uint(data: bytes, start: int, num_words: int) -> List[Uint]: | |
| Position to start the extraction | ||
| num_words: | ||
| The number of words to be extracted | ||
|
|
||
| """ | ||
| words = [] | ||
| for i in range(num_words): | ||
|
|
@@ -52,40 +51,38 @@ class Blake2: | |
|
|
||
| @property | ||
| def max_word(self) -> Uint: | ||
| """ | ||
| Largest value for a given Blake2 flavor. | ||
| """ | ||
| """Largest value for a given Blake2 flavor.""" | ||
gurukamath marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return Uint(2) ** self.w | ||
|
|
||
| @property | ||
| def w_R1(self) -> Uint: | ||
| """ | ||
| (w - R1) value for a given Blake2 flavor. | ||
| Used in the function G | ||
| Used in the function G. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we ignoring D205? If we're going to mandate summaries, we should mandate the blank line as well.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought I'd check the consequence of enabling D205. This example errors: """
Generate an index file (index.json) of all the fixtures in the specified
directory.
"""As the D checks seemingly expect that the summary is on a single line, i.e., it thinks "directory" is the description. This makes no sense, but it fixes D205: """
Generate an index file (index.json) of all the fixtures in the specified
directory.
"""I'm inclined to disable D200, but enable D205. But it's late and will re-visit tomorrow.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, enabling D205 gives 1241 errors. These would not be trivial to fix. We typically launch into multiline docstrings without a summary, so they'd have to re-written. It would result in nicer documentation though. e.g. """
A small pytest plugin that shows the a concise help string that only contains
the options defined by the plugins defined in execution-spec-tests.
"""
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funny example, needs fixing anyway 😆
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will need to be handled as part of the markdown conversion. See #671
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, it does need to be fixed but can be rolled into #671 |
||
| """ | ||
| return self.w - self.R1 | ||
|
|
||
| @property | ||
| def w_R2(self) -> Uint: | ||
| """ | ||
| (w - R2) value for a given Blake2 flavor. | ||
| Used in the function G | ||
| Used in the function G. | ||
| """ | ||
| return self.w - self.R2 | ||
|
|
||
| @property | ||
| def w_R3(self) -> Uint: | ||
| """ | ||
| (w - R3) value for a given Blake2 flavor. | ||
| Used in the function G | ||
| Used in the function G. | ||
| """ | ||
| return self.w - self.R3 | ||
|
|
||
| @property | ||
| def w_R4(self) -> Uint: | ||
| """ | ||
| (w - R4) value for a given Blake2 flavor. | ||
| Used in the function G | ||
| Used in the function G. | ||
| """ | ||
| return self.w - self.R4 | ||
|
|
||
|
|
@@ -126,9 +123,7 @@ def w_R4(self) -> Uint: | |
|
|
||
| @property | ||
| def sigma_len(self) -> int: | ||
| """ | ||
| Length of the sigma parameter. | ||
| """ | ||
| """Length of the sigma parameter.""" | ||
| return len(self.sigma) | ||
|
|
||
| def get_blake2_parameters(self, data: bytes) -> Tuple: | ||
|
|
@@ -140,6 +135,7 @@ def get_blake2_parameters(self, data: bytes) -> Tuple: | |
| ---------- | ||
| data : | ||
| The bytes data that has been passed in the message. | ||
|
|
||
| """ | ||
| rounds = Uint.from_be_bytes(data[:4]) | ||
| h = spit_le_to_uint(data, 4, 8) | ||
|
|
@@ -153,8 +149,7 @@ def G( | |
| self, v: List, a: Uint, b: Uint, c: Uint, d: Uint, x: Uint, y: Uint | ||
| ) -> List: | ||
| """ | ||
| The mixing function used in Blake2 | ||
| https://datatracker.ietf.org/doc/html/rfc7693#section-3.1 | ||
| The mixing function used in Blake2. | ||
gurukamath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
@@ -164,6 +159,7 @@ def G( | |
| Indexes within v of the words to be mixed. | ||
| x, y : | ||
| The two input words for the mixing. | ||
|
|
||
| """ | ||
| v[a] = (v[a] + v[b] + x) % self.max_word | ||
| v[d] = ((v[d] ^ v[a]) >> self.R1) ^ ( | ||
|
|
@@ -197,8 +193,7 @@ def compress( | |
| f: bool, | ||
| ) -> bytes: | ||
| """ | ||
| 'F Compression' from section 3.2 of RFC 7693: | ||
| https://tools.ietf.org/html/rfc7693#section-3.2 | ||
| 'F Compression' from section 3.2 of RFC 7693. | ||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
@@ -212,6 +207,7 @@ def compress( | |
| Offset counters. 2 unsigned 64-bit little-endian words | ||
| f: | ||
| The final block indicator flag. An 8-bit word | ||
|
|
||
| """ | ||
| # Initialize local work vector v[0..15] | ||
| v = [Uint(0)] * 16 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,23 @@ | ||
| """ | ||
| Error types common across all Ethereum forks. | ||
| """ | ||
| """Error types common across all Ethereum forks.""" | ||
|
|
||
|
|
||
| class EthereumException(Exception): # noqa N818 | ||
| class EthereumException(Exception): # noqa N818 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we want it to read |
||
| """ | ||
| Base class for all exceptions _expected_ to be thrown during normal | ||
| operation. | ||
| """ | ||
|
|
||
|
|
||
| class InvalidBlock(EthereumException): | ||
| """ | ||
| Thrown when a block being processed is found to be invalid. | ||
| """ | ||
| """Thrown when a block being processed is found to be invalid.""" | ||
|
|
||
|
|
||
| class StateWithEmptyAccount(EthereumException): | ||
| """ | ||
| Thrown when the state has empty account. | ||
| """ | ||
| """Thrown when the state has empty account.""" | ||
|
|
||
|
|
||
| class InvalidTransaction(EthereumException): | ||
| """ | ||
| Thrown when a transaction being processed is found to be invalid. | ||
| """ | ||
| """Thrown when a transaction being processed is found to be invalid.""" | ||
|
|
||
|
|
||
| class InvalidSenderError(InvalidTransaction): | ||
|
|
@@ -36,9 +28,7 @@ class InvalidSenderError(InvalidTransaction): | |
|
|
||
|
|
||
| class InvalidSignatureError(InvalidTransaction): | ||
| """ | ||
| Thrown when a transaction has an invalid signature. | ||
| """ | ||
| """Thrown when a transaction has an invalid signature.""" | ||
|
|
||
|
|
||
| class InsufficientBalanceError(InvalidTransaction): | ||
|
|
@@ -70,6 +60,4 @@ class InsufficientTransactionGasError(InvalidTransaction): | |
|
|
||
|
|
||
| class NonceOverflowError(InvalidTransaction): | ||
| """ | ||
| Thrown when a transaction's nonce is greater than `2**64 - 2`. | ||
| """ | ||
| """Thrown when a transaction's nonce is greater than `2**64 - 2`.""" | ||
Uh oh!
There was an error while loading. Please reload this page.