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

#12063 Deprecation helper function docstring handling consistent with Python 3.13 #12064

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

adiroiban
Copy link
Member

@adiroiban adiroiban commented Dec 21, 2023

Scope and purpose

Fixes #12063

In Python 3.13 the docstrings are stripped.

This causes some errors for our deprecation helpers.

Update the code to have the same behaviour to always strip and handle like Python 3.13.


From 3.13 release notes

Compiler now strip indents from docstrings. This will reduce the size of bytecode cache (e.g. .pyc file). For example, cache file size for sqlalchemy.orm.session in SQLAlchemy 2.0 is reduced by about 5%. This change will affect tools using docstrings, like doctest. (Contributed by Inada Naoki in gh-81283.)

@adiroiban
Copy link
Member Author

I am sending this for review as an initial feedback.

Not sure if for 3.13 we should handle the docstring stripped, while for older Python version keep the non-strip version.

I went with always strip for "future" compatibility.

needs-review

@@ -0,0 +1,2 @@
twisted.python.deprecate helper function will now always strip the docstrings.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "strip whitespace from the docstrings".

spaces = ""
if not trailer.strip():
# On Python 3.13 the docstring is already stripped.
# For older Python version we keep the trailer.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this sentence is quite accurate?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am also not sure what was going in there :(
This was done 2 months ago, and now I no longer remember what was the issue here.

I will try to review and update the docstring

@itamarst
Copy link
Contributor

itamarst commented Mar 4, 2024

@adiroiban Same as other PR; minor changes but you can feel free to merge.

@adiroiban
Copy link
Member Author

Many thanks for the review. Happy to see that Twisted on 3.13 gets some attention :)

Python 3.13.0 beta 1 is scheduled for 2024-05-07 with final release 3.13.0 2024-10-01

So we should have enough time to prepare Twisted for 3.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update docstring handling for Python 3.13
4 participants