mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 08:06:16 +00:00
fix(python): treat tomllib and newer stdlib modules as stdlib in import inference (#12670)
* fix(python): treat tomllib and other 3.11+ stdlib modules as stdlib in import inference STDIMPORTS predated several modules from sys.stdlib_module_names of Python 3.11-3.14 (tomllib, annotationlib, compression, ...), so 'import tomllib' was added to requirements.in and lock generation failed. Rebuild the list as the union of those versions' module names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(python): cover 3.10 and 3.15 stdlib modules in STDIMPORTS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2c2273cffb
commit
655562e805
@@ -749,11 +749,17 @@ fn extract_nimports_from_content(
|
||||
locked_version
|
||||
}
|
||||
|
||||
const STDIMPORTS: [&str; 303] = [
|
||||
// Union of `sys.stdlib_module_names` over every `PyVAlias` version (3.10 to 3.15), `_`
|
||||
// written as `-` like the inferred package names. Regenerate when a version is added;
|
||||
// modules a later version removed stay, since older workers still ship them.
|
||||
const STDIMPORTS: [&str; 332] = [
|
||||
"--future--",
|
||||
"-abc",
|
||||
"-aix-support",
|
||||
"-android-support",
|
||||
"-apple-support",
|
||||
"-ast",
|
||||
"-ast-unparse",
|
||||
"-asyncio",
|
||||
"-bisect",
|
||||
"-blake2",
|
||||
@@ -768,6 +774,7 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"-codecs-tw",
|
||||
"-collections",
|
||||
"-collections-abc",
|
||||
"-colorize",
|
||||
"-compat-pickle",
|
||||
"-compression",
|
||||
"-contextvars",
|
||||
@@ -786,18 +793,25 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"-gdbm",
|
||||
"-hashlib",
|
||||
"-heapq",
|
||||
"-hmac",
|
||||
"-imp",
|
||||
"-interpchannels",
|
||||
"-interpqueues",
|
||||
"-interpreters",
|
||||
"-io",
|
||||
"-ios-support",
|
||||
"-json",
|
||||
"-locale",
|
||||
"-lsprof",
|
||||
"-lzma",
|
||||
"-markupbase",
|
||||
"-math-integer",
|
||||
"-md5",
|
||||
"-msi",
|
||||
"-multibytecodec",
|
||||
"-multiprocessing",
|
||||
"-opcode",
|
||||
"-opcode-metadata",
|
||||
"-operator",
|
||||
"-osx-support",
|
||||
"-overlapped",
|
||||
@@ -805,11 +819,18 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"-posixshmem",
|
||||
"-posixsubprocess",
|
||||
"-py-abc",
|
||||
"-py-warnings",
|
||||
"-pydatetime",
|
||||
"-pydecimal",
|
||||
"-pyio",
|
||||
"-pylong",
|
||||
"-pyrepl",
|
||||
"-queue",
|
||||
"-random",
|
||||
"-remote-debugging",
|
||||
"-scproxy",
|
||||
"-sha1",
|
||||
"-sha2",
|
||||
"-sha256",
|
||||
"-sha3",
|
||||
"-sha512",
|
||||
@@ -824,20 +845,27 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"-string",
|
||||
"-strptime",
|
||||
"-struct",
|
||||
"-suggestions",
|
||||
"-symtable",
|
||||
"-sysconfig",
|
||||
"-thread",
|
||||
"-threading-local",
|
||||
"-tkinter",
|
||||
"-tokenize",
|
||||
"-tracemalloc",
|
||||
"-types",
|
||||
"-typing",
|
||||
"-uuid",
|
||||
"-warnings",
|
||||
"-weakref",
|
||||
"-weakrefset",
|
||||
"-winapi",
|
||||
"-wmi",
|
||||
"-zoneinfo",
|
||||
"zoneinfo",
|
||||
"-zstd",
|
||||
"abc",
|
||||
"aifc",
|
||||
"annotationlib",
|
||||
"antigravity",
|
||||
"argparse",
|
||||
"array",
|
||||
@@ -867,6 +895,7 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"collections",
|
||||
"colorsys",
|
||||
"compileall",
|
||||
"compression",
|
||||
"concurrent",
|
||||
"configparser",
|
||||
"contextlib",
|
||||
@@ -963,6 +992,7 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"posixpath",
|
||||
"pprint",
|
||||
"profile",
|
||||
"profiling",
|
||||
"pstats",
|
||||
"pty",
|
||||
"pwd",
|
||||
@@ -1024,6 +1054,7 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"tkinter",
|
||||
"token",
|
||||
"tokenize",
|
||||
"tomllib",
|
||||
"trace",
|
||||
"traceback",
|
||||
"tracemalloc",
|
||||
@@ -1052,5 +1083,6 @@ const STDIMPORTS: [&str; 303] = [
|
||||
"zipfile",
|
||||
"zipimport",
|
||||
"zlib",
|
||||
"zoneinfo",
|
||||
"",
|
||||
];
|
||||
|
||||
@@ -157,6 +157,24 @@ def main():
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_recent_stdlib_modules_not_inferred() -> anyhow::Result<()> {
|
||||
let code = "
|
||||
import tomllib
|
||||
import annotationlib
|
||||
from compression import zstd
|
||||
import requests
|
||||
|
||||
def main():
|
||||
return tomllib.loads(\"a = 1\")
|
||||
";
|
||||
assert_eq!(
|
||||
parse_code_for_imports(code, "f/foo/bar")?,
|
||||
vec![auto("requests")]
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_imports_recent_syntax_before_main() -> anyhow::Result<()> {
|
||||
let code = r#"
|
||||
|
||||
Reference in New Issue
Block a user