diff --git a/.github/workflows/diff_shades.yml b/.github/workflows/diff_shades.yml index 68cc2383306..464e5e9b92f 100644 --- a/.github/workflows/diff_shades.yml +++ b/.github/workflows/diff_shades.yml @@ -3,10 +3,10 @@ name: diff-shades on: push: branches: [main] - paths-ignore: ["docs/**", "tests/**", "**.md", "**.rst"] + paths: ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"] pull_request: - paths-ignore: ["docs/**", "tests/**", "**.md", "**.rst"] + paths: ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"] workflow_dispatch: inputs: @@ -88,7 +88,8 @@ jobs: if: steps.baseline-cache.outputs.cache-hit != 'true' run: > diff-shades analyze -v --work-dir projects-cache/ - ${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.baseline-args }} + ${{ steps.config.outputs.baseline-analysis }} -- + ${{ steps.config.outputs.extra-args }} ${{ github.event.inputs.baseline-args }} - name: Build and install target revision env: @@ -102,7 +103,8 @@ jobs: run: > diff-shades analyze -v --work-dir projects-cache/ ${{ steps.config.outputs.target-analysis }} --repeat-projects-from - ${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.target-args }} + ${{ steps.config.outputs.baseline-analysis }} -- + ${{ steps.config.outputs.extra-args }} ${{ github.event.inputs.target-args }} - name: Generate HTML diff report run: > diff --git a/docs/contributing/gauging_changes.md b/docs/contributing/gauging_changes.md index 59c40eb3909..786a1317342 100644 --- a/docs/contributing/gauging_changes.md +++ b/docs/contributing/gauging_changes.md @@ -34,6 +34,11 @@ these rules: | On PRs | latest commit on `main` | PR commit with `main` merged | | On pushes (main only) | latest PyPI version | the pushed commit | +```{note} +Except for manually triggered runs, `preview=True` is forcefully set for all projects so +we can gauge the impact ahead of time (which is literally the purpose of this workflow). +``` + Once finished, a PR comment will be posted embedding a summary of the changes and links to further information. If there's a pre-existing diff-shades comment, it'll be updated instead the next time the workflow is triggered on the same PR. diff --git a/scripts/diff_shades_gha_helper.py b/scripts/diff_shades_gha_helper.py index f1f7f2be91c..d2df179dea3 100644 --- a/scripts/diff_shades_gha_helper.py +++ b/scripts/diff_shades_gha_helper.py @@ -185,6 +185,10 @@ def config( set_output("baseline-setup-cmd", baseline_cmd) set_output("target-analysis", target_name + ".json") set_output("target-setup-cmd", target_cmd) + # Except for manually triggered runs, it's more useful to force --preview for all + # projects so we can gauge the impact ahead of time (which is literally the purpose + # of this workflow). + set_output("extra-args", "" if event == "workflow_dispatch" else "--preview") key = f"{platform.system()}-{platform.python_version()}-{diff_shades.__version__}" key += f"-{baseline_name}-{baseline_args.encode('utf-8').hex()}" diff --git a/src/black/__init__.py b/src/black/__init__.py index 8c28b6ba18b..f58c7d7dfde 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -682,6 +682,9 @@ def reformat_code( report.failed(path, str(exc)) +# diff-shades depends on being to monkeypatch this function to operate. I know it's +# not ideal, but this shouldn't cause any issues ... hopefully. ~ichard26 +@mypyc_attr(patchable=True) def reformat_one( src: Path, fast: bool, write_back: WriteBack, mode: Mode, report: "Report" ) -> None: