mirror of https://github.com/astral-sh/ruff
parent
7c824faa88
commit
6a28f3448e
|
|
@ -5,10 +5,96 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
(minor_version, module),
|
(minor_version, module),
|
||||||
(
|
(
|
||||||
_,
|
_,
|
||||||
"_ast"
|
"__hello__"
|
||||||
|
| "__phello__"
|
||||||
|
| "_abc"
|
||||||
|
| "_ast"
|
||||||
|
| "_asyncio"
|
||||||
|
| "_bisect"
|
||||||
|
| "_blake2"
|
||||||
|
| "_bz2"
|
||||||
|
| "_codecs"
|
||||||
|
| "_codecs_cn"
|
||||||
|
| "_codecs_hk"
|
||||||
|
| "_codecs_iso2022"
|
||||||
|
| "_codecs_jp"
|
||||||
|
| "_codecs_kr"
|
||||||
|
| "_codecs_tw"
|
||||||
|
| "_collections"
|
||||||
|
| "_collections_abc"
|
||||||
|
| "_compat_pickle"
|
||||||
|
| "_compression"
|
||||||
|
| "_contextvars"
|
||||||
|
| "_crypt"
|
||||||
|
| "_csv"
|
||||||
|
| "_ctypes"
|
||||||
|
| "_ctypes_test"
|
||||||
|
| "_curses"
|
||||||
|
| "_curses_panel"
|
||||||
|
| "_datetime"
|
||||||
|
| "_dbm"
|
||||||
|
| "_decimal"
|
||||||
|
| "_elementtree"
|
||||||
|
| "_frozen_importlib"
|
||||||
|
| "_frozen_importlib_external"
|
||||||
|
| "_functools"
|
||||||
|
| "_gdbm"
|
||||||
|
| "_hashlib"
|
||||||
|
| "_heapq"
|
||||||
|
| "_imp"
|
||||||
|
| "_io"
|
||||||
|
| "_json"
|
||||||
|
| "_locale"
|
||||||
|
| "_lsprof"
|
||||||
|
| "_lzma"
|
||||||
|
| "_markupbase"
|
||||||
|
| "_md5"
|
||||||
|
| "_msi"
|
||||||
|
| "_multibytecodec"
|
||||||
|
| "_multiprocessing"
|
||||||
|
| "_opcode"
|
||||||
|
| "_operator"
|
||||||
|
| "_osx_support"
|
||||||
|
| "_overlapped"
|
||||||
|
| "_pickle"
|
||||||
|
| "_posixsubprocess"
|
||||||
|
| "_py_abc"
|
||||||
|
| "_pydecimal"
|
||||||
|
| "_pyio"
|
||||||
|
| "_queue"
|
||||||
|
| "_random"
|
||||||
|
| "_scproxy"
|
||||||
|
| "_sha1"
|
||||||
|
| "_sha3"
|
||||||
|
| "_signal"
|
||||||
|
| "_sitebuiltins"
|
||||||
|
| "_socket"
|
||||||
|
| "_sqlite3"
|
||||||
|
| "_sre"
|
||||||
|
| "_ssl"
|
||||||
|
| "_stat"
|
||||||
|
| "_string"
|
||||||
|
| "_strptime"
|
||||||
|
| "_struct"
|
||||||
|
| "_symtable"
|
||||||
|
| "_testbuffer"
|
||||||
|
| "_testcapi"
|
||||||
|
| "_testconsole"
|
||||||
|
| "_testimportmultiple"
|
||||||
|
| "_testmultiphase"
|
||||||
| "_thread"
|
| "_thread"
|
||||||
|
| "_threading_local"
|
||||||
|
| "_tkinter"
|
||||||
|
| "_tracemalloc"
|
||||||
|
| "_uuid"
|
||||||
|
| "_warnings"
|
||||||
|
| "_weakref"
|
||||||
|
| "_weakrefset"
|
||||||
|
| "_winapi"
|
||||||
|
| "_xxtestfuzz"
|
||||||
| "abc"
|
| "abc"
|
||||||
| "aifc"
|
| "aifc"
|
||||||
|
| "antigravity"
|
||||||
| "argparse"
|
| "argparse"
|
||||||
| "array"
|
| "array"
|
||||||
| "ast"
|
| "ast"
|
||||||
|
|
@ -65,6 +151,7 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "ftplib"
|
| "ftplib"
|
||||||
| "functools"
|
| "functools"
|
||||||
| "gc"
|
| "gc"
|
||||||
|
| "genericpath"
|
||||||
| "getopt"
|
| "getopt"
|
||||||
| "getpass"
|
| "getpass"
|
||||||
| "gettext"
|
| "gettext"
|
||||||
|
|
@ -76,6 +163,7 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "hmac"
|
| "hmac"
|
||||||
| "html"
|
| "html"
|
||||||
| "http"
|
| "http"
|
||||||
|
| "idlelib"
|
||||||
| "imaplib"
|
| "imaplib"
|
||||||
| "imghdr"
|
| "imghdr"
|
||||||
| "importlib"
|
| "importlib"
|
||||||
|
|
@ -103,8 +191,11 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "netrc"
|
| "netrc"
|
||||||
| "nis"
|
| "nis"
|
||||||
| "nntplib"
|
| "nntplib"
|
||||||
|
| "nt"
|
||||||
| "ntpath"
|
| "ntpath"
|
||||||
|
| "nturl2path"
|
||||||
| "numbers"
|
| "numbers"
|
||||||
|
| "opcode"
|
||||||
| "operator"
|
| "operator"
|
||||||
| "optparse"
|
| "optparse"
|
||||||
| "os"
|
| "os"
|
||||||
|
|
@ -128,6 +219,8 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "py_compile"
|
| "py_compile"
|
||||||
| "pyclbr"
|
| "pyclbr"
|
||||||
| "pydoc"
|
| "pydoc"
|
||||||
|
| "pydoc_data"
|
||||||
|
| "pyexpat"
|
||||||
| "queue"
|
| "queue"
|
||||||
| "quopri"
|
| "quopri"
|
||||||
| "random"
|
| "random"
|
||||||
|
|
@ -173,8 +266,8 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "telnetlib"
|
| "telnetlib"
|
||||||
| "tempfile"
|
| "tempfile"
|
||||||
| "termios"
|
| "termios"
|
||||||
| "test"
|
|
||||||
| "textwrap"
|
| "textwrap"
|
||||||
|
| "this"
|
||||||
| "threading"
|
| "threading"
|
||||||
| "time"
|
| "time"
|
||||||
| "timeit"
|
| "timeit"
|
||||||
|
|
@ -205,13 +298,19 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "xdrlib"
|
| "xdrlib"
|
||||||
| "xml"
|
| "xml"
|
||||||
| "xmlrpc"
|
| "xmlrpc"
|
||||||
|
| "xx"
|
||||||
|
| "xxlimited"
|
||||||
|
| "xxsubtype"
|
||||||
| "zipapp"
|
| "zipapp"
|
||||||
| "zipfile"
|
| "zipfile"
|
||||||
| "zipimport"
|
| "zipimport"
|
||||||
| "zlib"
|
| "zlib"
|
||||||
) | (
|
) | (
|
||||||
7,
|
7,
|
||||||
"_dummy_thread"
|
"_bootlocale"
|
||||||
|
| "_dummy_thread"
|
||||||
|
| "_sha256"
|
||||||
|
| "_sha512"
|
||||||
| "asynchat"
|
| "asynchat"
|
||||||
| "asyncore"
|
| "asyncore"
|
||||||
| "binhex"
|
| "binhex"
|
||||||
|
|
@ -225,7 +324,14 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "symbol"
|
| "symbol"
|
||||||
) | (
|
) | (
|
||||||
8,
|
8,
|
||||||
"_dummy_thread"
|
"_bootlocale"
|
||||||
|
| "_dummy_thread"
|
||||||
|
| "_posixshmem"
|
||||||
|
| "_sha256"
|
||||||
|
| "_sha512"
|
||||||
|
| "_statistics"
|
||||||
|
| "_testinternalcapi"
|
||||||
|
| "_xxsubinterpreters"
|
||||||
| "asynchat"
|
| "asynchat"
|
||||||
| "asyncore"
|
| "asyncore"
|
||||||
| "binhex"
|
| "binhex"
|
||||||
|
|
@ -238,7 +344,18 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "symbol"
|
| "symbol"
|
||||||
) | (
|
) | (
|
||||||
9,
|
9,
|
||||||
"asynchat"
|
"_aix_support"
|
||||||
|
| "_bootlocale"
|
||||||
|
| "_bootsubprocess"
|
||||||
|
| "_peg_parser"
|
||||||
|
| "_posixshmem"
|
||||||
|
| "_sha256"
|
||||||
|
| "_sha512"
|
||||||
|
| "_statistics"
|
||||||
|
| "_testinternalcapi"
|
||||||
|
| "_xxsubinterpreters"
|
||||||
|
| "_zoneinfo"
|
||||||
|
| "asynchat"
|
||||||
| "asyncore"
|
| "asyncore"
|
||||||
| "binhex"
|
| "binhex"
|
||||||
| "distutils"
|
| "distutils"
|
||||||
|
|
@ -246,31 +363,80 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
| "graphlib"
|
| "graphlib"
|
||||||
| "imp"
|
| "imp"
|
||||||
| "parser"
|
| "parser"
|
||||||
|
| "peg_parser"
|
||||||
| "smtpd"
|
| "smtpd"
|
||||||
| "symbol"
|
| "symbol"
|
||||||
| "zoneinfo"
|
| "zoneinfo"
|
||||||
) | (
|
) | (
|
||||||
10,
|
10,
|
||||||
"asynchat"
|
"_aix_support"
|
||||||
|
| "_bootsubprocess"
|
||||||
|
| "_posixshmem"
|
||||||
|
| "_sha256"
|
||||||
|
| "_sha512"
|
||||||
|
| "_statistics"
|
||||||
|
| "_testclinic"
|
||||||
|
| "_testinternalcapi"
|
||||||
|
| "_xxsubinterpreters"
|
||||||
|
| "_zoneinfo"
|
||||||
|
| "asynchat"
|
||||||
| "asyncore"
|
| "asyncore"
|
||||||
| "binhex"
|
| "binhex"
|
||||||
| "distutils"
|
| "distutils"
|
||||||
| "graphlib"
|
| "graphlib"
|
||||||
| "idlelib"
|
|
||||||
| "imp"
|
| "imp"
|
||||||
| "smtpd"
|
| "smtpd"
|
||||||
|
| "xxlimited_35"
|
||||||
| "zoneinfo"
|
| "zoneinfo"
|
||||||
) | (
|
) | (
|
||||||
11,
|
11,
|
||||||
"asynchat"
|
"__hello_alias__"
|
||||||
|
| "__hello_only__"
|
||||||
|
| "__phello_alias__"
|
||||||
|
| "_aix_support"
|
||||||
|
| "_bootsubprocess"
|
||||||
|
| "_posixshmem"
|
||||||
|
| "_sha256"
|
||||||
|
| "_sha512"
|
||||||
|
| "_statistics"
|
||||||
|
| "_testclinic"
|
||||||
|
| "_testinternalcapi"
|
||||||
|
| "_tokenize"
|
||||||
|
| "_typing"
|
||||||
|
| "_xxsubinterpreters"
|
||||||
|
| "_zoneinfo"
|
||||||
|
| "asynchat"
|
||||||
| "asyncore"
|
| "asyncore"
|
||||||
| "distutils"
|
| "distutils"
|
||||||
| "graphlib"
|
| "graphlib"
|
||||||
| "idlelib"
|
|
||||||
| "imp"
|
| "imp"
|
||||||
| "smtpd"
|
| "smtpd"
|
||||||
| "tomllib"
|
| "tomllib"
|
||||||
|
| "xxlimited_35"
|
||||||
| "zoneinfo"
|
| "zoneinfo"
|
||||||
) | (12, "graphlib" | "idlelib" | "tomllib" | "zoneinfo")
|
) | (
|
||||||
|
12,
|
||||||
|
"__hello_alias__"
|
||||||
|
| "__hello_only__"
|
||||||
|
| "__phello_alias__"
|
||||||
|
| "_aix_support"
|
||||||
|
| "_posixshmem"
|
||||||
|
| "_pydatetime"
|
||||||
|
| "_pylong"
|
||||||
|
| "_sha2"
|
||||||
|
| "_statistics"
|
||||||
|
| "_testclinic"
|
||||||
|
| "_testinternalcapi"
|
||||||
|
| "_testsinglephase"
|
||||||
|
| "_tokenize"
|
||||||
|
| "_typing"
|
||||||
|
| "_xxinterpchannels"
|
||||||
|
| "_xxsubinterpreters"
|
||||||
|
| "_zoneinfo"
|
||||||
|
| "graphlib"
|
||||||
|
| "tomllib"
|
||||||
|
| "xxlimited_35"
|
||||||
|
| "zoneinfo"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,9 @@
|
||||||
"""Vendored from scripts/mkstdlibs.py in PyCQA/isort.
|
|
||||||
|
|
||||||
Source:
|
|
||||||
https://github.com/PyCQA/isort/blob/e321a670d0fefdea0e04ed9d8d696434cf49bdec/scripts/mkstdlibs.py
|
|
||||||
|
|
||||||
Only the generation of the file has been modified for use in this project.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from sphinx.ext.intersphinx import fetch_inventory
|
from stdlibs import stdlib_module_names
|
||||||
|
|
||||||
URL = "https://docs.python.org/{}/objects.inv"
|
|
||||||
PATH = Path("crates") / "ruff_python_stdlib" / "src" / "sys.rs"
|
PATH = Path("crates") / "ruff_python_stdlib" / "src" / "sys.rs"
|
||||||
VERSIONS: list[tuple[int, int]] = [
|
VERSIONS: list[tuple[int, int]] = [
|
||||||
(3, 7),
|
(3, 7),
|
||||||
|
|
@ -23,24 +14,12 @@ VERSIONS: list[tuple[int, int]] = [
|
||||||
(3, 12),
|
(3, 12),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class FakeConfig:
|
|
||||||
intersphinx_timeout = None
|
|
||||||
tls_verify = True
|
|
||||||
user_agent = ""
|
|
||||||
|
|
||||||
|
|
||||||
class FakeApp:
|
|
||||||
srcdir = ""
|
|
||||||
config = FakeConfig()
|
|
||||||
|
|
||||||
|
|
||||||
with PATH.open("w") as f:
|
with PATH.open("w") as f:
|
||||||
f.write(
|
f.write(
|
||||||
"""\
|
"""\
|
||||||
//! This file is generated by `scripts/generate_known_standard_library.py`
|
//! This file is generated by `scripts/generate_known_standard_library.py`
|
||||||
|
|
||||||
pub fn is_known_standard_library(minor_version: u32, module: &str) -> bool {
|
pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool {
|
||||||
matches!((minor_version, module),
|
matches!((minor_version, module),
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
@ -48,9 +27,6 @@ pub fn is_known_standard_library(minor_version: u32, module: &str) -> bool {
|
||||||
modules_by_version = {}
|
modules_by_version = {}
|
||||||
|
|
||||||
for major_version, minor_version in VERSIONS:
|
for major_version, minor_version in VERSIONS:
|
||||||
url = URL.format(f"{major_version}.{minor_version}")
|
|
||||||
invdata = fetch_inventory(FakeApp(), "", url)
|
|
||||||
|
|
||||||
modules = {
|
modules = {
|
||||||
"_ast",
|
"_ast",
|
||||||
"posixpath",
|
"posixpath",
|
||||||
|
|
@ -61,10 +37,9 @@ pub fn is_known_standard_library(minor_version: u32, module: &str) -> bool {
|
||||||
"sre",
|
"sre",
|
||||||
}
|
}
|
||||||
|
|
||||||
for module in invdata["py:module"]:
|
for module in stdlib_module_names(f"{major_version}.{minor_version}"):
|
||||||
root, *_ = module.split(".")
|
if module not in ["__future__", "__main__"]:
|
||||||
if root not in ["__future__", "__main__"]:
|
modules.add(module)
|
||||||
modules.add(root)
|
|
||||||
|
|
||||||
modules_by_version[minor_version] = modules
|
modules_by_version[minor_version] = modules
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[project]
|
[project]
|
||||||
name = "scripts"
|
name = "scripts"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = ["sphinx"]
|
dependencies = ["stdlibs"]
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue