diff --git a/CHANGELOG.md b/CHANGELOG.md index 5861d24..a5c705d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,71 @@ # Changelog +## 0.0.1-alpha.9 + +### Typing semantics and features + +- Add generic inference for dataclasses ([#18443](https://github.com/astral-sh/ruff/pull/18443)) +- Add support for global `__debug__` constant ([#18540](https://github.com/astral-sh/ruff/pull/18540)) +- Argument type expansion for overload call evaluation ([#18382](https://github.com/astral-sh/ruff/pull/18382)) +- Exclude members starting with `_abc_` from a protocol interface ([#18467](https://github.com/astral-sh/ruff/pull/18467)) +- Infer `list[T]` for starred target in unpacking ([#18401](https://github.com/astral-sh/ruff/pull/18401)) +- Infer `list[T]` when unpacking non-tuple type ([#18438](https://github.com/astral-sh/ruff/pull/18438)) +- Support type annotation for legacy typing aliases for generic classes ([#18404](https://github.com/astral-sh/ruff/pull/18404)) +- Allow using `dataclasses.dataclass` as a function ([#18440](https://github.com/astral-sh/ruff/pull/18440)) +- Type narrowing for attribute/subscript assignments ([#18041](https://github.com/astral-sh/ruff/pull/18041)) + +### Diagnostics + +- Add hints to `invalid-type-form` for common mistakes ([#18543](https://github.com/astral-sh/ruff/pull/18543)) +- Add subdiagnostic suggestion to `unresolved-reference` diagnostic when variable exists on `self` ([#18444](https://github.com/astral-sh/ruff/pull/18444)) +- Track the origin of the `environment.python` setting for better error messages ([#18483](https://github.com/astral-sh/ruff/pull/18483)) + +### CLI + +- Fix `--python` argument for Windows, and improve error messages for bad `--python` arguments ([#18457](https://github.com/astral-sh/ruff/pull/18457)) + +### Bug fixes + +- Meta-type of type variables should be `type[..]` ([#18439](https://github.com/astral-sh/ruff/pull/18439)) +- Only consider a type `T` a subtype of a protocol `P` if all of `P`'s members are fully bound on `T` ([#18466](https://github.com/astral-sh/ruff/pull/18466)) +- Fix false positives for legacy `ParamSpec`s inside `Callable` type expressions ([#18426](https://github.com/astral-sh/ruff/pull/18426)) +- Fix panic when pulling types for `UnaryOp` expressions inside `Literal` slices ([#18536](https://github.com/astral-sh/ruff/pull/18536)) +- Fix panic when trying to pull types for attribute expressions inside `Literal` type expressions ([#18535](https://github.com/astral-sh/ruff/pull/18535)) +- Fix panic when trying to pull types for subscript expressions inside `Callable` type expressions ([#18534](https://github.com/astral-sh/ruff/pull/18534)) +- Treat lambda functions as instances of `types.FunctionType` ([#18431](https://github.com/astral-sh/ruff/pull/18431)) +- Implement disjointness between `Callable` and `SpecialForm` ([#18503](https://github.com/astral-sh/ruff/pull/18503)) + +### Server + +- Fix stale diagnostics in documents on Windows ([#18544](https://github.com/astral-sh/ruff/pull/18544)) +- Add support for `object.` completions ([#18468](https://github.com/astral-sh/ruff/pull/18468)) +- Only provide declarations and bindings as completions ([#18456](https://github.com/astral-sh/ruff/pull/18456)) + +### Documentation + +- Add `CONDA_PREFIX` to `--python` documentation ([#18574](https://github.com/astral-sh/ruff/pull/18574)) +- Update list of referenced environment variables ([#612](https://github.com/astral-sh/ty/pull/612)) +- Document how the default value for `python-version` is determined ([#18549](https://github.com/astral-sh/ruff/pull/18549)) +- Document the `"all"` option for `python-platform` ([#18548](https://github.com/astral-sh/ruff/pull/18548)) + +### Contributors + +- [@AlexWaygood](https://github.com/AlexWaygood) +- [@charliermarsh](https://github.com/charliermarsh) +- [@mtshiba](https://github.com/mtshiba) +- [@benbaror](https://github.com/benbaror) +- [@sharkdp](https://github.com/sharkdp) +- [@carljm](https://github.com/carljm) +- [@MichaReiser](https://github.com/MichaReiser) +- [@lipefree](https://github.com/lipefree) +- [@BurntSushi](https://github.com/BurntSushi) +- [@DetachHead](https://github.com/DetachHead) +- [@MatthewMckee4](https://github.com/MatthewMckee4) +- [@suneettipirneni](https://github.com/suneettipirneni) +- [@abhijeetbodas2001](https://github.com/abhijeetbodas2001) +- [@ibraheemdev](https://github.com/ibraheemdev) +- [@dhruvmanila](https://github.com/dhruvmanila) + ## 0.0.1-alpha.8 ### Typing semantics and features diff --git a/dist-workspace.toml b/dist-workspace.toml index 3ad3657..2ef3b36 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -1,7 +1,7 @@ [workspace] members = ["cargo:./ruff"] packages = ["ty"] -version = "0.0.1-alpha.8" +version = "0.0.1-alpha.9" # Config for 'dist' [dist] diff --git a/docs/reference/cli.md b/docs/reference/cli.md index ae4382b..719ebd3 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -65,9 +65,9 @@ over all configuration files.

