mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 13:15:06 +00:00

## Summary Added version 3.14 to the script generating the `known_stdlib.rs` file. Rebuilt the known stdlibs with latest version (2025.5.10) of [stdlibs Python lib](https://pypi.org/project/stdlibs/) (which added support for 3.14.0b1). _Note: Python 3.14 is now in [feature freeze](https://peps.python.org/pep-0745/) so the modules in stdlib should be stable._ _See also: #15506_ ## Test Plan The following command has been run. Using for tests the `compression` module which been introduced with Python 3.14. ```sh ruff check --no-cache --select I001 --target-version py314 --fix ``` With ruff 0.11.9: ```python import base64 import datetime import compression print(base64, compression, datetime) ``` With this PR: ```python import base64 import compression import datetime print(base64, compression, datetime) ```
72 lines
1.7 KiB
Python
72 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from stdlibs import stdlib_module_names
|
|
|
|
PATH = Path("crates") / "ruff_python_stdlib" / "src" / "sys" / "known_stdlib.rs"
|
|
VERSIONS: list[tuple[int, int]] = [
|
|
(3, 7),
|
|
(3, 8),
|
|
(3, 9),
|
|
(3, 10),
|
|
(3, 11),
|
|
(3, 12),
|
|
(3, 13),
|
|
(3, 14),
|
|
]
|
|
|
|
with PATH.open("w") as f:
|
|
f.write(
|
|
"""\
|
|
//! This file is generated by `scripts/generate_known_standard_library.py`
|
|
|
|
pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
|
matches!((minor_version, module),
|
|
""",
|
|
)
|
|
|
|
modules_by_version = {}
|
|
|
|
for major_version, minor_version in VERSIONS:
|
|
modules = set()
|
|
|
|
for module in stdlib_module_names(f"{major_version}.{minor_version}"):
|
|
if module != "__future__":
|
|
modules.add(module)
|
|
|
|
modules_by_version[minor_version] = modules
|
|
|
|
# First, add a case for the modules that are in all versions.
|
|
ubiquitous_modules = set.intersection(*modules_by_version.values())
|
|
|
|
f.write("(_, ")
|
|
for i, module in enumerate(sorted(ubiquitous_modules)):
|
|
if i > 0:
|
|
f.write(" | ")
|
|
f.write(f'"{module}"')
|
|
f.write(")")
|
|
f.write("\n")
|
|
|
|
# Next, add any version-specific modules.
|
|
for _major_version, minor_version in VERSIONS:
|
|
version_modules = set.difference(
|
|
modules_by_version[minor_version],
|
|
ubiquitous_modules,
|
|
)
|
|
|
|
f.write(" | ")
|
|
f.write(f"({minor_version}, ")
|
|
for i, module in enumerate(sorted(version_modules)):
|
|
if i > 0:
|
|
f.write(" | ")
|
|
f.write(f'"{module}"')
|
|
f.write(")")
|
|
f.write("\n")
|
|
|
|
f.write(
|
|
"""\
|
|
)
|
|
}
|
|
""",
|
|
)
|