Skip to content

Commit 6b9db4a

Browse files
committed
Placate flake8-comprehensions
1 parent 5321ce7 commit 6b9db4a

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

pycparserext/ext_c_lexer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def add_lexer_keywords(cls, keywords):
5454
kw.upper() for kw in keywords)
5555

5656
cls.keyword_map = cls.keyword_map.copy()
57-
cls.keyword_map.update(dict(
58-
(kw, kw.upper()) for kw in keywords))
57+
cls.keyword_map.update({kw: kw.upper() for kw in keywords})
5958

6059
cls.tokens = cls.tokens + tuple(
6160
kw.upper() for kw in keywords)

pycparserext/ext_c_parser.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def parse(self, text, filename='', debuglevel=0,
2323

2424
# _scope_stack[-1] is the current (topmost) scope.
2525

26-
initial_scope = dict((tpsym, 1) for tpsym in initial_type_symbols)
26+
initial_scope = {tpsym: 1 for tpsym in initial_type_symbols}
2727
initial_scope.update(
28-
dict((tpsym, 1) for tpsym in self.initial_type_symbols))
28+
{tpsym: 1 for tpsym in self.initial_type_symbols})
2929
self._scope_stack = [initial_scope]
3030

3131
if not text or text.isspace():
@@ -479,7 +479,7 @@ class GnuCParser(_AsmAndAttributesMixin, CParserBase):
479479

480480
from pycparserext.ext_c_lexer import GnuCLexer as lexer_class # noqa
481481

482-
initial_type_symbols = set(["__builtin_va_list"])
482+
initial_type_symbols = {"__builtin_va_list"}
483483

484484
def p_function_specifier_gnu(self, p):
485485
""" function_specifier : __INLINE
@@ -585,32 +585,32 @@ class OpenCLCParser(_AsmAndAttributesMixin, CParserBase):
585585

586586
INT_BIT_COUNTS = [8, 16, 32, 64]
587587
initial_type_symbols = (
588-
set([
588+
{
589589
"%s%d" % (base_name, count)
590590
for base_name in [
591591
'char', 'uchar', 'short', 'ushort', 'int', 'uint',
592592
'long', 'ulong', 'float', 'double', 'half']
593593
for count in [2, 3, 4, 8, 16]
594-
])
595-
| set([
594+
}
595+
| {
596596
"intptr_t", "uintptr_t",
597597
"intmax_t", "uintmax_t",
598598
"size_t", "ptrdiff_t",
599599
"uint", "ulong", "ushort", "uchar",
600-
"half", "bool"])
601-
| set(["int%d_t" % bc for bc in INT_BIT_COUNTS])
602-
| set(["uint%d_t" % bc for bc in INT_BIT_COUNTS])
603-
| set(["int_least%d_t" % bc for bc in INT_BIT_COUNTS])
604-
| set(["uint_least%d_t" % bc for bc in INT_BIT_COUNTS])
605-
| set(["int_fast%d_t" % bc for bc in INT_BIT_COUNTS])
606-
| set(["uint_fast%d_t" % bc for bc in INT_BIT_COUNTS])
607-
| set([
600+
"half", "bool"}
601+
| {"int%d_t" % bc for bc in INT_BIT_COUNTS}
602+
| {"uint%d_t" % bc for bc in INT_BIT_COUNTS}
603+
| {"int_least%d_t" % bc for bc in INT_BIT_COUNTS}
604+
| {"uint_least%d_t" % bc for bc in INT_BIT_COUNTS}
605+
| {"int_fast%d_t" % bc for bc in INT_BIT_COUNTS}
606+
| {"uint_fast%d_t" % bc for bc in INT_BIT_COUNTS}
607+
| {
608608
"image1d_t", "image1d_array_t", "image1d_buffer_t",
609609
"image2d_t", "image2d_array_t",
610610
"image3d_t",
611611
"sampler_t", "event_t"
612-
])
613-
| set(["cfloat_t", "cdouble_t"]) # PyOpenCL extension
612+
}
613+
| {"cfloat_t", "cdouble_t"} # PyOpenCL extension
614614
)
615615

616616
def p_pp_directive(self, p):

0 commit comments

Comments
 (0)