From e6a3780c9496dba4119694fceff6e0bdd247f28c Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 02:36:40 +0530 Subject: [PATCH 01/12] feat: add --nocache option to prevent cache during formatting Signed-off-by: Pranay Pandey --- src/black/__init__.py | 23 ++++++++++++++++++----- src/black/concurrency.py | 29 ++++++++++++++++------------- tests/test_black.py | 18 ++++++++++++++++++ 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index c88aa4ef6c7..8a73a0aab11 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -505,6 +505,14 @@ def validate_regex( callback=read_pyproject_toml, help="Read configuration options from a configuration file.", ) +@click.option( + "--nocache", + is_flag=True, + help=( + "Do not use the cache when formatting files. This forces Black to reformat all files and not skip any unchanged file" + " Also prevents Black from updating the cache after formatting." + ), +) @click.pass_context def main( # noqa: C901 ctx: click.Context, @@ -536,6 +544,7 @@ def main( # noqa: C901 workers: Optional[int], src: tuple[str, ...], config: Optional[str], + nocache: bool, ) -> None: """The uncompromising code formatter.""" ctx.ensure_object(dict) @@ -694,7 +703,8 @@ def main( # noqa: C901 write_back=write_back, mode=mode, report=report, - lines=lines, + lines=lines, + nocache=nocache, ) else: from black.concurrency import reformat_many @@ -709,6 +719,7 @@ def main( # noqa: C901 mode=mode, report=report, workers=workers, + nocache=nocache, ) if verbose or not quiet: @@ -859,6 +870,7 @@ def reformat_one( report: "Report", *, lines: Collection[tuple[int, int]] = (), + nocache: bool = False, ) -> None: """Reformat a single file under `src` without spawning child processes. @@ -888,16 +900,17 @@ def reformat_one( ): changed = Changed.YES else: - cache = Cache.read(mode) - if write_back not in (WriteBack.DIFF, WriteBack.COLOR_DIFF): + cache = None if nocache else Cache.read(mode) + if not nocache and write_back not in (WriteBack.DIFF, WriteBack.COLOR_DIFF): if not cache.is_changed(src): changed = Changed.CACHED if changed is not Changed.CACHED and format_file_in_place( src, fast=fast, write_back=write_back, mode=mode, lines=lines ): changed = Changed.YES - if (write_back is WriteBack.YES and changed is not Changed.CACHED) or ( - write_back is WriteBack.CHECK and changed is Changed.NO + if not nocache and ( + (write_back is WriteBack.YES and changed is not Changed.CACHED) + or (write_back is WriteBack.CHECK and changed is Changed.NO) ): cache.write([src]) report.done(src, changed) diff --git a/src/black/concurrency.py b/src/black/concurrency.py index f6a2b8a93be..2c3ac4b364d 100644 --- a/src/black/concurrency.py +++ b/src/black/concurrency.py @@ -78,6 +78,7 @@ def reformat_many( mode: Mode, report: Report, workers: Optional[int], + nocache: bool = False, ) -> None: """Reformat multiple files using a ProcessPoolExecutor.""" maybe_install_uvloop() @@ -106,17 +107,18 @@ def reformat_many( loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) try: - loop.run_until_complete( - schedule_formatting( - sources=sources, - fast=fast, - write_back=write_back, - mode=mode, - report=report, - loop=loop, - executor=executor, + loop.run_until_complete( + schedule_formatting( + sources=sources, + fast=fast, + write_back=write_back, + mode=mode, + report=report, + loop=loop, + executor=executor, + nocache=nocache, + ) ) - ) finally: try: shutdown(loop) @@ -134,6 +136,7 @@ async def schedule_formatting( report: "Report", loop: asyncio.AbstractEventLoop, executor: "Executor", + nocache: bool = False, ) -> None: """Run formatting of `sources` in parallel using the provided `executor`. @@ -142,8 +145,8 @@ async def schedule_formatting( `write_back`, `fast`, and `mode` options are passed to :func:`format_file_in_place`. """ - cache = Cache.read(mode) - if write_back not in (WriteBack.DIFF, WriteBack.COLOR_DIFF): + cache = None if nocache else Cache.read(mode) + if not nocache and write_back not in (WriteBack.DIFF, WriteBack.COLOR_DIFF): sources, cached = cache.filtered_cached(sources) for src in sorted(cached): report.done(src, Changed.CACHED) @@ -194,5 +197,5 @@ async def schedule_formatting( report.done(src, changed) if cancelled: await asyncio.gather(*cancelled, return_exceptions=True) - if sources_to_cache: + if sources_to_cache and not nocache and cache is not None: cache.write(sources_to_cache) diff --git a/tests/test_black.py b/tests/test_black.py index 36ee7d9e1b9..c83857d8ac9 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2233,6 +2233,24 @@ def test_no_cache_when_stdin(self) -> None: cache_file = get_cache_file(mode) assert not cache_file.exists() + def test_nocache_flag_prevents_writes(self) -> None: + """--nocache should neither read nor write the cache; always do fresh analysis.""" + mode = DEFAULT_MODE + with cache_dir() as workspace: + src = (workspace / "test.py").resolve() + src.write_text("print('hello')", encoding="utf-8") + cache = black.Cache.read(mode) + # Pre-populate cache so the file is considered cached + cache.write([src]) + with ( + patch.object(black.Cache, "read") as read_cache, + patch.object(black.Cache, "write") as write_cache, + ): + # Pass --nocache; it should neither read nor write + invokeBlack([str(src), "--nocache"]) + read_cache.assert_not_called() + write_cache.assert_not_called() + def test_read_cache_no_cachefile(self) -> None: mode = DEFAULT_MODE with cache_dir(): From 7736e292d338b14996165a23ce0cd8b454308f7b Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 02:44:14 +0530 Subject: [PATCH 02/12] fix: improve formatting help text and adjust indentation in concurrency module --- src/black/__init__.py | 9 +++++---- src/black/concurrency.py | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 8a73a0aab11..f6a37858b2f 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -509,8 +509,9 @@ def validate_regex( "--nocache", is_flag=True, help=( - "Do not use the cache when formatting files. This forces Black to reformat all files and not skip any unchanged file" - " Also prevents Black from updating the cache after formatting." + "Do not use the cache when formatting files. This forces Black to reformat all" + " files and not skip any unchanged file Also prevents Black from updating the" + " cache after formatting." ), ) @click.pass_context @@ -703,8 +704,8 @@ def main( # noqa: C901 write_back=write_back, mode=mode, report=report, - lines=lines, - nocache=nocache, + lines=lines, + nocache=nocache, ) else: from black.concurrency import reformat_many diff --git a/src/black/concurrency.py b/src/black/concurrency.py index 2c3ac4b364d..c08e627a046 100644 --- a/src/black/concurrency.py +++ b/src/black/concurrency.py @@ -107,18 +107,18 @@ def reformat_many( loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) try: - loop.run_until_complete( - schedule_formatting( - sources=sources, - fast=fast, - write_back=write_back, - mode=mode, - report=report, - loop=loop, - executor=executor, - nocache=nocache, - ) + loop.run_until_complete( + schedule_formatting( + sources=sources, + fast=fast, + write_back=write_back, + mode=mode, + report=report, + loop=loop, + executor=executor, + nocache=nocache, ) + ) finally: try: shutdown(loop) From e322805bf3013d043cc9dbe9f58d00775a7352b0 Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 03:24:58 +0530 Subject: [PATCH 03/12] chore: rename nocache option to no-cache for consistency --- src/black/__init__.py | 19 +++++++++++-------- src/black/concurrency.py | 15 +++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index f6a37858b2f..93a8babfee3 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -506,7 +506,7 @@ def validate_regex( help="Read configuration options from a configuration file.", ) @click.option( - "--nocache", + "--no-cache", is_flag=True, help=( "Do not use the cache when formatting files. This forces Black to reformat all" @@ -545,7 +545,7 @@ def main( # noqa: C901 workers: Optional[int], src: tuple[str, ...], config: Optional[str], - nocache: bool, + no_cache: bool, ) -> None: """The uncompromising code formatter.""" ctx.ensure_object(dict) @@ -705,7 +705,7 @@ def main( # noqa: C901 mode=mode, report=report, lines=lines, - nocache=nocache, + no_cache=no_cache, ) else: from black.concurrency import reformat_many @@ -720,7 +720,7 @@ def main( # noqa: C901 mode=mode, report=report, workers=workers, - nocache=nocache, + no_cache=no_cache, ) if verbose or not quiet: @@ -871,7 +871,7 @@ def reformat_one( report: "Report", *, lines: Collection[tuple[int, int]] = (), - nocache: bool = False, + no_cache: bool = False, ) -> None: """Reformat a single file under `src` without spawning child processes. @@ -901,15 +901,18 @@ def reformat_one( ): changed = Changed.YES else: - cache = None if nocache else Cache.read(mode) - if not nocache and write_back not in (WriteBack.DIFF, WriteBack.COLOR_DIFF): + cache = None if no_cache else Cache.read(mode) + if cache is not None and write_back not in ( + WriteBack.DIFF, + WriteBack.COLOR_DIFF, + ): if not cache.is_changed(src): changed = Changed.CACHED if changed is not Changed.CACHED and format_file_in_place( src, fast=fast, write_back=write_back, mode=mode, lines=lines ): changed = Changed.YES - if not nocache and ( + if cache is not None and ( (write_back is WriteBack.YES and changed is not Changed.CACHED) or (write_back is WriteBack.CHECK and changed is Changed.NO) ): diff --git a/src/black/concurrency.py b/src/black/concurrency.py index c08e627a046..53a61456b63 100644 --- a/src/black/concurrency.py +++ b/src/black/concurrency.py @@ -78,7 +78,7 @@ def reformat_many( mode: Mode, report: Report, workers: Optional[int], - nocache: bool = False, + no_cache: bool = False, ) -> None: """Reformat multiple files using a ProcessPoolExecutor.""" maybe_install_uvloop() @@ -116,7 +116,7 @@ def reformat_many( report=report, loop=loop, executor=executor, - nocache=nocache, + no_cache=no_cache, ) ) finally: @@ -136,7 +136,7 @@ async def schedule_formatting( report: "Report", loop: asyncio.AbstractEventLoop, executor: "Executor", - nocache: bool = False, + no_cache: bool = False, ) -> None: """Run formatting of `sources` in parallel using the provided `executor`. @@ -145,8 +145,11 @@ async def schedule_formatting( `write_back`, `fast`, and `mode` options are passed to :func:`format_file_in_place`. """ - cache = None if nocache else Cache.read(mode) - if not nocache and write_back not in (WriteBack.DIFF, WriteBack.COLOR_DIFF): + cache = None if no_cache else Cache.read(mode) + if cache is not None and write_back not in ( + WriteBack.DIFF, + WriteBack.COLOR_DIFF, + ): sources, cached = cache.filtered_cached(sources) for src in sorted(cached): report.done(src, Changed.CACHED) @@ -197,5 +200,5 @@ async def schedule_formatting( report.done(src, changed) if cancelled: await asyncio.gather(*cancelled, return_exceptions=True) - if sources_to_cache and not nocache and cache is not None: + if sources_to_cache and not no_cache and cache is not None: cache.write(sources_to_cache) From bc740d4156fa6bc4035c716ad70dfb4d316fc2f7 Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 03:26:31 +0530 Subject: [PATCH 04/12] feat: add change log for no-cache and rename the option in test --- CHANGES.md | 4 ++++ src/test.py | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 src/test.py diff --git a/CHANGES.md b/CHANGES.md index cb71e3f4ec4..d655140e357 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,8 @@ +- Add `no_cache` option to control caching behavior. (#4803) + ### Packaging @@ -1696,6 +1698,7 @@ and the first release covered by our new ## 18.9b0 - numeric literals are now formatted by _Black_ (#452, #461, #464, #469): + - numeric literals are normalized to include `_` separators on Python 3.6+ code - added `--skip-numeric-underscore-normalization` to disable the above behavior and @@ -1745,6 +1748,7 @@ and the first release covered by our new - typing stub files (`.pyi`) now have blank lines added after constants (#340) - `# fmt: off` and `# fmt: on` are now much more dependable: + - they now work also within bracket pairs (#329) - they now correctly work across function/class boundaries (#335) diff --git a/src/test.py b/src/test.py new file mode 100644 index 00000000000..d4d064391b3 --- /dev/null +++ b/src/test.py @@ -0,0 +1,6 @@ +import importlib + +importlib.import_module("black") +print( + "import OK" +) # This is correctly using the black src. We are in cd src and using -m black uses it correctly From 451275b25d2e9f133afe1013271f8658394e2a7b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:57:03 +0000 Subject: [PATCH 05/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- CHANGES.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d655140e357..65eba6ce673 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1698,7 +1698,6 @@ and the first release covered by our new ## 18.9b0 - numeric literals are now formatted by _Black_ (#452, #461, #464, #469): - - numeric literals are normalized to include `_` separators on Python 3.6+ code - added `--skip-numeric-underscore-normalization` to disable the above behavior and @@ -1748,7 +1747,6 @@ and the first release covered by our new - typing stub files (`.pyi`) now have blank lines added after constants (#340) - `# fmt: off` and `# fmt: on` are now much more dependable: - - they now work also within bracket pairs (#329) - they now correctly work across function/class boundaries (#335) From de29d0e32f45f78737f20d395656bff6708c03aa Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 03:29:10 +0530 Subject: [PATCH 06/12] change --nocache option arg option to --no-cache --- src/test.py | 6 ------ tests/test_black.py | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 src/test.py diff --git a/src/test.py b/src/test.py deleted file mode 100644 index d4d064391b3..00000000000 --- a/src/test.py +++ /dev/null @@ -1,6 +0,0 @@ -import importlib - -importlib.import_module("black") -print( - "import OK" -) # This is correctly using the black src. We are in cd src and using -m black uses it correctly diff --git a/tests/test_black.py b/tests/test_black.py index c83857d8ac9..217c2e279d6 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2233,8 +2233,8 @@ def test_no_cache_when_stdin(self) -> None: cache_file = get_cache_file(mode) assert not cache_file.exists() - def test_nocache_flag_prevents_writes(self) -> None: - """--nocache should neither read nor write the cache; always do fresh analysis.""" + def test_no_cache_flag_prevents_writes(self) -> None: + """--no-cache should neither read nor write the cache""" mode = DEFAULT_MODE with cache_dir() as workspace: src = (workspace / "test.py").resolve() @@ -2246,8 +2246,8 @@ def test_nocache_flag_prevents_writes(self) -> None: patch.object(black.Cache, "read") as read_cache, patch.object(black.Cache, "write") as write_cache, ): - # Pass --nocache; it should neither read nor write - invokeBlack([str(src), "--nocache"]) + # Pass --no-cache; it should neither read nor write + invokeBlack([str(src), "--no-cache"]) read_cache.assert_not_called() write_cache.assert_not_called() From a01a20edb46509e50b3e9785bc747b34030330b3 Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 19:46:21 +0530 Subject: [PATCH 07/12] feat: add documentation and tests for --no-cache flag functionality --- .../file_collection_and_discovery.md | 11 +++++++ docs/usage_and_configuration/the_basics.md | 12 +++++++ src/black/__init__.py | 5 ++- tests/test_black.py | 31 +++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/docs/usage_and_configuration/file_collection_and_discovery.md b/docs/usage_and_configuration/file_collection_and_discovery.md index de1d5e6c11e..d62b0cf6379 100644 --- a/docs/usage_and_configuration/file_collection_and_discovery.md +++ b/docs/usage_and_configuration/file_collection_and_discovery.md @@ -29,6 +29,17 @@ in the directory you're running _Black_ from, set `BLACK_CACHE_DIR=.cache/black` _Black_ will then write the above files to `.cache/black`. Note that `BLACK_CACHE_DIR` will take precedence over `XDG_CACHE_HOME` if both are set. +### Disabling the cache with --no-cache + +If you need Black to always perform a fresh analysis and not consult or update the +on-disk cache, use the `--no-cache` flag. When provided, Black will neither read from +nor write to the per-user cache. This is useful for debugging, for CI runs where you +want a deterministic fresh run, or when you suspect cache corruption. + +Example: + +python -m black --no-cache . + ## .gitignore If `--exclude` is not set, _Black_ will automatically ignore files and directories in diff --git a/docs/usage_and_configuration/the_basics.md b/docs/usage_and_configuration/the_basics.md index 0c032261796..9af723f1618 100644 --- a/docs/usage_and_configuration/the_basics.md +++ b/docs/usage_and_configuration/the_basics.md @@ -227,6 +227,18 @@ All done! ✨ 🍰 ✨ 1 file would be reformatted. ``` +#### `--no-cache` + +Do not consult or update Black's per-user cache during this run. When `--no-cache` +is specified, Black will perform fresh analysis for all files and will neither read +from nor write to the cache. This is helpful for reproducing formatting results from +a clean run, debugging cache-related issues, or ensuring CI executes a fresh +formatting analysis every time. + +Example: + + python -m black --no-cache . + #### `--color` / `--no-color` Show (or do not show) colored diff. Only applies when `--diff` is given. diff --git a/src/black/__init__.py b/src/black/__init__.py index 93a8babfee3..46a7539a114 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -509,9 +509,8 @@ def validate_regex( "--no-cache", is_flag=True, help=( - "Do not use the cache when formatting files. This forces Black to reformat all" - " files and not skip any unchanged file Also prevents Black from updating the" - " cache after formatting." + "Skip reading and writing the cache, forcing Black to reformat all" + " included files." ), ) @click.pass_context diff --git a/tests/test_black.py b/tests/test_black.py index 217c2e279d6..1a68215dff9 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2251,6 +2251,37 @@ def test_no_cache_flag_prevents_writes(self) -> None: read_cache.assert_not_called() write_cache.assert_not_called() + def test_no_cache_with_multiple_files(self) -> None: + """Formatting multiple files with --no-cache should not read or write cache + and should format files normally.""" + mode = DEFAULT_MODE + with ( + cache_dir() as workspace, + ): + one = (workspace / "one.py").resolve() + one.write_text("print('hello')", encoding="utf-8") + two = (workspace / "two.py").resolve() + two.write_text("print('hello')", encoding="utf-8") + + # Pre-populate cache for `one` so it would normally be skipped + cache = black.Cache.read(mode) + cache.write([one]) + + with ( + patch.object(black.Cache, "read") as read_cache, + patch.object(black.Cache, "write") as write_cache, + ): + # Run Black over the directory with --no-cache + invokeBlack([str(workspace), "--no-cache"]) + + # Cache should not be consulted or updated + read_cache.assert_not_called() + write_cache.assert_not_called() + + # Both files should have been formatted (double quotes + newline) + assert one.read_text(encoding="utf-8") == 'print("hello")\n' + assert two.read_text(encoding="utf-8") == 'print("hello")\n' + def test_read_cache_no_cachefile(self) -> None: mode = DEFAULT_MODE with cache_dir(): From 25b1fb7bb280f1bd8e31c5943f18e0b7bb81d29a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:19:46 +0000 Subject: [PATCH 08/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/usage_and_configuration/the_basics.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/usage_and_configuration/the_basics.md b/docs/usage_and_configuration/the_basics.md index 9af723f1618..b7a33f727c9 100644 --- a/docs/usage_and_configuration/the_basics.md +++ b/docs/usage_and_configuration/the_basics.md @@ -229,15 +229,15 @@ All done! ✨ 🍰 ✨ #### `--no-cache` -Do not consult or update Black's per-user cache during this run. When `--no-cache` -is specified, Black will perform fresh analysis for all files and will neither read -from nor write to the cache. This is helpful for reproducing formatting results from -a clean run, debugging cache-related issues, or ensuring CI executes a fresh -formatting analysis every time. +Do not consult or update Black's per-user cache during this run. When `--no-cache` is +specified, Black will perform fresh analysis for all files and will neither read from +nor write to the cache. This is helpful for reproducing formatting results from a clean +run, debugging cache-related issues, or ensuring CI executes a fresh formatting analysis +every time. Example: - python -m black --no-cache . +python -m black --no-cache . #### `--color` / `--no-color` From 10766df2ad3272982ac955734522a0e550798003 Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 19:58:49 +0530 Subject: [PATCH 09/12] fix indentation in --no-cache flag --- src/black/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 46a7539a114..cd45202bbc2 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -509,8 +509,8 @@ def validate_regex( "--no-cache", is_flag=True, help=( - "Skip reading and writing the cache, forcing Black to reformat all" - " included files." + "Skip reading and writing the cache, forcing Black to reformat all" + " included files." ), ) @click.pass_context From 48fb874ab66cf3208fc15e29d523fe1642aa89a1 Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 20:23:17 +0530 Subject: [PATCH 10/12] fix: correct indentation in help text for --no-cache flag --- src/black/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index cd45202bbc2..079e95cf386 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -509,8 +509,8 @@ def validate_regex( "--no-cache", is_flag=True, help=( - "Skip reading and writing the cache, forcing Black to reformat all" - " included files." + "Skip reading and writing the cache, forcing Black to reformat all" + " included files." ), ) @click.pass_context From 2e9190ff2927d1c778a9a4d2dca837601f0d1caa Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 23:32:07 +0530 Subject: [PATCH 11/12] run black formatting on repo --- tests/test_black.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_black.py b/tests/test_black.py index 1a68215dff9..291dc01421e 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2255,9 +2255,7 @@ def test_no_cache_with_multiple_files(self) -> None: """Formatting multiple files with --no-cache should not read or write cache and should format files normally.""" mode = DEFAULT_MODE - with ( - cache_dir() as workspace, - ): + with (cache_dir() as workspace,): one = (workspace / "one.py").resolve() one.write_text("print('hello')", encoding="utf-8") two = (workspace / "two.py").resolve() From 32e5afb41252997564849026f207a9dc53d94335 Mon Sep 17 00:00:00 2001 From: Pranay Pandey Date: Tue, 21 Oct 2025 23:37:44 +0530 Subject: [PATCH 12/12] regenerate schema --- src/black/resources/black.schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/black/resources/black.schema.json b/src/black/resources/black.schema.json index ff517b5bbca..bbb3cdfbb84 100644 --- a/src/black/resources/black.schema.json +++ b/src/black/resources/black.schema.json @@ -150,6 +150,11 @@ "type": "boolean", "description": "Emit messages about files that were not changed or were ignored due to exclusion patterns. If Black is using a configuration file, a message detailing which one it is using will be emitted.", "default": false + }, + "no-cache": { + "type": "boolean", + "description": "Skip reading and writing the cache, forcing Black to reformat all included files.", + "default": false } } }