Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13 support #2306

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion isort/stdlibs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import all as _all
from . import py2, py3, py27, py36, py37, py38, py39, py310, py311, py312
from . import py2, py3, py27, py36, py37, py38, py39, py310, py311, py312, py313
3 changes: 2 additions & 1 deletion isort/stdlibs/py3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import py36, py37, py38, py39, py310, py311, py312
from . import py36, py37, py38, py39, py310, py311, py312, py313

stdlib = (
py36.stdlib
Expand All @@ -8,4 +8,5 @@
| py310.stdlib
| py311.stdlib
| py312.stdlib
| py313.stdlib
)
5 changes: 5 additions & 0 deletions isort/stdlibs/py312.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"argparse",
"array",
"ast",
"asynchat",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these.

They were all removed in 3.12:

https://docs.python.org/3/whatsnew/3.12.html#asynchat-and-asyncore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove it, but it was added by the scripts. So it will automatically appear on the next run because it's still present in the corresponding documentation: https://docs.python.org/3.12/library/asynchat.html#module-asynchat

Mb it would be better to use stdlibs package or adopt it's approach to modules generation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, the problem was caused by the docs re-adding module pages which had bee removed, but as stubs:

python/cpython#126622

Mb it would be better to use stdlibs package or adopt it's approach to modules generation?

Yeah, sounds like a good idea to use stdlibs 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the script to use stdlibs and ran it

"asyncio",
"asyncore",
"atexit",
"audioop",
"base64",
Expand Down Expand Up @@ -52,6 +54,7 @@
"decimal",
"difflib",
"dis",
"distutils",
"doctest",
"email",
"encodings",
Expand Down Expand Up @@ -82,6 +85,7 @@
"idlelib",
"imaplib",
"imghdr",
"imp",
"importlib",
"inspect",
"io",
Expand Down Expand Up @@ -151,6 +155,7 @@
"signal",
"site",
"sitecustomize",
"smtpd",
"smtplib",
"sndhdr",
"socket",
Expand Down
224 changes: 224 additions & 0 deletions isort/stdlibs/py313.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
"""
File contains the standard library of Python 3.13.
DO NOT EDIT. If the standard library changes, a new list should be created
using the mkstdlibs.py script.
"""

stdlib = {
"_ast",
"_thread",
"_tkinter",
"abc",
"aifc",
"argparse",
"array",
"ast",
"asynchat",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this list contains lots of modules that have been removed in 3.12 or earlier.

Was this list created using the mkstdlibs.py script?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all changes to stdlibbs/py*.py were generated by mkstdlibs.py scripts

"asyncio",
"asyncore",
"atexit",
"audioop",
"base64",
"bdb",
"binascii",
"bisect",
"builtins",
"bz2",
"cProfile",
"calendar",
"cgi",
"cgitb",
"chunk",
"cmath",
"cmd",
"code",
"codecs",
"codeop",
"collections",
"colorsys",
"compileall",
"concurrent",
"configparser",
"contextlib",
"contextvars",
"copy",
"copyreg",
"crypt",
"csv",
"ctypes",
"curses",
"dataclasses",
"datetime",
"dbm",
"decimal",
"difflib",
"dis",
"distutils",
"doctest",
"email",
"encodings",
"ensurepip",
"enum",
"errno",
"faulthandler",
"fcntl",
"filecmp",
"fileinput",
"fnmatch",
"fractions",
"ftplib",
"functools",
"gc",
"getopt",
"getpass",
"gettext",
"glob",
"graphlib",
"grp",
"gzip",
"hashlib",
"heapq",
"hmac",
"html",
"http",
"idlelib",
"imaplib",
"imghdr",
"imp",
"importlib",
"inspect",
"io",
"ipaddress",
"itertools",
"json",
"keyword",
"linecache",
"locale",
"logging",
"lzma",
"mailbox",
"mailcap",
"marshal",
"math",
"mimetypes",
"mmap",
"modulefinder",
"msilib",
"msvcrt",
"multiprocessing",
"netrc",
"nis",
"nntplib",
"ntpath",
"numbers",
"operator",
"optparse",
"os",
"ossaudiodev",
"pathlib",
"pdb",
"pickle",
"pickletools",
"pipes",
"pkgutil",
"platform",
"plistlib",
"poplib",
"posix",
"posixpath",
"pprint",
"profile",
"pstats",
"pty",
"pwd",
"py_compile",
"pyclbr",
"pydoc",
"queue",
"quopri",
"random",
"re",
"readline",
"reprlib",
"resource",
"rlcompleter",
"runpy",
"sched",
"secrets",
"select",
"selectors",
"shelve",
"shlex",
"shutil",
"signal",
"site",
"sitecustomize",
"smtpd",
"smtplib",
"sndhdr",
"socket",
"socketserver",
"spwd",
"sqlite3",
"sre",
"sre_compile",
"sre_constants",
"sre_parse",
"ssl",
"stat",
"statistics",
"string",
"stringprep",
"struct",
"subprocess",
"sunau",
"symtable",
"sys",
"sysconfig",
"syslog",
"tabnanny",
"tarfile",
"telnetlib",
"tempfile",
"termios",
"test",
"textwrap",
"threading",
"time",
"timeit",
"tkinter",
"token",
"tokenize",
"tomllib",
"trace",
"traceback",
"tracemalloc",
"tty",
"turtle",
"turtledemo",
"types",
"typing",
"unicodedata",
"unittest",
"urllib",
"usercustomize",
"uu",
"uuid",
"venv",
"warnings",
"wave",
"weakref",
"webbrowser",
"winreg",
"winsound",
"wsgiref",
"xdrlib",
"xml",
"xmlrpc",
"zipapp",
"zipfile",
"zipimport",
"zlib",
"zoneinfo",
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
Expand Down
2 changes: 2 additions & 0 deletions scripts/mkstdlibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
("3", "10"),
("3", "11"),
("3", "12"),
("3", "13"),
]

DOCSTRING = """
Expand All @@ -24,6 +25,7 @@ class FakeConfig:
intersphinx_timeout = None
tls_verify = True
user_agent = ""
tls_cacerts = None


class FakeApp:
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_importable.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_importable():
import isort.stdlibs.py310
import isort.stdlibs.py311
import isort.stdlibs.py312
import isort.stdlibs.py313
import isort.utils
import isort.wrap
import isort.wrap_modes
Expand Down
Loading