Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Placate flake8-comprehensions #74

Merged
merged 1 commit into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pycparserext/ext_c_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def add_lexer_keywords(cls, keywords):
kw.upper() for kw in keywords)

cls.keyword_map = cls.keyword_map.copy()
cls.keyword_map.update(dict(
(kw, kw.upper()) for kw in keywords))
cls.keyword_map.update({kw: kw.upper() for kw in keywords})

cls.tokens = cls.tokens + tuple(
kw.upper() for kw in keywords)
Expand Down
32 changes: 16 additions & 16 deletions pycparserext/ext_c_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def parse(self, text, filename='', debuglevel=0,

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

initial_scope = dict((tpsym, 1) for tpsym in initial_type_symbols)
initial_scope = {tpsym: 1 for tpsym in initial_type_symbols}
initial_scope.update(
dict((tpsym, 1) for tpsym in self.initial_type_symbols))
{tpsym: 1 for tpsym in self.initial_type_symbols})
self._scope_stack = [initial_scope]

if not text or text.isspace():
Expand Down Expand Up @@ -479,7 +479,7 @@ class GnuCParser(_AsmAndAttributesMixin, CParserBase):

from pycparserext.ext_c_lexer import GnuCLexer as lexer_class # noqa

initial_type_symbols = set(["__builtin_va_list"])
initial_type_symbols = {"__builtin_va_list"}

def p_function_specifier_gnu(self, p):
""" function_specifier : __INLINE
Expand Down Expand Up @@ -585,32 +585,32 @@ class OpenCLCParser(_AsmAndAttributesMixin, CParserBase):

INT_BIT_COUNTS = [8, 16, 32, 64]
initial_type_symbols = (
set([
{
"%s%d" % (base_name, count)
for base_name in [
'char', 'uchar', 'short', 'ushort', 'int', 'uint',
'long', 'ulong', 'float', 'double', 'half']
for count in [2, 3, 4, 8, 16]
])
| set([
}
| {
"intptr_t", "uintptr_t",
"intmax_t", "uintmax_t",
"size_t", "ptrdiff_t",
"uint", "ulong", "ushort", "uchar",
"half", "bool"])
| set(["int%d_t" % bc for bc in INT_BIT_COUNTS])
| set(["uint%d_t" % bc for bc in INT_BIT_COUNTS])
| set(["int_least%d_t" % bc for bc in INT_BIT_COUNTS])
| set(["uint_least%d_t" % bc for bc in INT_BIT_COUNTS])
| set(["int_fast%d_t" % bc for bc in INT_BIT_COUNTS])
| set(["uint_fast%d_t" % bc for bc in INT_BIT_COUNTS])
| set([
"half", "bool"}
| {"int%d_t" % bc for bc in INT_BIT_COUNTS}
| {"uint%d_t" % bc for bc in INT_BIT_COUNTS}
| {"int_least%d_t" % bc for bc in INT_BIT_COUNTS}
| {"uint_least%d_t" % bc for bc in INT_BIT_COUNTS}
| {"int_fast%d_t" % bc for bc in INT_BIT_COUNTS}
| {"uint_fast%d_t" % bc for bc in INT_BIT_COUNTS}
| {
"image1d_t", "image1d_array_t", "image1d_buffer_t",
"image2d_t", "image2d_array_t",
"image3d_t",
"sampler_t", "event_t"
])
| set(["cfloat_t", "cdouble_t"]) # PyOpenCL extension
}
| {"cfloat_t", "cdouble_t"} # PyOpenCL extension
)

def p_pp_directive(self, p):
Expand Down