From fb921d0dd19e832c4562f9ee2b8a5208cb15e2f9 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 2 Jun 2025 12:10:33 +0100 Subject: [PATCH 1/2] Update docs README for Python version inference from environment --- docs/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 1a9d9852c4..222e7fc5c7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -151,16 +151,18 @@ if sys.version_info >= (3, 10): print(sys.stdlib_module_names) ``` -By default, the lower bound of the project's [`requires-python`](<(https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#python-requires)>) field (from the `pyproject.toml`) is +By default, the lower bound of the project's [`requires-python`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#python-requires) field (from the `pyproject.toml`) is used as the target Python version, ensuring that features and symbols only available in newer Python versions are not used. -If the `requires-python` field is not available, the latest stable version supported by ty is used, -which is currently 3.13. +If the `requires-python` field is not available, however, but a virtual environment has been +configured or detected, ty will try to infer the Python version being used from the virtual +environment's metadata. -ty will not infer the Python version from the Python environment at this time. +If no virtual environment is present or inferring the Python version from the metadata fails, +applies, ty will fall back to the latest stable Python version supported by ty (currently 3.13). -The Python version may be explicitly specified using the +The Python version may also be explicitly specified using the [`python-version`](./reference/configuration.md#python-version) setting or the [`--python-version`](./reference/cli.md#ty-check--python-version) flag. From 59ec75a9f6a56728e9f77f14ed2d3d93112987c5 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 2 Jun 2025 12:23:01 +0100 Subject: [PATCH 2/2] review comments --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 222e7fc5c7..12de02829a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -155,12 +155,12 @@ By default, the lower bound of the project's [`requires-python`](https://packagi used as the target Python version, ensuring that features and symbols only available in newer Python versions are not used. -If the `requires-python` field is not available, however, but a virtual environment has been +If the `requires-python` field is not available but a virtual environment *has* been configured or detected, ty will try to infer the Python version being used from the virtual environment's metadata. If no virtual environment is present or inferring the Python version from the metadata fails, -applies, ty will fall back to the latest stable Python version supported by ty (currently 3.13). +ty will fall back to the latest stable Python version supported by ty (currently 3.13). The Python version may also be explicitly specified using the [`python-version`](./reference/configuration.md#python-version) setting or the