ruff/crates
Micha Reiser 796819e7a0
[ty] Disallow std::env and io methods in most ty crates (#20046)
## Summary

We use the `System` abstraction in ty to abstract away the host/system
on which ty runs.
This has a few benefits:

* Tests can run in full isolation using a memory system (that uses an
in-memory file system)
* The LSP has a custom implementation where `read_to_string` returns the
content as seen by the editor (e.g. unsaved changes) instead of always
returning the content as it is stored on disk
* We don't require any file system polyfills for wasm in the browser


However, it does require extra care that we don't accidentally use
`std::fs` or `std::env` (etc.) methods in ty's code base (which is very
easy).

This PR sets up Clippy and disallows the most common methods, instead
pointing users towards the corresponding `System` methods.

The setup is a bit awkward because clippy doesn't support inheriting
configurations. That means, a crate can only override the entire
workspace configuration or not at all.
The approach taken in this PR is:

* Configure the disallowed methods at the workspace level
* Allow `disallowed_methods` at the workspace level
* Enable the lint at the crate level using the warn attribute (in code)


The obvious downside is that it won't work if we ever want to disallow
other methods, but we can figure that out once we reach that point.

What about false positives: Just add an `allow` and move on with your
life :) This isn't something that we have to enforce strictly; the goal
is to catch accidental misuse.

## Test Plan

Clippy found a place where we incorrectly used `std::fs::read_to_string`
2025-08-22 11:13:47 -07:00
..
ruff Bump 0.12.10 (#20025) 2025-08-21 13:09:31 -05:00
ruff_annotate_snippets Move full diagnostic rendering to ruff_db (#19415) 2025-08-08 12:56:23 -04:00
ruff_benchmark Feature/build riscv64 bin (#19819) 2025-08-14 16:11:14 +02:00
ruff_cache
ruff_db [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ruff_dev Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_diagnostics Fix rust feature activation (#20012) 2025-08-21 09:26:06 +02:00
ruff_formatter Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_graph [ty] Remove KnownModule::is_enum (#19681) 2025-08-01 10:31:12 +02:00
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter Add testing helper to compare stable vs preview snapshots (#19715) 2025-08-22 12:49:34 -05:00
ruff_macros Don't cache files with diagnostics (#19869) 2025-08-12 15:28:44 -04:00
ruff_memory_usage [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
ruff_notebook
ruff_options_metadata Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_ast [ruff] Handle empty t-strings in unnecessary-empty-iterable-within-deque-call (RUF037) (#20045) 2025-08-22 10:23:49 -05:00
ruff_python_ast_integration_tests Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_codegen Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_formatter Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_index
ruff_python_literal
ruff_python_parser Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_semantic Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_stdlib
ruff_python_trivia Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests
ruff_server Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_source_file Move diff rendering to ruff_db (#20006) 2025-08-21 09:47:00 -04:00
ruff_text_size [ty] Fix a few more diagnostic differences from Ruff (#19806) 2025-08-08 11:31:19 -04:00
ruff_wasm Bump 0.12.10 (#20025) 2025-08-21 13:09:31 -05:00
ruff_workspace Fix rust feature activation (#20012) 2025-08-21 09:26:06 +02:00
ty [ty] distinguish base conda from child conda (#19990) 2025-08-20 09:07:42 -04:00
ty_combine [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_ide [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_project [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_python_semantic [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_server [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_static [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_test [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_vendored [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_wasm [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00