Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: update pre-commit hooks#957

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@wyardley
Copy link
Contributor

@wyardleywyardley commentedJun 15, 2024
edited
Loading

Note: the currentruff pre-commit checks check., however, there are multiple existing errors. Maybe it would make sense to switchruff to run on changed files only unless--all-files is passed? That would be gentler, especially if we're not requiring all these checks to pass (that said,#958 has some misc fixes that resolvesome of the outstanding flagged and non-ignored issues).

  • Update pre-commit hooks
  • Switch away from deprecated flag toruff
  • Resolve two minor pre-commit hook findings

Note: I still see the following finding frommypy:

semantic_release/cli/commands/publish.py: note: In function "publish":semantic_release/cli/commands/publish.py:66:9: error: "HvcsBase" has noattribute "upload_dists"  [attr-defined]            hvcs_client.upload_dists(tag=tag, dist_glob=pattern)            ^~~~~~~~~~~~~~~~~~~~~~~~Found 1 error in 1 file (checked 49 source files)

Maybe an inheritance issue with it being inremote_hvcs_base.py vs_base.py?

There is also some commented out code that ruff is flagging - I can remove in another PR if you'd like.

-id:ruff-format
name:ruff (format)
args:["."]
pass_filenames:false
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I think removing these two lines for both lint and fmt should switch it back to the more traditional behavior of only running on modified files, which IMO is the right behavior for a pre-commit hook (esp. since the checks run on everything in CI anyway)

Copy link
Contributor

Choose a reason for hiding this comment

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

concur. only lets keep it the same version that is inpyproject.toml for now, and then also see if there is a dependabot configuration for this file. That is how we keep ruff updated inpyproject.toml. There is a PR forruff currently from dependabot but i haven't merged it yet because honestlyruff is releasing so frequently it's annoying. I'm slow rolling the updates here for this dependency. Just for awareness, I have it locked to the specific patch version because if there is a bug fix that re-enables a rule it would arbitrarily cause the CI to break upon their release. I'm not okay with that so I'll just slow roll the merges as its only a dev dependency.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't think the hook version corresponds directly to the ruff version, though they may still be linked.

Not 100% sure on dependabot, but FWIW, Renovate does have experimental support (which works quite well) for keeping track of pre-commit hook versions.

I saw the comment, but I actually think (could be wrong) that having the old version of the pre-commit pinned here might be part of why people are seeing some fighting sometimes (as maybe the hook uses an internal version ofruff) tied to its own version?

I do see errors with the current ruff version if I runruff check locally as well, though (note: using Python 3.12 vs. 3.8, but the toml config does have target version set to 3.8) - do you not see that?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

per#958 (comment), adjusted to operate only on changed files. will double-check the behavior.

@wyardleywyardleyforce-pushed thewyardley/chore/minor_fixes branch 5 times, most recently from0d1e180 to9a7a1ccCompareJune 15, 2024 17:25
@wyardley
Copy link
ContributorAuthor

What I can do is pin back theruff pre-commit to the same version / tag as ruff itself... though we'd then want to update it later when#960 or something similar goes in

@codejedi365codejedi365force-pushed thewyardley/chore/minor_fixes branch fromff72154 tofd225bdCompareJune 17, 2024 19:04
@wyardley
Copy link
ContributorAuthor

However, the hook version doesn't seem to affect the version ofruff run.if I use--all-files, I do still see a couple errors withruff-lint, as well as onemypy error that doesn't seem to show up in CI. Either way, I think this will solve at least some of the problems with running it locally, but let me know if you want to pin back the pre-commit hook to match the ruff version.

Copy link
Contributor

@codejedi365codejedi365 left a comment

Choose a reason for hiding this comment

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

I bumped the project ruff version so that matches what is in the pre-commit definition. And then rebased this branch so that they are the same.

Also I did review theruff-pre-commit releases to find that each version corresponds to which ruff it uses under the hood.

@codejedi365
Copy link
Contributor

However, the hook version doesn't seem to affect the version ofruff run.if I use--all-files, I do still see a couple errors withruff-lint, as well as onemypy error that doesn't seem to show up in CI. Either way, I think this will solve at least some of the problems with running it locally, but let me know if you want to pin back the pre-commit hook to match the ruff version.

I really believe this is because the pre-commit is not reading our config in the pyproject.toml file because if you see the lint job in the ci we have to specify the configuration file to ruff. Why it doesn't do this by default is besides me but it changes what is flagged in the CI

wyardley reacted with thumbs up emoji

@wyardley
Copy link
ContributorAuthor

