mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-03 05:13:00 +00:00
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary #19990 didn't completely fix the base vs. child conda environment distinction, since it detected slightly different behavior than what I usually see in conda. E.g., I see something like the following: ``` (didn't yet activate conda, but base is active) ➜ printenv | grep CONDA CONDA_PYTHON_EXE=/opt/anaconda3/bin/python CONDA_PREFIX=/opt/anaconda3 CONDA_DEFAULT_ENV=base CONDA_EXE=/opt/anaconda3/bin/conda CONDA_SHLVL=1 CONDA_PROMPT_MODIFIER=(base) (activating conda) ➜ conda activate test (test is an active conda environment) ❯ printenv | grep CONDA CONDA_PREFIX=/opt/anaconda3/envs/test CONDA_PYTHON_EXE=/opt/anaconda3/bin/python CONDA_SHLVL=2 CONDA_PREFIX_1=/opt/anaconda3 CONDA_DEFAULT_ENV=test CONDA_PROMPT_MODIFIER=(test) CONDA_EXE=/opt/anaconda3/bin/conda ``` But the current behavior looks for `CONDA_DEFAULT_ENV = basename(CONDA_PREFIX)` for the base environment instead of the child environment, where we actually see this equality. This pull request fixes that and updates the tests correspondingly. ## Test Plan I updated the existing tests with the new behavior. Let me know if you want more tests. Note: It shouldn't be necessary to test for the case where we have `conda/envs/base`, since one should not be able to create such an environment (one with the name of `CONDA_DEFAULT_ENV`). --------- Co-authored-by: Aria Desires <aria.desires@gmail.com>
70 lines
2 KiB
Markdown
70 lines
2 KiB
Markdown
# Environment variables
|
||
|
||
ty defines and respects the following environment variables:
|
||
|
||
### `TY_LOG`
|
||
|
||
If set, ty will use this value as the log level for its `--verbose` output.
|
||
Accepts any filter compatible with the `tracing_subscriber` crate.
|
||
|
||
For example:
|
||
|
||
- `TY_LOG=uv=debug` is the equivalent of `-vv` to the command line
|
||
- `TY_LOG=trace` will enable all trace-level logging.
|
||
|
||
See the [tracing documentation](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#example-syntax)
|
||
for more.
|
||
|
||
### `TY_LOG_PROFILE`
|
||
|
||
If set to `"1"` or `"true"`, ty will enable flamegraph profiling.
|
||
This creates a `tracing.folded` file that can be used to generate flame graphs
|
||
for performance analysis.
|
||
|
||
### `TY_MAX_PARALLELISM`
|
||
|
||
Specifies an upper limit for the number of tasks ty is allowed to run in parallel.
|
||
|
||
For example, how many files should be checked in parallel.
|
||
This isn't the same as a thread limit. ty may spawn additional threads
|
||
when necessary, e.g. to watch for file system changes or a dedicated UI thread.
|
||
|
||
## Externally-defined variables
|
||
|
||
ty also reads the following externally defined environment variables:
|
||
|
||
### `CONDA_DEFAULT_ENV`
|
||
|
||
Used to determine the name of the active Conda environment.
|
||
|
||
### `CONDA_PREFIX`
|
||
|
||
Used to detect the path of an active Conda environment.
|
||
If both `VIRTUAL_ENV` and `CONDA_PREFIX` are present, `VIRTUAL_ENV` will be preferred.
|
||
|
||
### `_CONDA_ROOT`
|
||
|
||
Used to determine the root install path of Conda.
|
||
|
||
### `PYTHONPATH`
|
||
|
||
Adds additional directories to ty's search paths.
|
||
The format is the same as the shell’s PATH:
|
||
one or more directory pathnames separated by os appropriate pathsep
|
||
(e.g. colons on Unix or semicolons on Windows).
|
||
|
||
### `RAYON_NUM_THREADS`
|
||
|
||
Specifies an upper limit for the number of threads ty uses when performing work in parallel.
|
||
Equivalent to `TY_MAX_PARALLELISM`.
|
||
|
||
This is a standard Rayon environment variable.
|
||
|
||
### `VIRTUAL_ENV`
|
||
|
||
Used to detect an activated virtual environment.
|
||
|
||
### `XDG_CONFIG_HOME`
|
||
|
||
Path to user-level configuration directory on Unix systems.
|
||
|