Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

style: follow pep8 on lambda assignments #230

Merged
merged 1 commit into from
Nov 27, 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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ console_scripts =
hawkmoth = hawkmoth.__main__:main

[flake8]
extend-ignore = E302,E305,E731
extend-ignore = E302,E305
max-line-length = 100
2 changes: 1 addition & 1 deletion src/hawkmoth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __process_docstring(self, lines):
self.env.app.emit('hawkmoth-process-docstring', lines, transform, self.options)

def __get_docstrings_for_root(self, viewlist, root):
process_docstring = lambda lines: self.__process_docstring(lines)
def process_docstring(lines): self.__process_docstring(lines)

num_matches = 0
for docstrings in root.walk(recurse=False, filter_types=self._docstring_types,
Expand Down
4 changes: 2 additions & 2 deletions src/hawkmoth/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def main():
comments, errors = parse(args.file, domain=args.domain, clang_args=args.clang)

if args.process_docstring:
process_docstring = lambda lines: _process_docstring(args.process_docstring, lines)
def process_docstring(lines): return _process_docstring(args.process_docstring, lines)
else:
process_docstring = lambda lines: _process_docstring_compat(args, lines)
def process_docstring(lines): return _process_docstring_compat(args, lines)

for comment in comments.walk():
if args.verbose:
Expand Down
4 changes: 2 additions & 2 deletions src/hawkmoth/doccursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def _get_inheritance(self):
inherited = []
for child in self.get_children():
if child._cc.kind == CursorKind.CXX_BASE_SPECIFIER:
pad = lambda s: s + ' ' if s else ''
def pad(s): return s + ' ' if s else ''
access_spec = child._get_access_specifier()
inherited.append(f'{pad(access_spec)}{child._cc.type.spelling}')

Expand Down Expand Up @@ -568,7 +568,7 @@ def _var_type_fixup(cursor):
type_elem.append(access_spec)

if cursor_type.kind == TypeKind.FUNCTIONPROTO:
pad = lambda s: s if s.endswith('*') or s.endswith('&') else s + ' '
def pad(s): return s if s.endswith('*') or s.endswith('&') else s + ' '

args = []
for c in cursor.get_children():
Expand Down
4 changes: 2 additions & 2 deletions src/hawkmoth/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ def _get_header_lines(self):

args = ''
if self._args and len(self._args) > 0:
pad_type = lambda t: '' if len(t) == 0 or t.endswith('*') or t.endswith('&') else ' '
arg_fmt = lambda t, n: f"{t}{pad_type(t)}{n}"
def pad_type(t): return '' if len(t) == 0 or t.endswith('*') or t.endswith('&') else ' '
def arg_fmt(t, n): return f'{t}{pad_type(t)}{n}'
args = ', '.join([arg_fmt(t, n) for t, n in self._args])

header = self._fmt.format(domain=domain, name=name, ttype=ttype,
Expand Down
2 changes: 1 addition & 1 deletion src/hawkmoth/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _comment_extract(tu):
comments = {}
current_comment = None

is_doc = lambda cursor: cursor and docstring.Docstring.is_doc(cursor.spelling)
def is_doc(cursor): return cursor and docstring.Docstring.is_doc(cursor.spelling)

for token in tu.get_tokens(extent=tu.cursor.extent):
# Handle all comments we come across.
Expand Down
2 changes: 1 addition & 1 deletion test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_output(self):
continue

transform = directive.options.get('transform')
process_docstring = lambda lines: _process_docstring(transform, lines)
def process_docstring(lines): return _process_docstring(transform, lines)

for docstrings in root.walk(recurse=False, filter_types=_filter_types(directive),
filter_names=_filter_names(directive)):
Expand Down
Loading