-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ast
, configparser
, glob
: Python 3.13 updates
#12050
Conversation
d8f0a43
to
3df7443
Compare
853fb79
to
c42ae89
Compare
ast
, configparser
, glob
: Python3.13 updatesast
, configparser
, glob
: Python 3.13 updates
This comment has been minimized.
This comment has been minimized.
"DEFAULTSECT", | ||
"MAX_INTERPOLATION_DEPTH", | ||
"UNNAMED_SECTION", | ||
"MultilineContinuationError", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Ref: https://github.com/python/cpython/blob/9216a5336fc3c5b594bba1ae18779100c207b23f/Lib/glob.py#L267
https://github.com/python/cpython/blob/9216a5336fc3c5b594bba1ae18779100c207b23f/Lib/configparser.py#L371