Upgrade black to 2023.1
This commit is contained in:
parent
296272fd39
commit
1aa9e72ca1
@ -10,7 +10,6 @@ from .simple import parse_file
|
|||||||
|
|
||||||
|
|
||||||
def dumpmain() -> None:
|
def dumpmain() -> None:
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("header")
|
parser.add_argument("header")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -685,7 +685,6 @@ class LexerTokenStream(TokenStream):
|
|||||||
return self._lex.current_location()
|
return self._lex.current_location()
|
||||||
|
|
||||||
def get_doxygen(self) -> typing.Optional[str]:
|
def get_doxygen(self) -> typing.Optional[str]:
|
||||||
|
|
||||||
tokbuf = self.tokbuf
|
tokbuf = self.tokbuf
|
||||||
|
|
||||||
# fill the token buffer if it's empty (which indicates a newline)
|
# fill the token buffer if it's empty (which indicates a newline)
|
||||||
|
@ -213,7 +213,6 @@ class CxxParser:
|
|||||||
*init_tokens: LexToken,
|
*init_tokens: LexToken,
|
||||||
token_map: typing.Optional[typing.Dict[str, str]] = None,
|
token_map: typing.Optional[typing.Dict[str, str]] = None,
|
||||||
) -> LexTokenList:
|
) -> LexTokenList:
|
||||||
|
|
||||||
if token_map is None:
|
if token_map is None:
|
||||||
token_map = self._balanced_token_map
|
token_map = self._balanced_token_map
|
||||||
|
|
||||||
@ -427,7 +426,6 @@ class CxxParser:
|
|||||||
self.visitor.on_namespace_start(state)
|
self.visitor.on_namespace_start(state)
|
||||||
|
|
||||||
def _parse_extern(self, tok: LexToken, doxygen: typing.Optional[str]) -> None:
|
def _parse_extern(self, tok: LexToken, doxygen: typing.Optional[str]) -> None:
|
||||||
|
|
||||||
etok = self.lex.token_if("STRING_LITERAL", "template")
|
etok = self.lex.token_if("STRING_LITERAL", "template")
|
||||||
if etok:
|
if etok:
|
||||||
if etok.type == "STRING_LITERAL":
|
if etok.type == "STRING_LITERAL":
|
||||||
@ -535,7 +533,6 @@ class CxxParser:
|
|||||||
|
|
||||||
if not lex.token_if(">"):
|
if not lex.token_if(">"):
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
tok = lex.token()
|
tok = lex.token()
|
||||||
tok_type = tok.type
|
tok_type = tok.type
|
||||||
|
|
||||||
@ -603,7 +600,6 @@ class CxxParser:
|
|||||||
# On entry, < has just been consumed
|
# On entry, < has just been consumed
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
# We don't know whether each argument will be a type or an expression.
|
# We don't know whether each argument will be a type or an expression.
|
||||||
# Retrieve the expression first, then try to parse the name using those
|
# Retrieve the expression first, then try to parse the name using those
|
||||||
# tokens. If it succeeds we're done, otherwise we use the value
|
# tokens. If it succeeds we're done, otherwise we use the value
|
||||||
@ -615,7 +611,6 @@ class CxxParser:
|
|||||||
dtype = None
|
dtype = None
|
||||||
|
|
||||||
if raw_toks and raw_toks[0].type in self._pqname_start_tokens:
|
if raw_toks and raw_toks[0].type in self._pqname_start_tokens:
|
||||||
|
|
||||||
# append a token to make other parsing components happy
|
# append a token to make other parsing components happy
|
||||||
raw_toks.append(PhonyEnding)
|
raw_toks.append(PhonyEnding)
|
||||||
|
|
||||||
@ -1124,7 +1119,6 @@ class CxxParser:
|
|||||||
def _process_access_specifier(
|
def _process_access_specifier(
|
||||||
self, tok: LexToken, doxygen: typing.Optional[str]
|
self, tok: LexToken, doxygen: typing.Optional[str]
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
state = self.state
|
state = self.state
|
||||||
if not isinstance(state, ClassBlockState):
|
if not isinstance(state, ClassBlockState):
|
||||||
raise self._parse_error(tok)
|
raise self._parse_error(tok)
|
||||||
@ -1205,7 +1199,6 @@ class CxxParser:
|
|||||||
location: Location,
|
location: Location,
|
||||||
is_typedef: bool,
|
is_typedef: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
state = self.state
|
state = self.state
|
||||||
state.location = location
|
state.location = location
|
||||||
if isinstance(state, ClassBlockState):
|
if isinstance(state, ClassBlockState):
|
||||||
@ -1386,7 +1379,6 @@ class CxxParser:
|
|||||||
|
|
||||||
# parse out operators as that's generally useful
|
# parse out operators as that's generally useful
|
||||||
if tok_value == "operator":
|
if tok_value == "operator":
|
||||||
|
|
||||||
op_parts = self._parse_pqname_name_operator()
|
op_parts = self._parse_pqname_name_operator()
|
||||||
op = "".join(o.value for o in op_parts)
|
op = "".join(o.value for o in op_parts)
|
||||||
name = f"operator{op}"
|
name = f"operator{op}"
|
||||||
@ -1614,7 +1606,6 @@ class CxxParser:
|
|||||||
vararg = False
|
vararg = False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
if self.lex.token_if("ELLIPSIS"):
|
if self.lex.token_if("ELLIPSIS"):
|
||||||
vararg = True
|
vararg = True
|
||||||
self._next_token_must_be(")")
|
self._next_token_must_be(")")
|
||||||
@ -1789,7 +1780,6 @@ class CxxParser:
|
|||||||
multiple_name_segments = len(pqname.segments) > 1
|
multiple_name_segments = len(pqname.segments) > 1
|
||||||
|
|
||||||
if (is_class_block or multiple_name_segments) and not is_typedef:
|
if (is_class_block or multiple_name_segments) and not is_typedef:
|
||||||
|
|
||||||
props.update(dict.fromkeys(mods.meths.keys(), True))
|
props.update(dict.fromkeys(mods.meths.keys(), True))
|
||||||
|
|
||||||
method: Method
|
method: Method
|
||||||
@ -1901,7 +1891,6 @@ class CxxParser:
|
|||||||
#
|
#
|
||||||
|
|
||||||
def _parse_array_type(self, tok: LexToken, dtype: DecoratedType) -> Array:
|
def _parse_array_type(self, tok: LexToken, dtype: DecoratedType) -> Array:
|
||||||
|
|
||||||
assert tok.type == "["
|
assert tok.type == "["
|
||||||
|
|
||||||
if isinstance(dtype, (Reference, MoveReference)):
|
if isinstance(dtype, (Reference, MoveReference)):
|
||||||
@ -2157,7 +2146,6 @@ class CxxParser:
|
|||||||
# paren or it's a constructor
|
# paren or it's a constructor
|
||||||
tok = self.lex.token_if("(")
|
tok = self.lex.token_if("(")
|
||||||
if tok:
|
if tok:
|
||||||
|
|
||||||
dsegments: typing.List[PQNameSegment] = []
|
dsegments: typing.List[PQNameSegment] = []
|
||||||
if isinstance(dtype, Type):
|
if isinstance(dtype, Type):
|
||||||
dsegments = dtype.typename.segments
|
dsegments = dtype.typename.segments
|
||||||
@ -2166,7 +2154,6 @@ class CxxParser:
|
|||||||
# the method name to the class name
|
# the method name to the class name
|
||||||
is_class_block = isinstance(state, ClassBlockState)
|
is_class_block = isinstance(state, ClassBlockState)
|
||||||
if (is_class_block or len(dsegments) > 1) and isinstance(dtype, Type):
|
if (is_class_block or len(dsegments) > 1) and isinstance(dtype, Type):
|
||||||
|
|
||||||
if not is_class_block:
|
if not is_class_block:
|
||||||
# must be an instance of a class
|
# must be an instance of a class
|
||||||
cls_name = getattr(dsegments[-2], "name", None)
|
cls_name = getattr(dsegments[-2], "name", None)
|
||||||
@ -2397,7 +2384,6 @@ class CxxParser:
|
|||||||
is_friend: bool,
|
is_friend: bool,
|
||||||
location: Location,
|
location: Location,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
|
||||||
# check for forward declaration or friend declaration
|
# check for forward declaration or friend declaration
|
||||||
if self.lex.token_if(";"):
|
if self.lex.token_if(";"):
|
||||||
if is_typedef:
|
if is_typedef:
|
||||||
@ -2435,7 +2421,6 @@ class CxxParser:
|
|||||||
|
|
||||||
tok = self.lex.token_if_in_set(self._class_enum_stage2)
|
tok = self.lex.token_if_in_set(self._class_enum_stage2)
|
||||||
if tok:
|
if tok:
|
||||||
|
|
||||||
classkey = parsed_type.typename.classkey
|
classkey = parsed_type.typename.classkey
|
||||||
# var is ok because it could be carried on to any variables
|
# var is ok because it could be carried on to any variables
|
||||||
mods.validate(
|
mods.validate(
|
||||||
|
@ -29,7 +29,6 @@ class ParsedTypeModifiers(typing.NamedTuple):
|
|||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
|
|
||||||
#: parent state
|
#: parent state
|
||||||
parent: typing.Optional["State"]
|
parent: typing.Optional["State"]
|
||||||
|
|
||||||
@ -49,7 +48,6 @@ class EmptyBlockState(State):
|
|||||||
|
|
||||||
|
|
||||||
class ExternBlockState(State):
|
class ExternBlockState(State):
|
||||||
|
|
||||||
#: The linkage for this extern block
|
#: The linkage for this extern block
|
||||||
linkage: str
|
linkage: str
|
||||||
|
|
||||||
@ -62,7 +60,6 @@ class ExternBlockState(State):
|
|||||||
|
|
||||||
|
|
||||||
class NamespaceBlockState(State):
|
class NamespaceBlockState(State):
|
||||||
|
|
||||||
#: The incremental namespace for this block
|
#: The incremental namespace for this block
|
||||||
namespace: NamespaceDecl
|
namespace: NamespaceDecl
|
||||||
|
|
||||||
@ -77,7 +74,6 @@ class NamespaceBlockState(State):
|
|||||||
|
|
||||||
|
|
||||||
class ClassBlockState(State):
|
class ClassBlockState(State):
|
||||||
|
|
||||||
#: class decl block being processed
|
#: class decl block being processed
|
||||||
class_decl: ClassDecl
|
class_decl: ClassDecl
|
||||||
|
|
||||||
|
@ -363,7 +363,6 @@ def parse_file(
|
|||||||
if filename == "-":
|
if filename == "-":
|
||||||
content = sys.stdin.read()
|
content = sys.stdin.read()
|
||||||
else:
|
else:
|
||||||
|
|
||||||
with open(filename, encoding=encoding) as fp:
|
with open(filename, encoding=encoding) as fp:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ from cxxheaderparser.simple import (
|
|||||||
ParsedData,
|
ParsedData,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# friends
|
# friends
|
||||||
def test_various_friends() -> None:
|
def test_various_friends() -> None:
|
||||||
content = """
|
content = """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user