Skip to content

Commit

Permalink
Various fixes after running pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
seladb committed Oct 4, 2023
1 parent 0280e8d commit b559529
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions cxxheaderparser/_ply/lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def token(self):
if tok.type:
self.lexpos = m.end()
return tok
else:
lexpos = m.end()
break

lexpos = m.end()
break

lexpos = m.end()

Expand Down
12 changes: 6 additions & 6 deletions cxxheaderparser/gentest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import argparse
import dataclasses
import inspect
import re
import subprocess
import typing

Expand Down Expand Up @@ -37,15 +36,16 @@ def _inner_repr(o: typing.Any) -> str:

return f"{o.__class__.__qualname__ }({', '.join(vals)})"

elif isinstance(o, list):
if isinstance(o, list):
return f"[{','.join(_inner_repr(l) for l in o)}]"
elif isinstance(o, dict):

if isinstance(o, dict):
vals = []
for k, v in o.items():
vals.append(f'"{k}": {_inner_repr(v)}')
return "{" + ",".join(vals) + "}"
else:
return repr(o)

return repr(o)

return _inner_repr(data)

Expand All @@ -72,7 +72,7 @@ def gentest(
data = parse_string(content, options=options)
if fail:
raise ValueError("did not fail")
except CxxParseError as e:
except CxxParseError:
if not fail:
raise
# do it again, but strip the content so the error message matches
Expand Down
7 changes: 2 additions & 5 deletions cxxheaderparser/lexer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import contextlib
from collections import deque
import re
import typing
import sys
Expand Down Expand Up @@ -782,7 +780,8 @@ def get_doxygen_after(self) -> typing.Optional[str]:
tok = tokbuf.popleft()
if tok.type == "NEWLINE":
break
elif tok.type == "WHITESPACE":

if tok.type == "WHITESPACE":
new_tokbuf.append(tok)
elif tok.type in ("COMMENT_SINGLELINE", "COMMENT_MULTILINE"):
comments.append(tok)
Expand Down Expand Up @@ -838,8 +837,6 @@ def has_tokens(self) -> bool:
return len(self.tokbuf) > 0

def _fill_tokbuf(self, tokbuf: typing.Deque[LexToken]) -> bool:
from .errors import CxxParseError

raise CxxParseError("no more tokens left in this group")

def current_location(self) -> Location:
Expand Down
7 changes: 4 additions & 3 deletions cxxheaderparser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
)
self.anon_id = 0

self.verbose = True if self.options.verbose else False
self.verbose = self.options.verbose
if self.verbose:

def debug_print(fmt: str, *args: typing.Any) -> None:
Expand Down Expand Up @@ -1755,7 +1755,7 @@ def _parse_method_end(self, method: Method) -> None:

break

elif tok_value == "=":
if tok_value == "=":
tok = get_token()
tok_value = tok.value

Expand All @@ -1769,7 +1769,8 @@ def _parse_method_end(self, method: Method) -> None:
raise self._parse_error(tok, "0/delete/default")

break
elif tok_value in ("const", "volatile", "override", "final"):

if tok_value in ("const", "volatile", "override", "final"):
setattr(method, tok_value, True)
elif tok_value in ("&", "&&"):
method.ref_qualifier = tok_value
Expand Down
1 change: 0 additions & 1 deletion cxxheaderparser/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io
import re
import os
from os.path import relpath
import typing
from .options import PreprocessorFunction

Expand Down
1 change: 0 additions & 1 deletion cxxheaderparser/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
)

from .parserstate import (
State,
ClassBlockState,
ExternBlockState,
NamespaceBlockState,
Expand Down

0 comments on commit b559529

Please sign in to comment.