[ty] Document `TY_CONFIG_FILE` (#22001)

This commit is contained in:
David Peter 2025-12-16 13:15:24 +01:00 committed by GitHub
parent b2b0ad38ea
commit 5b1d3ac9b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View File

@ -2,6 +2,15 @@
ty defines and respects the following environment variables: ty defines and respects the following environment variables:
### `TY_CONFIG_FILE`
Path to a `ty.toml` configuration file to use.
When set, ty will use this file for configuration instead of
discovering configuration files automatically.
Equivalent to the `--config-file` command-line argument.
### `TY_LOG` ### `TY_LOG`
If set, ty will use this value as the log level for its `--verbose` output. If set, ty will use this value as the log level for its `--verbose` output.

View File

@ -9,6 +9,7 @@ use ty_combine::Combine;
use ty_project::metadata::options::{EnvironmentOptions, Options, SrcOptions, TerminalOptions}; use ty_project::metadata::options::{EnvironmentOptions, Options, SrcOptions, TerminalOptions};
use ty_project::metadata::value::{RangedValue, RelativeGlobPattern, RelativePathBuf, ValueSource}; use ty_project::metadata::value::{RangedValue, RelativeGlobPattern, RelativePathBuf, ValueSource};
use ty_python_semantic::lint; use ty_python_semantic::lint;
use ty_static::EnvVars;
// Configures Clap v3-style help menu colors // Configures Clap v3-style help menu colors
const STYLES: Styles = Styles::styled() const STYLES: Styles = Styles::styled()
@ -121,7 +122,7 @@ pub(crate) struct CheckCommand {
/// The path to a `ty.toml` file to use for configuration. /// The path to a `ty.toml` file to use for configuration.
/// ///
/// While ty configuration can be included in a `pyproject.toml` file, it is not allowed in this context. /// While ty configuration can be included in a `pyproject.toml` file, it is not allowed in this context.
#[arg(long, env = "TY_CONFIG_FILE", value_name = "PATH")] #[arg(long, env = EnvVars::TY_CONFIG_FILE, value_name = "PATH")]
pub(crate) config_file: Option<SystemPathBuf>, pub(crate) config_file: Option<SystemPathBuf>,
/// The format to use for printing diagnostic messages. /// The format to use for printing diagnostic messages.

View File

@ -39,6 +39,14 @@ impl EnvVars {
/// when necessary, e.g. to watch for file system changes or a dedicated UI thread. /// when necessary, e.g. to watch for file system changes or a dedicated UI thread.
pub const TY_MAX_PARALLELISM: &'static str = "TY_MAX_PARALLELISM"; pub const TY_MAX_PARALLELISM: &'static str = "TY_MAX_PARALLELISM";
/// Path to a `ty.toml` configuration file to use.
///
/// When set, ty will use this file for configuration instead of
/// discovering configuration files automatically.
///
/// Equivalent to the `--config-file` command-line argument.
pub const TY_CONFIG_FILE: &'static str = "TY_CONFIG_FILE";
/// Used to detect an activated virtual environment. /// Used to detect an activated virtual environment.
pub const VIRTUAL_ENV: &'static str = "VIRTUAL_ENV"; pub const VIRTUAL_ENV: &'static str = "VIRTUAL_ENV";