Skip to content

ast, configparser, glob: Python 3.13 updates #12050

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

Merged

Conversation

@aminalaee aminalaee force-pushed the ast-configparser-glob-python3.13-update branch from d8f0a43 to 3df7443 Compare May 28, 2024 09:49
@aminalaee aminalaee force-pushed the ast-configparser-glob-python3.13-update branch from 853fb79 to c42ae89 Compare May 28, 2024 09:51
@aminalaee aminalaee changed the title ast, configparser, glob: Python3.13 updates ast, configparser, glob: Python 3.13 updates May 28, 2024

This comment has been minimized.

@aminalaee aminalaee marked this pull request as ready for review May 28, 2024 10:01
"DEFAULTSECT",
"MAX_INTERPOLATION_DEPTH",
"UNNAMED_SECTION",
"MultilineContinuationError",
Copy link
Member

Choose a reason for hiding this comment

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

You could shorten this by adding something like if sys.version_info >= (3, 13): __all__ += ["MultilineContinuationError"]. We can also get rid of the existing duplication of __all__ this way.

Copy link
Member

Choose a reason for hiding this comment

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

It's not possible to get rid of the existing duplication without stubtest complaining because it's a tuple in one branch but a list in the other branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah after 3.12 this is a tuple now, and in 3.13 there are a few additions and removals which makes editing it not simple

Copy link
Member

Choose a reason for hiding this comment

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

We could do something like this to make it more concise, but I personally think the nested sys.version_info branches are a bit confusing:

--- a/stdlib/configparser.pyi
+++ b/stdlib/configparser.pyi
@@ -5,32 +5,8 @@ from re import Pattern
 from typing import Any, ClassVar, Literal, TypeVar, overload
 from typing_extensions import TypeAlias
 
-if sys.version_info >= (3, 13):
-    __all__ = (
-        "NoSectionError",
-        "DuplicateOptionError",
-        "DuplicateSectionError",
-        "NoOptionError",
-        "InterpolationError",
-        "InterpolationDepthError",
-        "InterpolationMissingOptionError",
-        "InterpolationSyntaxError",
-        "ParsingError",
-        "MissingSectionHeaderError",
-        "ConfigParser",
-        "RawConfigParser",
-        "Interpolation",
-        "BasicInterpolation",
-        "ExtendedInterpolation",
-        "SectionProxy",
-        "ConverterMapping",
-        "DEFAULTSECT",
-        "MAX_INTERPOLATION_DEPTH",
-        "UNNAMED_SECTION",
-        "MultilineContinuationError",
-    )
-elif sys.version_info >= (3, 12):
-    __all__ = (
+if sys.version_info >= (3, 12):
+    __all__: tuple[str, ...] = (
         "NoSectionError",
         "DuplicateOptionError",
         "DuplicateSectionError",
@@ -46,12 +22,15 @@ elif sys.version_info >= (3, 12):
         "Interpolation",
         "BasicInterpolation",
         "ExtendedInterpolation",
-        "LegacyInterpolation",
         "SectionProxy",
         "ConverterMapping",
         "DEFAULTSECT",
         "MAX_INTERPOLATION_DEPTH",
     )
+    if sys.version_info >= (3, 13):
+        __all__ += ("UNNAMED_SECTION", "MultilineContinuationError")
+    else:
+        __all__ += ("LegacyInterpolation",)
 else:
     __all__ = [

Though it's verbose, I'd go with what this PR currently has for this module.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I didn't notice the list/tuple difference. It's OK to go with what we currently have then.

aminalaee and others added 2 commits June 1, 2024 13:44
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Copy link
Contributor

github-actions bot commented Jun 1, 2024

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 124d020 into python:main Jun 1, 2024
63 checks passed
@aminalaee aminalaee deleted the ast-configparser-glob-python3.13-update branch June 1, 2024 18:28
max-muoto pushed a commit to max-muoto/typeshed that referenced this pull request Sep 8, 2024
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@srittau srittau mentioned this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants