Skip to content

Commit c91410f

Browse files
committed
Fix join statement and more linting
1 parent dabb815 commit c91410f

16 files changed

+28
-28
lines changed

asv_bench/benchmarks/frame_ctor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def setup(self, offset, n_steps):
132132
offset = getattr(offsets, offset)
133133
self.idx = get_index_for_offset(offset(n_steps, **kwargs))
134134
self.df = DataFrame(np.random.randn(len(self.idx), 10), index=self.idx)
135-
self.d = dict([(col, self.df[col]) for col in self.df.columns])
135+
self.d = dict((col, self.df[col]) for col in self.df.columns)
136136

137137
def time_frame_ctor(self, offset, n_steps):
138138
DataFrame(self.d)

asv_bench/benchmarks/io_bench.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class read_json_lines(object):
202202
def setup(self):
203203
self.N = 100000
204204
self.C = 5
205-
self.df = DataFrame(dict([('float{0}'.format(i), randn(self.N)) for i in range(self.C)]))
205+
self.df = DataFrame(dict(('float{0}'.format(i), randn(self.N)) for i in range(self.C)))
206206
self.df.to_json(self.fname,orient="records",lines=True)
207207

208208
def teardown(self):

asv_bench/benchmarks/packers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _setup(self):
1717
self.N = 100000
1818
self.C = 5
1919
self.index = date_range('20000101', periods=self.N, freq='H')
20-
self.df = DataFrame(dict([('float{0}'.format(i), randn(self.N)) for i in range(self.C)]), index=self.index)
20+
self.df = DataFrame(dict(('float{0}'.format(i), randn(self.N)) for i in range(self.C)), index=self.index)
2121
self.df2 = self.df.copy()
2222
self.df2['object'] = [('%08x' % randrange((16 ** 8))) for _ in range(self.N)]
2323
self.remove(self.f)

asv_bench/vbench_to_asv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def visit_ClassDef(self, node):
6969
return node
7070

7171
def visit_TryExcept(self, node):
72-
if any([isinstance(x, (ast.Import, ast.ImportFrom)) for x in node.body]):
72+
if any(isinstance(x, (ast.Import, ast.ImportFrom)) for x in node.body):
7373
self.imports.append(node)
7474
else:
7575
self.generic_visit(node)

ci/lint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if [ "$LINT" ]; then
8484
fi
8585
echo "Check for invalid testing DONE"
8686

87-
echo "Check for use of lists in built-in Python functions"
87+
echo "Check for use of lists instead of generators in built-in Python functions"
8888

8989
# Example: Avoid `any([i for i in some_iterator])` in favor of `any(i for i in some_iterator)`
9090
#
@@ -95,7 +95,7 @@ if [ "$LINT" ]; then
9595
if [ $? = "0" ]; then
9696
RET=1
9797
fi
98-
echo "Check for use of lists in built-in Python functions DONE"
98+
echo "Check for use of lists instead of generators in built-in Python functions DONE"
9999

100100
else
101101
echo "NOT Linting"

doc/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
# JP: added from sphinxdocs
7979
autosummary_generate = False
8080

81-
if any([re.match("\s*api\s*", l) for l in index_rst_lines]):
81+
if any(re.match("\s*api\s*", l) for l in index_rst_lines):
8282
autosummary_generate = True
8383

8484
files_to_delete = []
@@ -89,7 +89,7 @@
8989

9090
_file_basename = os.path.splitext(f)[0]
9191
_regex_to_match = "\s*{}\s*$".format(_file_basename)
92-
if not any([re.match(_regex_to_match, line) for line in index_rst_lines]):
92+
if not any(re.match(_regex_to_match, line) for line in index_rst_lines):
9393
files_to_delete.append(f)
9494

9595
if files_to_delete:

doc/sphinxext/ipython_sphinxext/ipython_directive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def process_output(self, data, output_prompt,
522522
source = self.directive.state.document.current_source
523523
content = self.directive.content
524524
# Add tabs and join into a single string.
525-
content = '\n'.join([TAB + line for line in content])
525+
content = '\n'.join(TAB + line for line in content)
526526

527527
# Make sure the output contains the output prompt.
528528
ind = found.find(output_prompt)

doc/sphinxext/numpydoc/compiler_unparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def _Return(self, t):
399399
self._fill("return ")
400400
if t.value:
401401
if isinstance(t.value, Tuple):
402-
text = ', '.join([ name.name for name in t.value.asList() ])
402+
text = ', '.join(name.name for name in t.value.asList())
403403
self._write(text)
404404
else:
405405
self._dispatch(t.value)

doc/sphinxext/numpydoc/docscrape.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def _parse_summary(self):
270270
# If several signatures present, take the last one
271271
while True:
272272
summary = self._doc.read_to_next_empty_line()
273-
summary_str = " ".join([s.strip() for s in summary]).strip()
273+
summary_str = " ".join(s.strip() for s in summary).strip()
274274
if re.compile('^([\w., ]+=)?\s*[\w\.]+\(.*\)$').match(summary_str):
275275
self['Signature'] = summary_str
276276
if not self._is_at_section():
@@ -289,7 +289,7 @@ def _parse(self):
289289

290290
for (section,content) in self._read_sections():
291291
if not section.startswith('..'):
292-
section = ' '.join([s.capitalize() for s in section.split(' ')])
292+
section = ' '.join(s.capitalize() for s in section.split(' '))
293293
if section in ('Parameters', 'Returns', 'Raises', 'Warns',
294294
'Other Parameters', 'Attributes', 'Methods'):
295295
self[section] = self._parse_param_list(content)

doc/sphinxext/numpydoc/docscrape_sphinx.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _str_member_list(self, name):
130130
out += [''] + autosum
131131

132132
if others:
133-
maxlen_0 = max(3, max([len(x[0]) for x in others]))
133+
maxlen_0 = max(3, max(len(x[0]) for x in others))
134134
hdr = sixu("=")*maxlen_0 + sixu(" ") + sixu("=")*10
135135
fmt = sixu('%%%ds %%s ') % (maxlen_0,)
136136
out += ['', hdr]
@@ -203,7 +203,7 @@ def _str_references(self):
203203
m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I)
204204
if m:
205205
items.append(m.group(1))
206-
out += [' ' + ", ".join(["[%s]_" % item for item in items]), '']
206+
out += [' ' + ", ".join("[%s]_" % item for item in items), '']
207207
return out
208208

209209
def _str_examples(self):

doc/sphinxext/numpydoc/phantom_import.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def import_phantom_module(xml_file):
6060
# Sort items so that
6161
# - Base classes come before classes inherited from them
6262
# - Modules come before their contents
63-
all_nodes = dict([(n.attrib['id'], n) for n in root])
63+
all_nodes = dict((n.attrib['id'], n) for n in root)
6464

6565
def _get_bases(node, recurse=False):
6666
bases = [x.attrib['ref'] for x in node.findall('base')]

pandas/io/sql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ def has_table(self, name, schema=None):
11861186
def get_table(self, table_name, schema=None):
11871187
schema = schema or self.meta.schema
11881188
if schema:
1189-
tbl = self.meta.tables.get('.'.join(schema, table_name))
1189+
tbl = self.meta.tables.get('.'.join([schema, table_name]))
11901190
else:
11911191
tbl = self.meta.tables.get(table_name)
11921192

scripts/api_rst_coverage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def class_name_sort_key(x):
2222
api_rst_members = set()
2323
file_name = '../doc/source/api.rst'
2424
with open(file_name, 'r') as f:
25-
pattern = re.compile('({})\.(\w+)'.format('|'.join([cls.__name__ for cls in classes])))
25+
pattern = re.compile('({})\.(\w+)'.format('|'.join(cls.__name__ for cls in classes)))
2626
for line in f:
2727
match = pattern.search(line)
2828
if match:

scripts/find_commits_touching_func.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def get_hits(defname,files=()):
8888
# remove comment lines
8989
lines = [x for x in lines if not re.search("^\w+\s*\(.+\)\s*#",x)]
9090
hits = set(map(lambda x: x.split(" ")[0],lines))
91-
cs.update(set([Hit(commit=c,path=f) for c in hits]))
91+
cs.update(set(Hit(commit=c,path=f) for c in hits))
9292

9393
return cs
9494

@@ -101,12 +101,12 @@ def get_commit_vitals(c,hlen=HASH_LEN):
101101
return h[:hlen],s,parse_date(d)
102102

103103
def file_filter(state,dirname,fnames):
104-
if args.dir_masks and not any([re.search(x,dirname) for x in args.dir_masks]):
104+
if args.dir_masks and not any(re.search(x,dirname) for x in args.dir_masks):
105105
return
106106
for f in fnames:
107107
p = os.path.abspath(os.path.join(os.path.realpath(dirname),f))
108-
if any([re.search(x,f) for x in args.file_masks])\
109-
or any([re.search(x,p) for x in args.path_masks]):
108+
if any(re.search(x,f) for x in args.file_masks)\
109+
or any(re.search(x,p) for x in args.path_masks):
110110
if os.path.isfile(p):
111111
state['files'].append(p)
112112

scripts/merge-pr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def merge_pr(pr_num, target_ref):
160160
if body is not None:
161161
merge_message_flags += ["-m", '\n'.join(textwrap.wrap(body))]
162162

163-
authors = "\n".join(["Author: %s" % a for a in distinct_authors])
163+
authors = "\n".join("Author: %s" % a for a in distinct_authorsS)
164164

165165
merge_message_flags += ["-m", authors]
166166

versioneer.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
606606
if verbose:
607607
print("keywords are unexpanded, not using")
608608
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
609-
refs = set([r.strip() for r in refnames.strip("()").split(",")])
609+
refs = set(r.strip() for r in refnames.strip("()").split(","))
610610
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
611611
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
612612
TAG = "tag: "
613-
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
613+
tags = set(r[len(TAG):] for r in refs if r.startswith(TAG))
614614
if not tags:
615615
# Either we're using git < 1.8.3, or there really are no tags. We use
616616
# a heuristic: assume all version tags have a digit. The old git %%d
@@ -619,7 +619,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
619619
# between branches and tags. By ignoring refnames without digits, we
620620
# filter out many common branch names like "release" and
621621
# "stabilization", as well as "HEAD" and "master".
622-
tags = set([r for r in refs if re.search(r'\d', r)])
622+
tags = set(r for r in refs if re.search(r'\d', r))
623623
if verbose:
624624
print("discarding '%%s', no digits" %% ",".join(refs-tags))
625625
if verbose:
@@ -960,11 +960,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
960960
if verbose:
961961
print("keywords are unexpanded, not using")
962962
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
963-
refs = set([r.strip() for r in refnames.strip("()").split(",")])
963+
refs = set(r.strip() for r in refnames.strip("()").split(","))
964964
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
965965
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
966966
TAG = "tag: "
967-
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
967+
tags = set(r[len(TAG):] for r in refs if r.startswith(TAG))
968968
if not tags:
969969
# Either we're using git < 1.8.3, or there really are no tags. We use
970970
# a heuristic: assume all version tags have a digit. The old git %d
@@ -973,7 +973,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
973973
# between branches and tags. By ignoring refnames without digits, we
974974
# filter out many common branch names like "release" and
975975
# "stabilization", as well as "HEAD" and "master".
976-
tags = set([r for r in refs if re.search(r'\d', r)])
976+
tags = set(r for r in refs if re.search(r'\d', r))
977977
if verbose:
978978
print("discarding '%s', no digits" % ",".join(refs-tags))
979979
if verbose:

0 commit comments

Comments
 (0)