Skip to content

✅ Use custom changing_dir instead of CLIRunner.isolated_filesystem to set working dir#15616

Merged
tiangolo merged 2 commits into
masterfrom
fix-typer-removed-isolated_filesystem
May 27, 2026
Merged

✅ Use custom changing_dir instead of CLIRunner.isolated_filesystem to set working dir#15616
tiangolo merged 2 commits into
masterfrom
fix-typer-removed-isolated_filesystem

Conversation

@YuriiMotov
Copy link
Copy Markdown
Member

@YuriiMotov YuriiMotov commented May 27, 2026

Description

Typer 0.26 removed CLIRunner.isolated_filesystem context manager that was used in tests to set working directory to temporary path.
So, FastAPI redistribute tests started to fail (they run with latest dependency versions) - see logs.

Here is where isolated_filesystem is used:

with runner.isolated_filesystem():

The fix is to use custom context manager as in fastapi-cloud-cli: https://github.com/fastapilabs/fastapi-cloud-cli/blob/1d807db95e43d598f74ddecb8e7ce107396a99fa/tests/utils.py#L11-L18

AI Disclaimer

No AI used

Checklist

  • This PR is an obvious typo fix, or it links to a GitHub Discussion for the proposed code change.
  • I added tests for the change.
  • The new or updated tests fail on the main branch and pass on this PR.
  • Coverage stays at 100%.
  • The documentation explains the change if needed.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 27, 2026

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing fix-typer-removed-isolated_filesystem (4984057) with master (59d4a80)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (dbfd55c) during the generation of this report, so 59d4a80 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Just to add, if we prefer to bring back CLIRunner.isolated_filesystem that's possible too. In Typer we could resolve all of its usages with tmp_path which is why I originally ended up removing it, but I don't feel strongly either way.

If we want to restore it, I can easily do so in fastapi/typer#1792, just let me know 🙂

Copy link
Copy Markdown
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

Thank you! 🚀


And I personally agree with just dropping isolated_filesystem, I would think if people need that, it would make more sense to use tmp_path from pytest or similar, I don't really think the CLI should provide that utility as that can come from testing utilities. I also suspect it was added to Click before there were any other options, but for us is probably safe to not have to keep supporting it.

@tiangolo tiangolo merged commit 57535ef into master May 27, 2026
38 checks passed
@tiangolo tiangolo deleted the fix-typer-removed-isolated_filesystem branch May 27, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants