GH-137623: Use an AC decorator for docstring line length enforcement (#137690)

This commit is contained in:
Adam Turner 2025-08-18 18:29:00 +01:00 committed by GitHub
parent 0324c726de
commit 918e3ba6c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
76 changed files with 569 additions and 570 deletions

View file

@ -11046,6 +11046,7 @@ replace(PyObject *self, PyObject *str1,
/* --- Unicode Object Methods --------------------------------------------- */
/*[clinic input]
@permit_long_docstring_body
str.title as unicode_title
Return a version of the string where each word is titlecased.
@ -11056,12 +11057,13 @@ cased characters have lower case.
static PyObject *
unicode_title_impl(PyObject *self)
/*[clinic end generated code: output=c75ae03809574902 input=fa945d669b26e683]*/
/*[clinic end generated code: output=c75ae03809574902 input=533ce0eb6a7f5d1b]*/
{
return case_operation(self, do_title);
}
/*[clinic input]
@permit_long_docstring_body
str.capitalize as unicode_capitalize
Return a capitalized version of the string.
@ -11072,7 +11074,7 @@ case.
static PyObject *
unicode_capitalize_impl(PyObject *self)
/*[clinic end generated code: output=e49a4c333cdb7667 input=f4cbf1016938da6d]*/
/*[clinic end generated code: output=e49a4c333cdb7667 input=a4a15ade41f6f9e9]*/
{
if (PyUnicode_GET_LENGTH(self) == 0)
return unicode_result_unchanged(self);
@ -11720,6 +11722,7 @@ PyUnicode_AppendAndDel(PyObject **pleft, PyObject *right)
}
/*[clinic input]
@permit_long_summary
@text_signature "($self, sub[, start[, end]], /)"
str.count as unicode_count -> Py_ssize_t
@ -11737,7 +11740,7 @@ Optional arguments start and end are interpreted as in slice notation.
static Py_ssize_t
unicode_count_impl(PyObject *str, PyObject *substr, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=8fcc3aef0b18edbf input=6f168ffd94be8785]*/
/*[clinic end generated code: output=8fcc3aef0b18edbf input=8590716ee228b935]*/
{
assert(PyUnicode_Check(str));
assert(PyUnicode_Check(substr));
@ -11911,6 +11914,7 @@ unicode_expandtabs_impl(PyObject *self, int tabsize)
}
/*[clinic input]
@permit_long_summary
str.find as unicode_find = str.count
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].
@ -11922,7 +11926,7 @@ Return -1 on failure.
static Py_ssize_t
unicode_find_impl(PyObject *str, PyObject *substr, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=51dbe6255712e278 input=4a89d2d68ef57256]*/
/*[clinic end generated code: output=51dbe6255712e278 input=3a9d650fe4c24695]*/
{
Py_ssize_t result = any_find_slice(str, substr, start, end, 1);
if (result < 0) {
@ -11974,6 +11978,7 @@ unicode_hash(PyObject *self)
}
/*[clinic input]
@permit_long_summary
str.index as unicode_index = str.count
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].
@ -11985,7 +11990,7 @@ Raises ValueError when the substring is not found.
static Py_ssize_t
unicode_index_impl(PyObject *str, PyObject *substr, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=77558288837cdf40 input=d986aeac0be14a1c]*/
/*[clinic end generated code: output=77558288837cdf40 input=ae5e48f69ed75b06]*/
{
Py_ssize_t result = any_find_slice(str, substr, start, end, 1);
if (result == -1) {
@ -12014,6 +12019,7 @@ unicode_isascii_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.islower as unicode_islower
Return True if the string is a lowercase string, False otherwise.
@ -12024,7 +12030,7 @@ there is at least one cased character in the string.
static PyObject *
unicode_islower_impl(PyObject *self)
/*[clinic end generated code: output=dbd41995bd005b81 input=acec65ac6821ae47]*/
/*[clinic end generated code: output=dbd41995bd005b81 input=c6fc0295241a1aaa]*/
{
Py_ssize_t i, length;
int kind;
@ -12057,6 +12063,7 @@ unicode_islower_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isupper as unicode_isupper
Return True if the string is an uppercase string, False otherwise.
@ -12067,7 +12074,7 @@ there is at least one cased character in the string.
static PyObject *
unicode_isupper_impl(PyObject *self)
/*[clinic end generated code: output=049209c8e7f15f59 input=e9b1feda5d17f2d3]*/
/*[clinic end generated code: output=049209c8e7f15f59 input=8d5cb33e67efde72]*/
{
Py_ssize_t i, length;
int kind;
@ -12156,6 +12163,7 @@ unicode_istitle_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isspace as unicode_isspace
Return True if the string is a whitespace string, False otherwise.
@ -12166,7 +12174,7 @@ is at least one character in the string.
static PyObject *
unicode_isspace_impl(PyObject *self)
/*[clinic end generated code: output=163a63bfa08ac2b9 input=fe462cb74f8437d8]*/
/*[clinic end generated code: output=163a63bfa08ac2b9 input=44fe05e248c6e159]*/
{
Py_ssize_t i, length;
int kind;
@ -12194,6 +12202,7 @@ unicode_isspace_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isalpha as unicode_isalpha
Return True if the string is an alphabetic string, False otherwise.
@ -12204,7 +12213,7 @@ is at least one character in the string.
static PyObject *
unicode_isalpha_impl(PyObject *self)
/*[clinic end generated code: output=cc81b9ac3883ec4f input=d0fd18a96cbca5eb]*/
/*[clinic end generated code: output=cc81b9ac3883ec4f input=c233000624a56e0d]*/
{
Py_ssize_t i, length;
int kind;
@ -12231,6 +12240,7 @@ unicode_isalpha_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isalnum as unicode_isalnum
Return True if the string is an alpha-numeric string, False otherwise.
@ -12241,7 +12251,7 @@ there is at least one character in the string.
static PyObject *
unicode_isalnum_impl(PyObject *self)
/*[clinic end generated code: output=a5a23490ffc3660c input=5c6579bf2e04758c]*/
/*[clinic end generated code: output=a5a23490ffc3660c input=5d63ba9c9bafdb6b]*/
{
int kind;
const void *data;
@ -12270,6 +12280,7 @@ unicode_isalnum_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isdecimal as unicode_isdecimal
Return True if the string is a decimal string, False otherwise.
@ -12280,7 +12291,7 @@ there is at least one character in the string.
static PyObject *
unicode_isdecimal_impl(PyObject *self)
/*[clinic end generated code: output=fb2dcdb62d3fc548 input=336bc97ab4c8268f]*/
/*[clinic end generated code: output=fb2dcdb62d3fc548 input=8e84a58b414935a3]*/
{
Py_ssize_t i, length;
int kind;
@ -12307,6 +12318,7 @@ unicode_isdecimal_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isdigit as unicode_isdigit
Return True if the string is a digit string, False otherwise.
@ -12317,7 +12329,7 @@ is at least one character in the string.
static PyObject *
unicode_isdigit_impl(PyObject *self)
/*[clinic end generated code: output=10a6985311da6858 input=901116c31deeea4c]*/
/*[clinic end generated code: output=10a6985311da6858 input=99e284affb54d4a0]*/
{
Py_ssize_t i, length;
int kind;
@ -12345,6 +12357,7 @@ unicode_isdigit_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isnumeric as unicode_isnumeric
Return True if the string is a numeric string, False otherwise.
@ -12355,7 +12368,7 @@ least one character in the string.
static PyObject *
unicode_isnumeric_impl(PyObject *self)
/*[clinic end generated code: output=9172a32d9013051a input=722507db976f826c]*/
/*[clinic end generated code: output=9172a32d9013051a input=e9f5b6b8b29b0ee6]*/
{
Py_ssize_t i, length;
int kind;
@ -12425,6 +12438,7 @@ PyUnicode_IsIdentifier(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.isidentifier as unicode_isidentifier
Return True if the string is a valid Python identifier, False otherwise.
@ -12435,12 +12449,13 @@ such as "def" or "class".
static PyObject *
unicode_isidentifier_impl(PyObject *self)
/*[clinic end generated code: output=fe585a9666572905 input=2d807a104f21c0c5]*/
/*[clinic end generated code: output=fe585a9666572905 input=86315dd889d7bd04]*/
{
return PyBool_FromLong(PyUnicode_IsIdentifier(self));
}
/*[clinic input]
@permit_long_summary
str.isprintable as unicode_isprintable
Return True if all characters in the string are printable, False otherwise.
@ -12450,7 +12465,7 @@ A character is printable if repr() may use it in its output.
static PyObject *
unicode_isprintable_impl(PyObject *self)
/*[clinic end generated code: output=3ab9626cd32dd1a0 input=4e56bcc6b06ca18c]*/
/*[clinic end generated code: output=3ab9626cd32dd1a0 input=18345ba847084ec5]*/
{
Py_ssize_t i, length;
int kind;
@ -12474,6 +12489,7 @@ unicode_isprintable_impl(PyObject *self)
}
/*[clinic input]
@permit_long_docstring_body
str.join as unicode_join
iterable: object
@ -12489,7 +12505,7 @@ Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'
static PyObject *
unicode_join(PyObject *self, PyObject *iterable)
/*[clinic end generated code: output=6857e7cecfe7bf98 input=2f70422bfb8fa189]*/
/*[clinic end generated code: output=6857e7cecfe7bf98 input=bac724ed412ef3f8]*/
{
return PyUnicode_Join(self, iterable);
}
@ -12710,6 +12726,7 @@ do_argstrip(PyObject *self, int striptype, PyObject *sep)
/*[clinic input]
@permit_long_summary
str.strip as unicode_strip
chars: object = None
@ -12722,7 +12739,7 @@ If chars is given and not None, remove characters in chars instead.
static PyObject *
unicode_strip_impl(PyObject *self, PyObject *chars)
/*[clinic end generated code: output=ca19018454345d57 input=385289c6f423b954]*/
/*[clinic end generated code: output=ca19018454345d57 input=8bc6353450345fbd]*/
{
return do_argstrip(self, BOTHSTRIP, chars);
}
@ -12833,6 +12850,7 @@ PyUnicode_Replace(PyObject *str,
}
/*[clinic input]
@permit_long_docstring_body
str.replace as unicode_replace
old: unicode
@ -12851,12 +12869,13 @@ replaced.
static PyObject *
unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new,
Py_ssize_t count)
/*[clinic end generated code: output=b63f1a8b5eebf448 input=3345c455d60a5499]*/
/*[clinic end generated code: output=b63f1a8b5eebf448 input=f27ca92ac46b65a1]*/
{
return replace(self, old, new, count);
}
/*[clinic input]
@permit_long_docstring_body
str.removeprefix as unicode_removeprefix
prefix: unicode
@ -12870,7 +12889,7 @@ Otherwise, return a copy of the original string.
static PyObject *
unicode_removeprefix_impl(PyObject *self, PyObject *prefix)
/*[clinic end generated code: output=f1e5945e9763bcb9 input=27ec40b99a37eb88]*/
/*[clinic end generated code: output=f1e5945e9763bcb9 input=1989a856dbb813f1]*/
{
int match = tailmatch(self, prefix, 0, PY_SSIZE_T_MAX, -1);
if (match == -1) {
@ -13003,6 +13022,7 @@ unicode_repr(PyObject *unicode)
}
/*[clinic input]
@permit_long_summary
str.rfind as unicode_rfind = str.count
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
@ -13014,7 +13034,7 @@ Return -1 on failure.
static Py_ssize_t
unicode_rfind_impl(PyObject *str, PyObject *substr, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=880b29f01dd014c8 input=898361fb71f59294]*/
/*[clinic end generated code: output=880b29f01dd014c8 input=7f7e97d5cd3299a2]*/
{
Py_ssize_t result = any_find_slice(str, substr, start, end, -1);
if (result < 0) {
@ -13024,6 +13044,7 @@ unicode_rfind_impl(PyObject *str, PyObject *substr, Py_ssize_t start,
}
/*[clinic input]
@permit_long_summary
str.rindex as unicode_rindex = str.count
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
@ -13035,7 +13056,7 @@ Raises ValueError when the substring is not found.
static Py_ssize_t
unicode_rindex_impl(PyObject *str, PyObject *substr, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=5f3aef124c867fe1 input=35943dead6c1ea9d]*/
/*[clinic end generated code: output=5f3aef124c867fe1 input=0363a324740b3e62]*/
{
Py_ssize_t result = any_find_slice(str, substr, start, end, -1);
if (result == -1) {
@ -13079,6 +13100,7 @@ PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
}
/*[clinic input]
@permit_long_summary
str.split as unicode_split
sep: object = None
@ -13103,7 +13125,7 @@ the regular expression module.
static PyObject *
unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
/*[clinic end generated code: output=3a65b1db356948dc input=a29bcc0c7a5af0eb]*/
/*[clinic end generated code: output=3a65b1db356948dc input=2c1fd08a78e038b8]*/
{
if (sep == Py_None)
return split(self, NULL, maxsplit);
@ -13220,6 +13242,7 @@ PyUnicode_RPartition(PyObject *str_obj, PyObject *sep_obj)
}
/*[clinic input]
@permit_long_docstring_body
str.partition as unicode_partition
sep: object
@ -13237,12 +13260,13 @@ and two empty strings.
static PyObject *
unicode_partition(PyObject *self, PyObject *sep)
/*[clinic end generated code: output=e4ced7bd253ca3c4 input=f29b8d06c63e50be]*/
/*[clinic end generated code: output=e4ced7bd253ca3c4 input=4d854b520d7b0e97]*/
{
return PyUnicode_Partition(self, sep);
}
/*[clinic input]
@permit_long_docstring_body
str.rpartition as unicode_rpartition = str.partition
Partition the string into three parts using the given separator.
@ -13257,7 +13281,7 @@ and the original string.
static PyObject *
unicode_rpartition(PyObject *self, PyObject *sep)
/*[clinic end generated code: output=1aa13cf1156572aa input=c4b7db3ef5cf336a]*/
/*[clinic end generated code: output=1aa13cf1156572aa input=a6adabe91e75b486]*/
{
return PyUnicode_RPartition(self, sep);
}
@ -13272,6 +13296,7 @@ PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
}
/*[clinic input]
@permit_long_summary
str.rsplit as unicode_rsplit = str.split
Return a list of the substrings in the string, using sep as the separator string.
@ -13281,7 +13306,7 @@ Splitting starts at the end of the string and works to the front.
static PyObject *
unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
/*[clinic end generated code: output=c2b815c63bcabffc input=ea78406060fce33c]*/
/*[clinic end generated code: output=c2b815c63bcabffc input=0f762e30d267fa83]*/
{
if (sep == Py_None)
return rsplit(self, NULL, maxsplit);
@ -13295,6 +13320,7 @@ unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
}
/*[clinic input]
@permit_long_docstring_body
str.splitlines as unicode_splitlines
keepends: bool = False
@ -13307,7 +13333,7 @@ true.
static PyObject *
unicode_splitlines_impl(PyObject *self, int keepends)
/*[clinic end generated code: output=f664dcdad153ec40 input=ba6ad05ee85d2b55]*/
/*[clinic end generated code: output=f664dcdad153ec40 input=39eeafbfef61c827]*/
{
return PyUnicode_Splitlines(self, keepends);
}
@ -13319,6 +13345,7 @@ PyObject *unicode_str(PyObject *self)
}
/*[clinic input]
@permit_long_summary
str.swapcase as unicode_swapcase
Convert uppercase characters to lowercase and lowercase characters to uppercase.
@ -13326,7 +13353,7 @@ Convert uppercase characters to lowercase and lowercase characters to uppercase.
static PyObject *
unicode_swapcase_impl(PyObject *self)
/*[clinic end generated code: output=5d28966bf6d7b2af input=3f3ef96d5798a7bb]*/
/*[clinic end generated code: output=5d28966bf6d7b2af input=85bc39a9b4e8ee91]*/
{
return case_operation(self, do_swapcase);
}
@ -13462,6 +13489,7 @@ unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z)
}
/*[clinic input]
@permit_long_docstring_body
str.translate as unicode_translate
table: object
@ -13478,7 +13506,7 @@ left untouched. Characters mapped to None are deleted.
static PyObject *
unicode_translate(PyObject *self, PyObject *table)
/*[clinic end generated code: output=3cb448ff2fd96bf3 input=6d38343db63d8eb0]*/
/*[clinic end generated code: output=3cb448ff2fd96bf3 input=699e5fa0ebf9f5e9]*/
{
return _PyUnicode_TranslateCharmap(self, table, "ignore");
}
@ -13499,6 +13527,7 @@ unicode_upper_impl(PyObject *self)
}
/*[clinic input]
@permit_long_summary
str.zfill as unicode_zfill
width: Py_ssize_t
@ -13511,7 +13540,7 @@ The string is never truncated.
static PyObject *
unicode_zfill_impl(PyObject *self, Py_ssize_t width)
/*[clinic end generated code: output=e13fb6bdf8e3b9df input=c6b2f772c6f27799]*/
/*[clinic end generated code: output=e13fb6bdf8e3b9df input=25a4ee0ea3e58ce0]*/
{
Py_ssize_t fill;
PyObject *u;
@ -13544,6 +13573,7 @@ unicode_zfill_impl(PyObject *self, Py_ssize_t width)
}
/*[clinic input]
@permit_long_summary
@text_signature "($self, prefix[, start[, end]], /)"
str.startswith as unicode_startswith
@ -13561,7 +13591,7 @@ Return True if the string starts with the specified prefix, False otherwise.
static PyObject *
unicode_startswith_impl(PyObject *self, PyObject *subobj, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=4bd7cfd0803051d4 input=5f918b5f5f89d856]*/
/*[clinic end generated code: output=4bd7cfd0803051d4 input=766bdbd33df251dc]*/
{
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
@ -13600,6 +13630,7 @@ unicode_startswith_impl(PyObject *self, PyObject *subobj, Py_ssize_t start,
/*[clinic input]
@permit_long_summary
@text_signature "($self, suffix[, start[, end]], /)"
str.endswith as unicode_endswith
@ -13617,7 +13648,7 @@ Return True if the string ends with the specified suffix, False otherwise.
static PyObject *
unicode_endswith_impl(PyObject *self, PyObject *subobj, Py_ssize_t start,
Py_ssize_t end)
/*[clinic end generated code: output=cce6f8ceb0102ca9 input=00fbdc774a7d4d71]*/
/*[clinic end generated code: output=cce6f8ceb0102ca9 input=b66bf6d5547ba1aa]*/
{
if (PyTuple_Check(subobj)) {
Py_ssize_t i;