Also, just read that the lint should come before format if lint is run with—fix, so maybe I should switch the order?

@wyardley
Copy link
ContributorAuthor

Also, I can try adding that argument here and see if that fixes the issue.

@wyardley
Copy link
ContributorAuthor

wyardley commentedJun 17, 2024
edited
Loading

Also, I can try adding that argument here and see if that fixes the issue.

So, just FWIW, I checked and adding--config=pyproject.toml to the args for pre-commit config doesn't seem to change the behavior (also, I noticed that ruff does seem to pick up settings frompyproject.toml even when it's not called with that argument). If it matters, I'm also not seeing codes for the specific findings (for example,ERA001) ignored in the config file.

Playing around with it locally, Ithink the actual issue is that having the--diff flag set seems to suppress some of the findings. If you tryruff check --fix vsruff check --fix --diff

$ ruff check --fix[...]tests/unit/semantic_release/hvcs/test_gitlab.py:  612:5 SIM117 Use a single`with` statement with multiple contexts instead of nested`with` statementstests/util.py:  15:34 N812 Lowercase`config` imported as non-lowercase`cliConfigModule`Found 26 errors.$ ruff check --diff$echo$?0

So even though there are findings,ruff check --diff seems to be exiting 0 in any case (note: I think it's not printing anything else because there are nofixable findings, even though there are findings).

That said, we can leave this as it is here, and I can try ignoring and / or chipping away some of those other findings in another PR.

Also, I think with this change, at least ruff should now only run against modified files.

@wyardley
Copy link
ContributorAuthor

I'm trying to fix the mypy pre-commit issue with--all-files too, but may have to figure that out separately. It basically has to do with the way files are provided / passed

Just settingsemantic-release/ as a finalargs value doesn't seem to do it properly, probably because it expects filenames to be passed in last as a positional argument, but withpre-commit run --all-files, it's throwing at least one error

% mypy semantic_release                                                         Success: no issues found in 46 source files% python3 -m mypy --config pyproject.toml --ignore-missing-imports semantic_releaseSuccess: no issues found in 46 source files% pre-commit run --all-files[...]semantic_release/cli/commands/publish.py:66:9: error: "HvcsBase" has noattribute "upload_dists"  [attr-defined]            hvcs_client.upload_dists(tag=tag, dist_glob=pattern)            ^~~~~~~~~~~~~~~~~~~~~~~~Found 1 error in 1 file (checked 46 source files)

Another thing I can do separately, but Ithink with the versions ofmypy andruff we have, we may not need to set the config file anymore for either?

@wyardleywyardleyforce-pushed thewyardley/chore/minor_fixes branch fromfd225bd toa9aa2f1CompareJune 17, 2024 21:09
@wyardley
Copy link
ContributorAuthor

Threw up a draft first pass in#961 at the rest of the ruff failures and removing--diff from the CI job

@codejedi365
Copy link
Contributor

% python3 -m mypy --config pyproject.toml --ignore-missing-imports semantic_release
Success: no issues found in 46 source files
% pre-commit run --all-files
[...]
semantic_release/cli/commands/publish.py:66:9: error: "HvcsBase" has no
attribute "upload_dists" [attr-defined]
hvcs_client.upload_dists(tag=tag, dist_glob=pattern)
^~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 46 source files)

Let's just throw a# type: ignore on this because this will be refactored soon anyway.

Another thing I can do separately, but Ithink with the versions ofmypy andruff we have, we may not need to set the config file anymore for either?

Probably but not sure. The less command line arguments the better.

@wyardleywyardleyforce-pushed thewyardley/chore/minor_fixes branch froma9aa2f1 to79896e9CompareJune 18, 2024 05:36
- Update pre-commit hooks- Switch away from deprecated flag to `ruff`- Resolve two minor pre-commit hook findings
@wyardleywyardleyforce-pushed thewyardley/chore/minor_fixes branch from79896e9 toabddf84CompareJune 18, 2024 05:37
@wyardley
Copy link
ContributorAuthor

Probably but not sure. The less command line arguments the better.

Ok, see how you think this looks now - removed what I think should be unnecessary args, also added that ignore.

@codejedi365
Copy link
Contributor

Thanks 🎉

@codejedi365codejedi365 merged commitc54ec86 intopython-semantic-release:masterJun 18, 2024
@wyardleywyardley deleted the wyardley/chore/minor_fixes branchJune 20, 2024 20:32
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@codejedi365codejedi365codejedi365 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@wyardley@codejedi365

[8]ページ先頭

©2009-2025 Movatter.jp