Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ea2087

Browse files
committed
Fix flake8 issues
1 parent 1f872ba commit 6ea2087

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

tests/test_pythoncapi_compat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def build_ext():
3737
display_title("Build the C extension")
3838
if os.path.exists("build"):
3939
shutil.rmtree("build")
40-
include_dir = os.path.normpath(os.path.join(os.getcwd(), '..'))
4140
os.environ['CFLAGS'] = "-I .."
4241
cmd = [sys.executable, "setup.py", "build"]
4342
if VERBOSE:
@@ -83,7 +82,7 @@ def _check_refleak(test_func, verbose):
8382

8483
init_refcnt = sys.gettotalrefcount()
8584
test_func()
86-
diff = sys.gettotalrefcount() - init_refcnt;
85+
diff = sys.gettotalrefcount() - init_refcnt
8786

8887
if i > 3 and diff:
8988
raise AssertionError(f"refcnt leak, diff: {diff}")

tests/test_upgrade_pythoncapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Get upgrade_pythoncapi.py of the parent directory
1010
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
11-
import upgrade_pythoncapi
11+
import upgrade_pythoncapi # noqa
1212

1313

1414
def patch(source):

upgrade_pythoncapi.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
FORCE_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')
1213
PYTHONCAPI_COMPAT_H = 'pythoncapi_compat.h'
1314
INCLUDE_PYTHONCAPI_COMPAT = f'#include "{PYTHONCAPI_COMPAT_H}"'
1415
INCLUDE_PYTHONCAPI_COMPAT2 = f'#include <{PYTHONCAPI_COMPAT_H}>'
@@ -20,7 +21,7 @@
2021
SUBEXPR_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

2627
def get_member_regex_str(member):
@@ -131,7 +132,8 @@ class Py_SET_SIZE(Operation):
131132

132133
class 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

218220
class 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

228231
class 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

239243
class 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

Comments
 (0)