Other command-line arguments (such as relative paths) will be resolved relative to the current working directory.

--python path

Path to the Python environment.

ty uses the Python environment to resolve type information and third-party dependencies.

-

If not specified, ty will attempt to infer it from the VIRTUAL_ENV environment variable or discover a .venv directory in the project root or working directory.

+

If not specified, ty will attempt to infer it from the VIRTUAL_ENV or CONDA_PREFIX environment variables, or discover a .venv directory in the project root or working directory.

If a path to a Python interpreter is provided, e.g., .venv/bin/python3, ty will attempt to find an environment two directories up from the interpreter's path, e.g., .venv. At this time, ty does not invoke the interpreter to determine the location of the environment. This means that ty will not resolve dynamic executables such as a shim.

-

ty will search in the resolved environments's site-packages directories for type information and third-party imports.

+

ty will search in the resolved environment's site-packages directories for type information and third-party imports.

--python-platform, --platform platform

Target platform to assume when resolving types.

This is used to specialize the type of sys.platform and will affect the visibility of platform-specific functions and attributes. If the value is set to all, no assumptions are made about the target platform. If unspecified, the current system's platform will be used.

--python-version, --target-version version

Python version to assume when resolving types.

diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index a2986ee..fac5fbe 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -76,6 +76,7 @@ python = "./.venv" Specifies the target platform that will be used to analyze the source code. If specified, ty will understand conditions based on comparisons with `sys.platform`, such as are commonly found in typeshed to reflect the differing contents of the standard library across platforms. +If `all` is specified, ty will assume that the source code can run on any platform. If no platform is specified, ty will use the current platform: - `win32` for Windows @@ -86,7 +87,7 @@ If no platform is specified, ty will use the current platform: **Default value**: `` -**Type**: `"win32" | "darwin" | "android" | "ios" | "linux" | str` +**Type**: `"win32" | "darwin" | "android" | "ios" | "linux" | "all" | str` **Example usage** (`pyproject.toml`): @@ -105,9 +106,18 @@ The version should be specified as a string in the format `M.m` where `M` is the and `m` is the minor (e.g. `"3.0"` or `"3.6"`). If a version is provided, ty will generate errors if the source code makes use of language features that are not supported in that version. -It will also understand conditionals based on comparisons with `sys.version_info`, such -as are commonly found in typeshed to reflect the differing contents of the standard -library across Python versions. + +If a version is not specified, ty will try the following techniques in order of preference +to determine a value: +1. Check for the `project.requires-python` setting in a `pyproject.toml` file + and use the minimum version from the specified range +2. Check for an activated or configured virtual environment + and use the Python version of that environment +3. Fall back to the default value (see below) + +For some language features, ty can also understand conditionals based on comparisons +with `sys.version_info`. These are commonly found in typeshed, for example, +to reflect the differing contents of the standard library across Python versions. **Default value**: `"3.13"` diff --git a/pyproject.toml b/pyproject.toml index 405213a..cc72c24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ty" -version = "0.0.1a8" +version = "0.0.1a9" requires-python = ">=3.8" dependencies = [] description = "An extremely fast Python type checker, written in Rust." diff --git a/ruff b/ruff index e2d96df..3aae1cd 160000 --- a/ruff +++ b/ruff @@ -1 +1 @@ -Subproject commit e2d96df50192803abe63cb0865b447c2552c2eff +Subproject commit 3aae1cd59b6490c72af055d28add6cc2f983e545 diff --git a/uv.lock b/uv.lock index e067f91..c4bca2b 100644 --- a/uv.lock +++ b/uv.lock @@ -762,7 +762,7 @@ wheels = [ [[package]] name = "ty" -version = "0.0.1a8" +version = "0.0.1a9" source = { editable = "." } [package.dev-dependencies]