From 307a66cfb023ca309f22357f20842f5416502c9e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 13 May 2024 12:12:00 -0400 Subject: [PATCH] Add Python 3.13 to list of allowed Python versions --- crates/ruff_linter/src/settings/types.rs | 2 + crates/ruff_python_formatter/src/options.rs | 1 + crates/ruff_python_stdlib/src/sys.rs | 182 +++++++++++++++++--- crates/ruff_workspace/src/configuration.rs | 1 + pyproject.toml | 1 + scripts/generate_known_standard_library.py | 1 + 6 files changed, 166 insertions(+), 22 deletions(-) diff --git a/crates/ruff_linter/src/settings/types.rs b/crates/ruff_linter/src/settings/types.rs index 77f9c5ed28d0e1..ce9f9abd057f8c 100644 --- a/crates/ruff_linter/src/settings/types.rs +++ b/crates/ruff_linter/src/settings/types.rs @@ -49,6 +49,7 @@ pub enum PythonVersion { Py310, Py311, Py312, + Py313, } impl From for Pep440Version { @@ -72,6 +73,7 @@ impl PythonVersion { Self::Py310 => (3, 10), Self::Py311 => (3, 11), Self::Py312 => (3, 12), + Self::Py313 => (3, 13), } } diff --git a/crates/ruff_python_formatter/src/options.rs b/crates/ruff_python_formatter/src/options.rs index 7b74c7b0d5a3cc..541bac549f5cdb 100644 --- a/crates/ruff_python_formatter/src/options.rs +++ b/crates/ruff_python_formatter/src/options.rs @@ -465,6 +465,7 @@ pub enum PythonVersion { Py310, Py311, Py312, + Py313, } impl PythonVersion { diff --git a/crates/ruff_python_stdlib/src/sys.rs b/crates/ruff_python_stdlib/src/sys.rs index 6c9e607a65c1cb..9cab56df9594ae 100644 --- a/crates/ruff_python_stdlib/src/sys.rs +++ b/crates/ruff_python_stdlib/src/sys.rs @@ -25,7 +25,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "_compat_pickle" | "_compression" | "_contextvars" - | "_crypt" | "_csv" | "_ctypes" | "_ctypes_test" @@ -49,7 +48,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "_lzma" | "_markupbase" | "_md5" - | "_msi" | "_multibytecodec" | "_multiprocessing" | "_opcode" @@ -93,14 +91,12 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "_winapi" | "_xxtestfuzz" | "abc" - | "aifc" | "antigravity" | "argparse" | "array" | "ast" | "asyncio" | "atexit" - | "audioop" | "base64" | "bdb" | "binascii" @@ -109,9 +105,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "bz2" | "cProfile" | "calendar" - | "cgi" - | "cgitb" - | "chunk" | "cmath" | "cmd" | "code" @@ -126,7 +119,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "contextvars" | "copy" | "copyreg" - | "crypt" | "csv" | "ctypes" | "curses" @@ -165,7 +157,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "http" | "idlelib" | "imaplib" - | "imghdr" | "importlib" | "inspect" | "io" @@ -173,24 +164,19 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "itertools" | "json" | "keyword" - | "lib2to3" | "linecache" | "locale" | "logging" | "lzma" | "mailbox" - | "mailcap" | "marshal" | "math" | "mimetypes" | "mmap" | "modulefinder" - | "msilib" | "msvcrt" | "multiprocessing" | "netrc" - | "nis" - | "nntplib" | "nt" | "ntpath" | "nturl2path" @@ -199,12 +185,10 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "operator" | "optparse" | "os" - | "ossaudiodev" | "pathlib" | "pdb" | "pickle" | "pickletools" - | "pipes" | "pkgutil" | "platform" | "plistlib" @@ -240,10 +224,8 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "signal" | "site" | "smtplib" - | "sndhdr" | "socket" | "socketserver" - | "spwd" | "sqlite3" | "sre_compile" | "sre_constants" @@ -255,14 +237,12 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "stringprep" | "struct" | "subprocess" - | "sunau" | "symtable" | "sys" | "sysconfig" | "syslog" | "tabnanny" | "tarfile" - | "telnetlib" | "tempfile" | "termios" | "textwrap" @@ -284,7 +264,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "unicodedata" | "unittest" | "urllib" - | "uu" | "uuid" | "venv" | "warnings" @@ -294,7 +273,6 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "winreg" | "winsound" | "wsgiref" - | "xdrlib" | "xml" | "xmlrpc" | "xx" @@ -307,45 +285,91 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { ) | ( 7, "_bootlocale" + | "_crypt" | "_dummy_thread" + | "_msi" | "_sha256" | "_sha512" + | "aifc" | "asynchat" | "asyncore" + | "audioop" | "binhex" + | "cgi" + | "cgitb" + | "chunk" + | "crypt" | "distutils" | "dummy_threading" | "formatter" + | "imghdr" | "imp" + | "lib2to3" | "macpath" + | "mailcap" + | "msilib" + | "nis" + | "nntplib" + | "ossaudiodev" | "parser" + | "pipes" | "smtpd" + | "sndhdr" + | "spwd" + | "sunau" | "symbol" + | "telnetlib" + | "uu" + | "xdrlib" ) | ( 8, "_bootlocale" + | "_crypt" | "_dummy_thread" + | "_msi" | "_posixshmem" | "_sha256" | "_sha512" | "_statistics" | "_testinternalcapi" | "_xxsubinterpreters" + | "aifc" | "asynchat" | "asyncore" + | "audioop" | "binhex" + | "cgi" + | "cgitb" + | "chunk" + | "crypt" | "distutils" | "dummy_threading" | "formatter" + | "imghdr" | "imp" + | "lib2to3" + | "mailcap" + | "msilib" + | "nis" + | "nntplib" + | "ossaudiodev" | "parser" + | "pipes" | "smtpd" + | "sndhdr" + | "spwd" + | "sunau" | "symbol" + | "telnetlib" + | "uu" + | "xdrlib" ) | ( 9, "_aix_support" | "_bootlocale" | "_bootsubprocess" + | "_crypt" + | "_msi" | "_peg_parser" | "_posixshmem" | "_sha256" @@ -354,22 +378,44 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "_testinternalcapi" | "_xxsubinterpreters" | "_zoneinfo" + | "aifc" | "asynchat" | "asyncore" + | "audioop" | "binhex" + | "cgi" + | "cgitb" + | "chunk" + | "crypt" | "distutils" | "formatter" | "graphlib" + | "imghdr" | "imp" + | "lib2to3" + | "mailcap" + | "msilib" + | "nis" + | "nntplib" + | "ossaudiodev" | "parser" | "peg_parser" + | "pipes" | "smtpd" + | "sndhdr" + | "spwd" + | "sunau" | "symbol" + | "telnetlib" + | "uu" + | "xdrlib" | "zoneinfo" ) | ( 10, "_aix_support" | "_bootsubprocess" + | "_crypt" + | "_msi" | "_posixshmem" | "_sha256" | "_sha512" @@ -378,13 +424,33 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "_testinternalcapi" | "_xxsubinterpreters" | "_zoneinfo" + | "aifc" | "asynchat" | "asyncore" + | "audioop" | "binhex" + | "cgi" + | "cgitb" + | "chunk" + | "crypt" | "distutils" | "graphlib" + | "imghdr" | "imp" + | "lib2to3" + | "mailcap" + | "msilib" + | "nis" + | "nntplib" + | "ossaudiodev" + | "pipes" | "smtpd" + | "sndhdr" + | "spwd" + | "sunau" + | "telnetlib" + | "uu" + | "xdrlib" | "xxlimited_35" | "zoneinfo" ) | ( @@ -394,6 +460,8 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "__phello_alias__" | "_aix_support" | "_bootsubprocess" + | "_crypt" + | "_msi" | "_posixshmem" | "_sha256" | "_sha512" @@ -404,13 +472,33 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "_typing" | "_xxsubinterpreters" | "_zoneinfo" + | "aifc" | "asynchat" | "asyncore" + | "audioop" + | "cgi" + | "cgitb" + | "chunk" + | "crypt" | "distutils" | "graphlib" + | "imghdr" | "imp" + | "lib2to3" + | "mailcap" + | "msilib" + | "nis" + | "nntplib" + | "ossaudiodev" + | "pipes" | "smtpd" + | "sndhdr" + | "spwd" + | "sunau" + | "telnetlib" | "tomllib" + | "uu" + | "xdrlib" | "xxlimited_35" | "zoneinfo" ) | ( @@ -419,17 +507,67 @@ pub fn is_known_standard_library(minor_version: u8, module: &str) -> bool { | "__hello_only__" | "__phello_alias__" | "_aix_support" + | "_crypt" + | "_msi" + | "_posixshmem" + | "_pydatetime" + | "_pylong" + | "_sha2" + | "_statistics" + | "_testclinic" + | "_testinternalcapi" + | "_testsinglephase" + | "_tokenize" + | "_typing" + | "_xxinterpchannels" + | "_xxsubinterpreters" + | "_zoneinfo" + | "aifc" + | "audioop" + | "cgi" + | "cgitb" + | "chunk" + | "crypt" + | "graphlib" + | "imghdr" + | "lib2to3" + | "mailcap" + | "msilib" + | "nis" + | "nntplib" + | "ossaudiodev" + | "pipes" + | "sndhdr" + | "spwd" + | "sunau" + | "telnetlib" + | "tomllib" + | "uu" + | "xdrlib" + | "xxlimited_35" + | "zoneinfo" + ) | ( + 13, + "__hello_alias__" + | "__hello_only__" + | "__phello_alias__" + | "_aix_support" + | "_opcode_metadata" | "_posixshmem" | "_pydatetime" | "_pylong" | "_sha2" | "_statistics" + | "_suggestions" + | "_sysconfig" | "_testclinic" + | "_testclinic_limited" | "_testinternalcapi" | "_testsinglephase" | "_tokenize" | "_typing" | "_xxinterpchannels" + | "_xxinterpqueues" | "_xxsubinterpreters" | "_zoneinfo" | "graphlib" diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index ec3bdbb2284fa9..240ab7a12fd8fc 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -181,6 +181,7 @@ impl Configuration { PythonVersion::Py310 => ruff_python_formatter::PythonVersion::Py310, PythonVersion::Py311 => ruff_python_formatter::PythonVersion::Py311, PythonVersion::Py312 => ruff_python_formatter::PythonVersion::Py312, + PythonVersion::Py313 => ruff_python_formatter::PythonVersion::Py313, }, line_width: self .line_length diff --git a/pyproject.toml b/pyproject.toml index 27616733420e69..66e9930223fbb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Rust", "Topic :: Software Development :: Libraries :: Python Modules", diff --git a/scripts/generate_known_standard_library.py b/scripts/generate_known_standard_library.py index de17282607635a..6205908b14d421 100644 --- a/scripts/generate_known_standard_library.py +++ b/scripts/generate_known_standard_library.py @@ -12,6 +12,7 @@ (3, 10), (3, 11), (3, 12), + (3, 13), ] with PATH.open("w") as f: