88FORCE_NEWREF = False
99
1010
11- PYTHONCAPI_COMPAT_URL = 'https://raw.githubusercontent.com/pythoncapi/pythoncapi_compat/master/pythoncapi_compat.h'
11+ PYTHONCAPI_COMPAT_URL = ('https://raw.githubusercontent.com/pythoncapi/'
12+ 'pythoncapi_compat/master/pythoncapi_compat.h' )
1213PYTHONCAPI_COMPAT_H = 'pythoncapi_compat.h'
1314INCLUDE_PYTHONCAPI_COMPAT = f'#include "{ PYTHONCAPI_COMPAT_H } "'
1415INCLUDE_PYTHONCAPI_COMPAT2 = f'#include <{ PYTHONCAPI_COMPAT_H } >'
2021SUBEXPR_REGEX = fr'{ ID_REGEX } (?:\[[^]]+\])*'
2122# Match a C expression like "frame", "frame.attr" or "obj->attr".
2223# Don't match functions calls like "func()".
23- EXPR_REGEX = f "{ SUBEXPR_REGEX } (?:(?:->|\.){ SUBEXPR_REGEX } )*"
24+ EXPR_REGEX = fr "{ SUBEXPR_REGEX } (?:(?:->|\.){ SUBEXPR_REGEX } )*"
2425
2526
2627def get_member_regex_str (member ):
@@ -131,7 +132,8 @@ class Py_SET_SIZE(Operation):
131132
132133class Py_SET_REFCNT (Operation ):
133134 NAME = "Py_SET_REFCNT"
134- DOC = 'replace "Py_REFCNT(obj) = refcnt;" with "Py_SET_REFCNT(obj, refcnt);"'
135+ DOC = ('replace "Py_REFCNT(obj) = refcnt;" '
136+ 'with "Py_SET_REFCNT(obj, refcnt);"' )
135137 REPLACE = (
136138 (call_assign_regex ('Py_REFCNT' ), r'Py_SET_REFCNT(\1, \2);' ),
137139 (set_member_regex ('ob_refcnt' ), r'Py_SET_REFCNT(\1, \2);' ),
@@ -217,7 +219,8 @@ class PyFrame_GetCode(Operation):
217219
218220class PyThreadState_GetInterpreter (Operation ):
219221 NAME = "PyThreadState_GetInterpreter"
220- DOC = 'replace "tstate->interp" with "PyThreadState_GetInterpreter(tstate)"'
222+ DOC = ('replace "tstate->interp" '
223+ 'with "PyThreadState_GetInterpreter(tstate)"' )
221224 REPLACE = (
222225 (get_member_regex ('interp' ), r'PyThreadState_GetInterpreter(\1)' ),
223226 )
@@ -227,7 +230,8 @@ class PyThreadState_GetInterpreter(Operation):
227230
228231class PyThreadState_GetFrame (Operation ):
229232 NAME = "PyThreadState_GetFrame"
230- DOC = 'replace "tstate->frame" with "_PyThreadState_GetFrameBorrow(tstate)"'
233+ DOC = ('replace "tstate->frame" '
234+ 'with "_PyThreadState_GetFrameBorrow(tstate)"' )
231235 REPLACE = (
232236 (get_member_regex ('frame' ), r'_PyThreadState_GetFrameBorrow(\1)' ),
233237 )
@@ -238,7 +242,8 @@ class PyThreadState_GetFrame(Operation):
238242
239243class Py_INCREF_return (Operation ):
240244 NAME = "Py_INCREF_return"
241- DOC = 'replace "Py_INCREF(obj); return (obj);" with "return Py_NewRef(obj);"'
245+ DOC = ('replace "Py_INCREF(obj); return (obj);" '
246+ 'with "return Py_NewRef(obj);"' )
242247 REPLACE = (
243248 (re .compile (r'Py_INCREF\((%s)\);\s*return \1;' % ID_REGEX ),
244249 r'return Py_NewRef(\1);' ),
@@ -449,7 +454,8 @@ def usage(parser):
449454 key = lambda operation : operation .NAME ):
450455 print ("- %s: %s" % (operation .NAME , operation .DOC ))
451456 print ()
452- print ("If a directory is passed, search for .c and .h files in subdirectories." )
457+ print ("If a directory is passed, search for .c and .h files "
458+ "in subdirectories." )
453459
454460 def _parse_options (self , args ):
455461 parser = argparse .ArgumentParser (
@@ -467,7 +473,7 @@ def _parse_options(self, args):
467473 'in-place (imply quiet mode)' )
468474 parser .add_argument (
469475 '-B' , '--no-backup' , action = "store_true" ,
470- help = f "Don't create .old backup files" )
476+ help = "Don't create .old backup files" )
471477 parser .add_argument (
472478 '-C' , '--no-compat' , action = "store_true" ,
473479 help = f"Don't add: { INCLUDE_PYTHONCAPI_COMPAT } " )
0 commit comments