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

Split tox lint env into three envs, all safe #1870

Merged
merged 4 commits into from
Mar 14, 2024

Commits on Mar 13, 2024

  1. Clean up mention of manual hook stage

    This is no longer used. No pre-commit hook specifies it anymore in
    `stages`, since 517f83a (gitpython-developers#1865). See b059cd5 (gitpython-developers#1868) for context.
    
    In the lint.yml GitHub Actions workflow, this removes the
    extra_args key altogether, because all that would remain there is
    --all-files, which is already the default for that action, when
    the extra_args key is absent.
    EliahKagan committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    f788418 View commit details
    Browse the repository at this point in the history
  2. Split tox "lint" env into three envs, all safe

    It makes sense for ruff linting and ruff autoformatting to be
    easily runnable individually and to have their results be shown
    separately. Splitting them out in tox.ini also makes it so tox can
    do the other tests corresponding to those in lint.yml on CI in an
    environment that requries no custom behavior from pre-commit other
    than skipping the ruff checks.
    
    The ruff linting ("ruff") and ruff format checking ("format") tox
    environments specify ruff as a dependency and call it directly
    rather than through pre-commit, invoking it in such a way that it
    does not attempt to modify any files in the working tree.
    
    See b059cd5 (gitpython-developers#1868) for context. All three of these tox envs that
    "lint" has been split into are listed in the env_list and thus run
    automatically when tox is run with no arguments, since no tox envs
    unexpectedly (or at all) modify files in the working tree anymore.
    
    One limitation of the current approach is that new pre-commit hooks
    configured in .pre-commit-config.yml will automatically be run as
    part of the "misc" tox environment, which means that new unexpected
    mutating operatons could be added if the impact on tox is not
    considered. The benefit of having it work this way is that most
    hooks that are likely to be added to GitPython would not modify
    files and would be wanted as part of "misc". But this may benefit
    from further refinement.
    EliahKagan committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    4c034db View commit details
    Browse the repository at this point in the history
  3. Colorize ruff output when run through tox

    In most other situations it is typically already colorized.
    
    This also includes comments about how to override this to suppress
    color.
    EliahKagan committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    dcbd5db View commit details
    Browse the repository at this point in the history
  4. Colorize mypy output when run through tox

    On Unix-like systems, this approach is currently only sufficient if
    the TERM environment variable is set. In practice this means that
    if tox is run on CI, color will not be shown. Because GitPython
    does not itself use tox on CI, and other (e.g. downstream) projects
    may not want color on CI or in other situations where this would be
    insufficient, the further step of defining TERM as a workaround is
    deliberately omitted.
    
    See aeacb0 in gitpython-developers#1859 for what adding TERM would look like. This does
    not make any changes to how mypy runs on CI because that change is
    already included there.
    EliahKagan committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    89e519e View commit details
    Browse the repository at this point in the history