Skip to content

chore(tooling): Update static checks#1428

Merged
gurukamath merged 22 commits intoethereum:forks/osakafrom
gurukamath:static-checks
Sep 25, 2025
Merged

chore(tooling): Update static checks#1428
gurukamath merged 22 commits intoethereum:forks/osakafrom
gurukamath:static-checks

Conversation

@gurukamath
Copy link
Contributor

@gurukamath gurukamath commented Sep 16, 2025

(closes #1378)
(closes #1397)
(closes #1403 )

What was wrong?

Some of the current static checks are not run on the tests folder. Also, ruff format is not being run.

Related to Issue #1378
Related to Issue #1397
Related to Issue #1403

How was it fixed?

Extend static checks to the tests folder. Only exclude the eest related code

Add ruff format check.

Cute Animal Picture

Cute Animals - 1 of 1

@gurukamath gurukamath marked this pull request as draft September 18, 2025 08:47
Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

The updated tox static env looks good, @gurukamath! We just need to make sure that we're running with the appropriate ruff config, to avoid another mass format PR.

A few points on config relevant for ruff format :

  1. To have the ruff format-specific config, as close to the target post-weld config as possible, I'd suggest removing this EELS-specific ignore:

    "E203", # Whitespace before ':'

  2. What do you think about removing E501: line-too-long for all of ./tests/ for consistency (my preference: as we're doing this for spec and unit tests in ethereum/execution-spec-tests#2152)? This will not only be a reformat; docstrings, comments will cause trouble.

    "E501", # Line too long

  3. We should evaluate the target post-weld docstring rules. Perhaps it's ok to subsequently apply the changes for this ruleset as a separate PR? It will need a little alignment and potentially quite some effort. This is potentially another mass reformat.

Another suggestion, not strictly required in this PR: We will need to update the path(s) here to exclude EEST. So that when we enable EEST ruff commands, these rules aren't applied to tests/eest:

[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"E501", # Line too long

@gurukamath gurukamath marked this pull request as ready for review September 18, 2025 13:33
Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

Hey @gurukamath, I only reviewed the changes to pyproject.toml and compared them to EEST's ruff config. The [tool.ruff.lint] section looks great; I copied it over to EEST (enabled D400, enabled D415; disabled "A" which will be fixed by Sam's ethereum/execution-spec-tests#2166) and it runs cleanly on our code.

Just one request below to enable D400 🙏

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.07%. Comparing base (5ddb904) to head (1da0e96).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##           forks/osaka    #1428   +/-   ##
============================================
  Coverage        86.07%   86.07%           
============================================
  Files              743      743           
  Lines            44072    44072           
  Branches          3891     3891           
============================================
  Hits             37936    37936           
  Misses            5659     5659           
  Partials           477      477           
Flag Coverage Δ
unittests 86.07% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danceratopz
Copy link
Member

I copied it over to EEST (enabled D400, enabled D415; disabled "A" which will be fixed by Sam's ethereum/execution-spec-tests#2166) and it runs cleanly on our code.

Small correction to the above: EEST will need to enable the other ARG checks to have parity with EELS:

@gurukamath
Copy link
Contributor Author

@danceratopz @Carsons-Eels Have updated the PR to stop ignoring D400

Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

Thanks for enabling D400, @gurukamath. At a first glance the changes look good.

Could you just comment whether the changes were fully automated or not? I.e., how much manual resolution did you do? I assume you manually removed or scripted the ^^^ restructuredText underneath headers? What else was required apart from ruff format?

Can you check the comment below? If that change is fine, then I'll do a more thorough review of the changes, based on your answers to the questions (about "how") above.

@gurukamath
Copy link
Contributor Author

gurukamath commented Sep 22, 2025

Thanks for enabling D400, @gurukamath. At a first glance the changes look good.

Could you just comment whether the changes were fully automated or not? I.e., how much manual resolution did you do? I assume you manually removed or scripted the ^^^ restructuredText underneath headers? What else was required apart from ruff format?

Yes. It is a ruff check automated fix + some manual changes. An overwhelming majority of these changes are removing the underline from restructured text. There might be 2-3 slightly more specific cases of manual change. For example like the re-ordering of the restructured test anchor here. Unfortunately, I do not recollect all such cases right now but if you want, I can re-make the commits such that all the automated changes and manual ones are in different commits. Do let me know.

Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

LGTM @gurukamath. Here's what I checked:

  1. I used the ruff settings from this PR in EEST with two exceptions:
    i. select: without "ARG"; this is still WIP in EEST,
    ii. line-length 99 instead of 79.
  2. I reviewed a random subset of the changes manually: Small comment below.
  3. I asked Claude to review the PR on a per-file basis: All good.

About 2.: Tldr: It's fine from my side, but.. The only comment I have is that the titles in the rendered doc might look a little strange with a period at the end of them. We could potentially modify docc to remove them again? It is kinda crazy to add a period for a linter only to remove them again in the doc flow, BUT, it does allow for consistent lint rules.

The review in 1. was worth it, I found two bugs in EEST's ruff config 😄

  1. We select "C", which doesn't exist. It appears ruff enables both complexity (C90) and flake8-comprehensions (C4) with this -> we should be more explicit and only enable "C4". EELS should add "C4" to its select (27 issues; separate PR)? There are other rules that start with "C", looking into whether these are enabled, or not.
  2. We reverted enabling of "C420" by accident, will fix.

@gurukamath
Copy link
Contributor Author

About 2.: Tldr: It's fine from my side, but.. The only comment I have is that the titles in the rendered doc might look a little strange with a period at the end of them. We could potentially modify docc to remove them again? It is kinda crazy to add a period for a linter only to remove them again in the doc flow, BUT, it does allow for consistent lint rules.

@SamWilsn What do you think of the point made here about docc?

@gurukamath
Copy link
Contributor Author

  1. We select "C", which doesn't exist. It appears ruff enables both complexity (C90) and flake8-comprehensions (C4) with this -> we should be more explicit and only enable "C4". EELS should add "C4" to its select (27 issues; separate PR)? There are other rules that start with "C", looking into whether these are enabled, or not.

Here are my thoughts on the C-space rules. I am ok with ignoring C901 as we had earlier agreed. But I think we should also ignore C401 and C408. The generators and calls which these rules deal with might be a bit of an overhead but they definitely make for more readable code in the spec. So I am in favour of enabling the entire C space and selectively disabling C401, C408 and C901

@danceratopz
Copy link
Member

Here are my thoughts on the C-space rules. I am ok with ignoring C901 as we had earlier agreed. But I think we should also ignore C401 and C408. The generators and calls which these rules deal with might be a bit of an overhead but they definitely make for more readable code in the spec. So I am in favour of enabling the entire C space and selectively disabling C401, C408 and C901

Thanks for looking at this @gurukamath. This change would be outside the scope of this PR. I haven't looked at how difficult it'd be to able the whole C space, but let's follow up on that elsewhere.

"""
(w - R1) value for a given Blake2 flavor.
Used in the function G
Used in the function G.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member

@danceratopz danceratopz Sep 22, 2025

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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.
"""

Copy link
Member

Choose a reason for hiding this comment

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

Funny example, needs fixing anyway 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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

@SamWilsn
Copy link
Contributor

About 2.: Tldr: It's fine from my side, but.. The only comment I have is that the titles in the rendered doc might look a little strange with a period at the end of them. We could potentially modify docc to remove them again? It is kinda crazy to add a period for a linter only to remove them again in the doc flow, BUT, it does allow for consistent lint rules.

@SamWilsn What do you think of the point made here about docc?

Titles should never have a period, whether it's in the rendered output or the source input. The practical effect of this is that we always need to have a summary line before the first title in a docstring, but I think that actually makes a lot of sense.

@gurukamath
Copy link
Contributor Author

Titles should never have a period, whether it's in the rendered output or the source input. The practical effect of this is that we always need to have a summary line before the first title in a doc-string, but I think that actually makes a lot of sense.

I am going to add this to the issue #671 which is aimed at converting all the doc-strings into markdown. I think we should handle this post weld and enforce the following.

  1. All doc-strings should have the a summary at the start.
  2. The summary should be a single line and should end with a .
  3. There should be a blank line after the summary.

gurukamath and others added 3 commits September 23, 2025 12:17
Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com>
"""
(w - R1) value for a given Blake2 flavor.
Used in the function G
Used in the function G.
Copy link
Contributor

Choose a reason for hiding this comment

The 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



class EthereumException(Exception): # noqa N818
class EthereumException(Exception): # noqa N818
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want it to read EthereumException rather than EthereumError?

@gurukamath gurukamath merged commit 4ac7a9b into ethereum:forks/osaka Sep 25, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants