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 --fix flag to ruff pre-commit hook for automatic suggestion of fixes #140

Merged
merged 2 commits into from
Aug 25, 2024

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Aug 12, 2024

This is documented in https://github.com/astral-sh/ruff-pre-commit?tab=readme-ov-file#using-ruff-with-pre-commit and should be safe to apply, because it requires the developer to "manually approve" the suggested changes via git add.

…fixes.

This is documented in https://github.com/astral-sh/ruff-pre-commit?tab=readme-ov-file#using-ruff-with-pre-commit and should be safe to apply, because it requires the developer to "manually approve the suggested changes via `git add`.
@bswck
Copy link
Contributor

bswck commented Aug 12, 2024

We might also be interested in --unsafe-fixes, but I'm not sure whether @jaraco's up to that

Copy link
Owner

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

I don't use pre-commit, so I'm fine with whatever. Should we add --unsafe-fixes or leave it as proposed? In my experience, I've almost always wanted --unsafe-fixes.

@abravalheri
Copy link
Contributor Author

abravalheri commented Aug 12, 2024

I have added --unsafe-fixes.

Since the developer still needs to manually git add any of the automatically suggested changes, it should be fine.

Worst case scenario if the suggestions are not desired, a couple of git restore ... commands followed by git commit --no-verify should be enough to bypass edge cases.

@Avasam
Copy link
Contributor

Avasam commented Aug 12, 2024

When used in CI, I personally prefer "unsafe fixes" from fixers, because you should self review anyway and it's clearly communicated that a bot made a commit for you.

As a git hook, idk if it might surprise someone to accidentally include a breaking change. I don't use pre-commit/pre-push hooks as I find they slow me down more than they help. So I don't really care either way.

Edit:

Since the developer still needs to manually git add any of the automatically suggested changes, it should be fine.

@jaraco jaraco merged commit 57b8aa8 into jaraco:main Aug 25, 2024
12 of 14 checks passed
@abravalheri abravalheri deleted the patch-1 branch August 25, 2024 10:21
clrpackages pushed a commit to clearlinux-pkgs/pypi-jaraco.collections that referenced this pull request Aug 30, 2024
…0.1 to version 5.1.0

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Avasam (4):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)
      Pass mypy and link issues
      Fully typed `RangeMap` and avoid complete iterations to find matches (#16)

Bartosz Sławecki (1):
      Move project metadata to `pyproject.toml` (jaraco/skeleton#122)

Dimitri Papadopoulos Orfanos (3):
      "preserve" does not require preview any more (jaraco/skeleton#133)
      Enforce ruff/Perflint rule PERF401 (jaraco/skeleton#132)
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (14):
      Pin against pytest 8.1.x due to pytest-dev/pytest#12194.
      Migrated config to pyproject.toml using jaraco.develop.migrate-config and ini2toml.
      Allow macos on Python 3.8 to fail as GitHub CI has dropped support.
      Move project.urls to appear in the order that ini2toml generates it. Remove project.scripts.
      Revert "Allow macos on Python 3.8 to fail as GitHub CI has dropped support."
      Rename extras to align with core metadata spec.
      Prefer "Source" to "Homepage" for the repository label.
      Exclude pytest-ruff (and thus ruff), which cannot build on cygwin.
      Re-enable preview, this time not for one specific feature, but for all features in preview.
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      Disable mypy for now. Ref jaraco/skeleton#143
      Finalize
      Remove unsupported attribution. See jaraco/skeleton#144.
clrpackages pushed a commit to clearlinux-pkgs/pypi-zipp that referenced this pull request Aug 30, 2024
…n 3.20.1

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Avasam (2):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)

Dimitri Papadopoulos Orfanos (1):
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (19):
      Uncomment link to the docs.
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      Add reference to development methodology.
      Disable mypy for now. Ref jaraco/skeleton#143
      Add two tests capturing the expectation for unsupported names.
      Adjust the expectation in test_malformed_paths to expect empty paths ignored and .. to be a path segment.
      Removed SanitizedNames.
      Address infinite loop when zipfile begins with more than one leading slash.
      Refine expectation that paths with leading slashes are simply not visible.
      Invent DirtyZipInfo to create an unsanitized zipfile with backslashes.
      Add news fragment.
      Mark unused code as uncovered.
      Prefer simpler path.rstrip to consolidate checks for empty or only paths.
      Add TODO to consolidate this behavior in CPython.
      Finalize
clrpackages pushed a commit to clearlinux-pkgs/pypi-setuptools that referenced this pull request Aug 30, 2024
…version 74.0.0

Anderson Bravalheri (11):
      Remove outdated import error check for warnings
      Satisfy ruff import format
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)
      Remove unnecessary conditional on TYPE_CHECKING
      Test setuptools own sdist does not include tox files
      Prune .tox directory
      Remove custom manifest_maker.prune_file_list and rely on default implementation in sdist
      Automatically exclude top-level .tox|.nox|.ven from sdist
      Test against false positve matches
      Account for windows path separators in tests
      Add missing news fragment for PR 4603

Avasam (18):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)
      Raise `TypeError` in `easy_install.CommandSpec.from_param`
      Type-check on all Python versions
      Pin Ruff to a lower bound rather than pinning pytest-ruff to an upper-bound
      Move static-checkers-only dependencies into their dedicated extras
      Avoid issues with  _build_ext being Any (#4599)
      `pkg_resources`: use `_typeshed.importlib.LoaderProtocol` (#4597)
      Make get_ext_filename typesafe (#4592)
      `pkg_resources` fully type all collection attributes (#4598)
      Made setuptools.package_index.Credential a NamedTuple (#4585)
      Initial pyright config (#4192)
      Type str/repr dunders (#4582)
      Type all get/set dunders
      Type all comparison/operators dunders (#4583)
      Type context manager dunders (#4581)
      Link to issues in mypy.ini for non py.typed dependencies (#4561)
      Reraise sensible errors from auto_chmod

Cal Jacobson (3):
      handle failures to find a user home directory
      Update distutils/dist.py
      format

Chris Barker (1):
      change VERSION to __version__ in the example (#4590)

Christoph Reiter (1):
      Remove unused wininst-*.exe files

Dimitri Papadopoulos (9):
      Apply ruff/tryceratops rule TRY300
      Apply ruff/tryceratops rule TRY301
      Enforce ruff/tryceratops rules (TRY)
      Enforce ruff/flake8-2020 rule (YTT301)
      Apply ruff/Perflint rule PERF102
      Apply ruff/Perflint rule PERF402
      Apply ruff/Perflint rule PERF403
      Enforce ruff/Perflint rules (PERF)
      Add `# local` to ignore conflicts with upstrea

Dimitri Papadopoulos Orfanos (1):
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (17):
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      Disable mypy for now. Ref jaraco/skeleton#143
      Simply suppress the exception.
      Sort imports
      Define the variable in one place.
      Extract logic around the mappings into a function to compute the spec.
      Tweak docstring
      Remove legacy msvc compiler modules.
      Remove associated tests
      Remove monkeypatching of _msvccompiler.
      Remove associated tests
      Apply downstream VS 2017 support.
      Apply error message from downstream.
      Add news fragment.
      Add news fragment.
      Bump version: 73.0.1 → 74.0.0

Kagami Sascha Rosylight (8):
      Use arm64 MSVC on arm64 Windows
      Check MSVC arm64 variant on arm64 host (#4555)
      conditionally construct PLAT_TO_VCVARS
      function-ify
      nit
      python supports comparison chains
      apply feedback
      restore the lost comment
clrpackages pushed a commit to clearlinux-pkgs/pypi-inflect that referenced this pull request Sep 10, 2024
…ion 7.4.0

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Avasam (2):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)

Dimitri Papadopoulos Orfanos (3):
      "preserve" does not require preview any more (jaraco/skeleton#133)
      Enforce ruff/Perflint rule PERF401 (jaraco/skeleton#132)
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (14):
      Exclude pytest-ruff (and thus ruff), which cannot build on cygwin.
      Re-enable preview, this time not for one specific feature, but for all features in preview.
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      🧎‍♀️ Genuflect to the types.
      Move comment
      Construct the _gend_sing dictionary statically.
      Disable mypy for now. Ref jaraco/skeleton#143
      Move overload-overlap disablement to its own line for easier diffs and simpler relevant comments.
      Add a degenerate nitpick_ignore for downstream consumers. Add a 'local' comment to delineate where the skeleton ends and the downstream begins.
      Add support for linking usernames.
      Include the trailing slash in disable_error_code(overload-overlap), also required for clean diffs.
      Add news fragment.
      Finalize

Josh Stephenson (1):
      Clarify that inflect is for English.

Mitchel Humpherys (2):
      Handle a single apostrophe more gracefully
      Add a test for a single-character apostrophe string
clrpackages pushed a commit to clearlinux-pkgs/pypi-importlib_resources that referenced this pull request Sep 10, 2024
….4.4 to version 6.4.5

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Jason R. Coombs (11):
      Add reference to development methodology.
      Disable mypy for now. Ref jaraco/skeleton#143
      Move overload-overlap disablement to its own line for easier diffs and simpler relevant comments.
      Add a degenerate nitpick_ignore for downstream consumers. Add a 'local' comment to delineate where the skeleton ends and the downstream begins.
      Add support for linking usernames.
      Include the trailing slash in disable_error_code(overload-overlap), also required for clean diffs.
      Fix typo in _temp_path comment.
      Add type annotations for _candidate_paths
      Add test capturing failure when resolving the MultiplexedPath for a namespace package with non-path elements in the path.
      Omit sentinel values from a namespace path.
      Finalize
clrpackages pushed a commit to clearlinux-pkgs/pypi-importlib_metadata that referenced this pull request Sep 16, 2024
…4.0 to version 8.5.0

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Avasam (4):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)
      Pass mypy and link issues
      Update tests/_path.py with jaraco.path 3.7.2

Daniel Hollas (3):
      Defer import of zipp
      Defer json import
      Defer platform import

Dimitri Papadopoulos Orfanos (1):
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (24):
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      👹 Feed the hobgoblins (delint).
      Remove superfluous parentheses.
      Rely on zipp overlay for zipfile.Path.
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      Add reference to development methodology.
      Disable mypy for now. Ref jaraco/skeleton#143
      Move overload-overlap disablement to its own line for easier diffs and simpler relevant comments.
      Add a degenerate nitpick_ignore for downstream consumers. Add a 'local' comment to delineate where the skeleton ends and the downstream begins.
      Add support for linking usernames.
      Include the trailing slash in disable_error_code(overload-overlap), also required for clean diffs.
      Add comment to protect the deferred import.
      Add news fragment.
      Revert "Defer platform import"
      Add comment to protect the deferred import.
      Add news fragment.
      Back out changes to tests._path
      Finalize
clrpackages pushed a commit to clearlinux-pkgs/pypi-keyring that referenced this pull request Sep 19, 2024
…sion 25.4.0

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Avasam (4):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)
      Re-enable mypy and add libraries to type checking
      Fix an incompatibility (and source of merge conflicts) with projects using Ruff/isort.

David Hotham (1):
      add a couple of type annotations

Dimitri Papadopoulos Orfanos (1):
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (16):
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      🧎‍♀️ Genuflect to the types.
      🧎‍♀️ Genuflect to the types.
      Restrict SimpleCredential to require a password.
      Introduce AnonymousCredential to support the use-case of a secret without a username.
      Add news fragment.
      Disable mypy for now. Ref jaraco/skeleton#143
      Move overload-overlap disablement to its own line for easier diffs and simpler relevant comments.
      Add a degenerate nitpick_ignore for downstream consumers. Add a 'local' comment to delineate where the skeleton ends and the downstream begins.
      Add support for linking usernames.
      Include the trailing slash in disable_error_code(overload-overlap), also required for clean diffs.
      Remove workaround for sphinx-contrib/sphinx-lint#83
      Allow the workflow to be triggered manually.
      Add Python 3.13 and 3.14 into the matrix. (jaraco/skeleton#146)
      Finalize
clrpackages pushed a commit to clearlinux-pkgs/pypi-jaraco.functools that referenced this pull request Oct 1, 2024
…2 to version 4.1.0

Anderson Bravalheri (1):
      Add `--fix`  flag to ruff pre-commit hook for automatic suggestion of fixes (jaraco/skeleton#140)

Avasam (4):
      Add Protocols, remove @overload, from `.coveragerc` `exclude_also` (jaraco/skeleton#135)
      Loosen restrictions on mypy (jaraco/skeleton#136)
      Strict typing
      Fix an incompatibility (and source of merge conflicts) with projects using Ruff/isort.

Dimitri Papadopoulos Orfanos (1):
      Update to the latest ruff version (jaraco/skeleton#137)

Jason R. Coombs (15):
      Split the test dependencies into four classes (test, cover, type, check). (jaraco/skeleton#139)
      Add upstream and local sections for 'type' extra, since many projects will have 'types-*' dependencies.
      Disable mypy for now. Ref jaraco/skeleton#143
      Move overload-overlap disablement to its own line for easier diffs and simpler relevant comments.
      Add a degenerate nitpick_ignore for downstream consumers. Add a 'local' comment to delineate where the skeleton ends and the downstream begins.
      Add support for linking usernames.
      Include the trailing slash in disable_error_code(overload-overlap), also required for clean diffs.
      Remove workaround for sphinx-contrib/sphinx-lint#83
      Allow the workflow to be triggered manually.
      Add Python 3.13 and 3.14 into the matrix. (jaraco/skeleton#146)
      Added chainable decorator.
      🚡 Toil the docs.
      Restore Python 3.8 compatibility.
      Use 'in' check to produce a bool.
      Finalize
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.

4 participants