Skip to content

Commit 45be44c

Browse files
author
MarcoFalke
committed
Merge #15257: Scripts and tools: Bump flake8 to 3.7.8
3d0a82c devtools: Accomodate block-style copyright blocks (Ben Woosley) 0ef0e51 lint: Bump flake8 to 3.7.8 (Ben Woosley) 8389207 lint: Disable flake8 W504 warning (Ben Woosley) b21680b test/contrib: Fix invalid escapes in regex strings (Ben Woosley) Pull request description: This is a second go at #15221, fixing new lints in: W504 line break after binary operator W605 invalid escape sequence F841 local variable 'e' is assigned to but never used This time around: * One commit per rule, for easier review * I went with the PEP-8 style of breaking before binary operators * I looked into the raw regex newline issue, and found that raw strings with newlines embedded do work appropriately. E.g. run `re.match(r" \n ", " \n ")` to check this for yourself. `re.MULTILINE` exists to modify `^` and `$` in multiline scenarios, but all of these searches are per-line. ACKs for top commit: practicalswift: ACK 3d0a82c -- diff looks correct Tree-SHA512: bea0c144cadd72e4adf2e9a4b4ee0535dd91a8e694206924cf8a389dc9253f364a717edfe9abda88108fbb67fda19b9e823f46822d7303c0aaa72e48909a6105
2 parents 761fe07 + 3d0a82c commit 45be44c

16 files changed

+39
-43
lines changed

ci/lint/04_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export LC_ALL=C
88

99
travis_retry pip3 install codespell==1.15.0
10-
travis_retry pip3 install flake8==3.5.0
10+
travis_retry pip3 install flake8==3.7.8
1111
travis_retry pip3 install vulture==0.29
1212

1313
SHELLCHECK_VERSION=v0.6.0

contrib/devtools/clang-format-diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def main():
106106
filename = None
107107
lines_by_file = {}
108108
for line in sys.stdin:
109-
match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
109+
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
110110
if match:
111111
filename = match.group(2)
112112
if filename is None:
@@ -119,7 +119,7 @@ def main():
119119
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
120120
continue
121121

122-
match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
122+
match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
123123
if match:
124124
start_line = int(match.group(1))
125125
line_count = 1

contrib/devtools/copyright_header.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_filenames_to_examine(base_directory):
7171
################################################################################
7272

7373

74-
COPYRIGHT_WITH_C = 'Copyright \(c\)'
74+
COPYRIGHT_WITH_C = r'Copyright \(c\)'
7575
COPYRIGHT_WITHOUT_C = 'Copyright'
7676
ANY_COPYRIGHT_STYLE = '(%s|%s)' % (COPYRIGHT_WITH_C, COPYRIGHT_WITHOUT_C)
7777

@@ -85,21 +85,21 @@ def get_filenames_to_examine(base_directory):
8585
ANY_COPYRIGHT_COMPILED = re.compile(ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE)
8686

8787
def compile_copyright_regex(copyright_style, year_style, name):
88-
return re.compile('%s %s,? %s' % (copyright_style, year_style, name))
88+
return re.compile(r'%s %s,? %s( +\*)?\n' % (copyright_style, year_style, name))
8989

9090
EXPECTED_HOLDER_NAMES = [
91-
"Satoshi Nakamoto\n",
92-
"The Bitcoin Core developers\n",
93-
"BitPay Inc\.\n",
94-
"University of Illinois at Urbana-Champaign\.\n",
95-
"Pieter Wuille\n",
96-
"Wladimir J. van der Laan\n",
97-
"Jeff Garzik\n",
98-
"Jan-Klaas Kollhof\n",
99-
"ArtForz -- public domain half-a-node\n",
100-
"Intel Corporation",
101-
"The Zcash developers",
102-
"Jeremy Rubin",
91+
r"Satoshi Nakamoto",
92+
r"The Bitcoin Core developers",
93+
r"BitPay Inc\.",
94+
r"University of Illinois at Urbana-Champaign\.",
95+
r"Pieter Wuille",
96+
r"Wladimir J\. van der Laan",
97+
r"Jeff Garzik",
98+
r"Jan-Klaas Kollhof",
99+
r"ArtForz -- public domain half-a-node",
100+
r"Intel Corporation ?",
101+
r"The Zcash developers",
102+
r"Jeremy Rubin",
103103
]
104104

105105
DOMINANT_STYLE_COMPILED = {}
@@ -329,7 +329,7 @@ def write_file_lines(filename, file_lines):
329329
# update header years execution
330330
################################################################################
331331

332-
COPYRIGHT = 'Copyright \(c\)'
332+
COPYRIGHT = r'Copyright \(c\)'
333333
YEAR = "20[0-9][0-9]"
334334
YEAR_RANGE = '(%s)(-%s)?' % (YEAR, YEAR)
335335
HOLDER = 'The Bitcoin Core developers'

contrib/devtools/symbol-check.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def read_libraries(filename):
141141
for line in stdout.splitlines():
142142
tokens = line.split()
143143
if len(tokens)>2 and tokens[1] == '(NEEDED)':
144-
match = re.match('^Shared library: \[(.*)\]$', ' '.join(tokens[2:]))
144+
match = re.match(r'^Shared library: \[(.*)\]$', ' '.join(tokens[2:]))
145145
if match:
146146
libraries.append(match.group(1))
147147
else:
@@ -171,5 +171,3 @@ def read_libraries(filename):
171171
retval = 1
172172

173173
sys.exit(retval)
174-
175-

contrib/linearize/linearize-data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ def run(self):
263263
f = open(sys.argv[1], encoding="utf8")
264264
for line in f:
265265
# skip comment lines
266-
m = re.search('^\s*#', line)
266+
m = re.search(r'^\s*#', line)
267267
if m:
268268
continue
269269

270270
# parse key=value lines
271-
m = re.search('^(\w+)\s*=\s*(\S.*)$', line)
271+
m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)
272272
if m is None:
273273
continue
274274
settings[m.group(1)] = m.group(2)

contrib/linearize/linearize-hashes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ def get_rpc_cookie():
106106
f = open(sys.argv[1], encoding="utf8")
107107
for line in f:
108108
# skip comment lines
109-
m = re.search('^\s*#', line)
109+
m = re.search(r'^\s*#', line)
110110
if m:
111111
continue
112112

113113
# parse key=value lines
114-
m = re.search('^(\w+)\s*=\s*(\S.*)$', line)
114+
m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)
115115
if m is None:
116116
continue
117117
settings[m.group(1)] = m.group(2)

contrib/macdeploy/macdeployqtplus

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,8 @@ if config.dmg is not None:
765765
output = runHDIUtil("attach", dmg_name + ".temp", readwrite=True, noverify=True, noautoopen=True, capture_stdout=True)
766766
except subprocess.CalledProcessError as e:
767767
sys.exit(e.returncode)
768-
769-
m = re.search("/Volumes/(.+$)", output)
768+
769+
m = re.search(r"/Volumes/(.+$)", output)
770770
disk_root = m.group(0)
771771
disk_name = m.group(1)
772772

contrib/seeds/generate-seeds.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def name_to_ipv6(addr):
7474
raise ValueError('Could not parse address %s' % addr)
7575

7676
def parse_spec(s, defaultport):
77-
match = re.match('\[([0-9a-fA-F:]+)\](?::([0-9]+))?$', s)
77+
match = re.match(r'\[([0-9a-fA-F:]+)\](?::([0-9]+))?$', s)
7878
if match: # ipv6
7979
host = match.group(1)
8080
port = match.group(2)
@@ -136,4 +136,3 @@ def main():
136136

137137
if __name__ == '__main__':
138138
main()
139-

test/functional/combine_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def read_logs(tmp_dir):
8181
chain = glob.glob("{}/node0/*/debug.log".format(tmp_dir))
8282
if chain:
8383
chain = chain[0] # pick the first one if more than one chain was found (should never happen)
84-
chain = re.search('node0/(.+?)/debug\.log$', chain).group(1) # extract the chain name
84+
chain = re.search(r'node0/(.+?)/debug\.log$', chain).group(1) # extract the chain name
8585
else:
8686
chain = 'regtest' # fallback to regtest (should only happen when none exists)
8787

test/functional/feature_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run_test(self):
3636
invdir = self.relative_log_path("foo")
3737
invalidname = os.path.join("foo", "foo.log")
3838
self.stop_node(0)
39-
exp_stderr = "Error: Could not open debug log file \S+$"
39+
exp_stderr = r"Error: Could not open debug log file \S+$"
4040
self.nodes[0].assert_start_raises_init_error(["-debuglogfile=%s" % (invalidname)], exp_stderr, match=ErrorMatch.FULL_REGEX)
4141
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
4242

0 commit comments

Comments
 (0)