Skip to content

Ruff config - #14744

Merged
pllim merged 3 commits into
astropy:mainfrom
nstarman:ruff-config
May 9, 2023
Merged

pllim merged 3 commits into
astropy:mainfrom
nstarman:ruff-config

Conversation

@nstarman

@nstarman nstarman commented May 3, 2023

Copy link
Copy Markdown
Member

fixes #14736

@nstarman nstarman added this to the v6.0 milestone May 3, 2023
@github-actions

github-actions Bot commented May 3, 2023

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions

github-actions Bot commented May 3, 2023

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@nstarman
nstarman force-pushed the ruff-config branch 2 times, most recently from 3c2124a to 7375b37 Compare May 3, 2023 04:45
@nstarman
nstarman requested review from WilliamJamieson and pllim May 3, 2023 15:45
@nstarman nstarman mentioned this pull request May 3, 2023
@nstarman

nstarman commented May 3, 2023

Copy link
Copy Markdown
Member Author

First #14692, then this.

@nstarman
nstarman marked this pull request as ready for review May 3, 2023 17:37

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As noted in the issue, I'm not so sure this move is really needed, but if all agreed, then of course it is fine. PR itself is OK except for a strange unrelated change that seems to have slipped in.

Comment thread docs/conf.py Resolved
Comment thread .ruff.toml Resolved

@eerovaher eerovaher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ruff documentation says that if it finds ruff.toml then it doesn't normally bother reading pyproject.toml, but if we add extend = "pyproject.toml" to our ruff.toml then we can keep the permanent settings there and write out only the TODO items here. Having the permanent and TODO settings in different files would make it very simple to distinguish between the two, for maintainers and for new contributors alike.

Comment thread .ruff.toml Resolved
Comment thread .ruff.toml Outdated
"ANN",

# flake8-unused-arguments (ARG)
"ARG001", # unused-function-argument # 493 violations (2023-05-03)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think writing out these numbers adds much value. Writing out the command to obtain these numbers would be much more useful.

Suggested change
"ARG001", # unused-function-argument # 493 violations (2023-05-03)
"ARG001", # unused-function-argument

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The idea for this is to make it easy for maintainers / contributors to find an issue to work on -- essentially helpful triage. I don't think many / any people will run the command umpteen times before finding something suitable to work on.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ruff --select="ALL" --statistics . gives much the same information but its output is guaranteed to be up to date with no maintenance burden. Furthermore, some of these rules affect many files and we should encourage addressing them one subpackage at a time. In such cases the numbers listed in the file are not useful at all, but the command can be easily modified, e.g. ruff --select="ALL" --statistics astropy/time

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fine enough with me. I worry slightly that this is adding a step, reducing the odds someone volunteers to fix something. So far it's mostly been myself and @WilliamJamieson.

@nstarman

nstarman commented May 4, 2023

Copy link
Copy Markdown
Member Author

Ruff documentation says that if it finds ruff.toml then it doesn't normally bother reading pyproject.toml, but if we add extend = "pyproject.toml" to our ruff.toml then we can keep the permanent settings there and write out only the TODO items here. Having the permanent and TODO settings in different files would make it very simple to distinguish between the two, for maintainers and for new contributors alike.

I like this.

@nstarman
nstarman force-pushed the ruff-config branch 4 times, most recently from 02385d4 to c35d4ed Compare May 6, 2023 15:17

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks all good to me, thanks!

@pllim

pllim commented May 6, 2023

Copy link
Copy Markdown
Member

@eerovaher and @WilliamJamieson , please re-review. Thanks!

@eerovaher eerovaher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is almost ready to be merged, I only have one remark left.

Comment thread .ruff.toml Resolved
- per-subpackage fix loc
- Sort into permanent and TODO
- label number of violation

Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
Co-authored-by: Eero Vaher <[email protected]>
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
nstarman added 2 commits May 8, 2023 15:15
Deleted this. Might as well just fix.

Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
@nstarman
nstarman requested a review from eerovaher May 8, 2023 19:16
Comment thread .ruff.toml
Comment on lines +251 to +253
unfixable = [
"E711" # NoneComparison. Hard to fix b/c numpy has it's own None.
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this belong here or should it be in pyproject.toml?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would like to fix this eventually.
Or ask ruff if this can be detected with a sufficiently low false-positive rate.

@nstarman
nstarman requested a review from eerovaher May 8, 2023 20:47
@pllim
pllim merged commit a2717ae into astropy:main May 9, 2023
@pllim

pllim commented May 9, 2023

Copy link
Copy Markdown
Member

Thanks, all!

@nstarman
nstarman deleted the ruff-config branch May 9, 2023 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Create ruff.toml and re-organize the exception codes

5 participants