Skip to content

Commit

Permalink
blackening
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmcg committed Oct 24, 2021
1 parent 5d6c14a commit a80951b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
17 changes: 12 additions & 5 deletions pyparsing/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def enable_all_warnings():
del __config_flags


def _should_enable_warnings(cmd_line_warn_options: List[str], warn_env_var: str) -> bool:
def _should_enable_warnings(
cmd_line_warn_options: List[str], warn_env_var: str
) -> bool:
enable = bool(warn_env_var)
for warn_opt in cmd_line_warn_options:
w_action, w_message, w_category, w_module, w_line = (warn_opt + "::::").split(
Expand All @@ -191,7 +193,9 @@ def _should_enable_warnings(cmd_line_warn_options: List[str], warn_env_var: str)
return enable


if _should_enable_warnings(sys.warnoptions, os.environ.get("PYPARSINGENABLEALLWARNINGS")):
if _should_enable_warnings(
sys.warnoptions, os.environ.get("PYPARSINGENABLEALLWARNINGS")
):
enable_all_warnings()


Expand Down Expand Up @@ -560,7 +564,9 @@ def breaker(instring, loc, doActions=True, callPreParse=True):
self._parse = self._parse._originalParseMethod
return self

def set_parse_action(self, *fns: ParseAction, **kwargs) -> OptionalType["ParserElement"]:
def set_parse_action(
self, *fns: ParseAction, **kwargs
) -> OptionalType["ParserElement"]:
"""
Define one or more actions to perform when successfully matching parse element definition.
Expand Down Expand Up @@ -1691,6 +1697,7 @@ def ignore(self, other: "ParserElement") -> "ParserElement":
# -> ['ablaj', 'lskjd']
"""
import typing

if isinstance(other, str_type):
other = Suppress(other)

Expand Down Expand Up @@ -3528,8 +3535,8 @@ class ParseExpression(ParserElement):

def __init__(self, exprs: IterableType[ParserElement], savelist: bool = False):
super().__init__(savelist)
self.exprs : List[ParserElement]
exprs : Iterable[ParserElement]
self.exprs: List[ParserElement]
exprs: Iterable[ParserElement]
if isinstance(exprs, _generatorType):
exprs = list(exprs)

Expand Down
11 changes: 7 additions & 4 deletions pyparsing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ def one_of(
asKeyword = asKeyword or as_keyword
useRegex = useRegex and use_regex

if isinstance(caseless, str_type) and __diag__.warn_on_multiple_string_args_to_oneof:
if (
isinstance(caseless, str_type)
and __diag__.warn_on_multiple_string_args_to_oneof
):
warnings.warn(
"More than one string argument passed to one_of, pass"
" choices as a list or space-delimited string",
Expand Down Expand Up @@ -652,9 +655,9 @@ def make_xml_tags(
)

_htmlEntityMap = {k.rstrip(";"): v for k, v in html.entities.html5.items()}
common_html_entity = Regex(
"&(?P<entity>" + "|".join(_htmlEntityMap) + ");"
).set_name("common HTML entity")
common_html_entity = Regex("&(?P<entity>" + "|".join(_htmlEntityMap) + ");").set_name(
"common HTML entity"
)


def replace_html_entity(t):
Expand Down
2 changes: 1 addition & 1 deletion pyparsing/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def with_line_numbers(
if mark_control != "unicode":
s_lines = s.splitlines()[start_line - 1 : end_line]
else:
s_lines = [line+"␊" for line in s.split("␊")[start_line - 1 : end_line]]
s_lines = [line + "␊" for line in s.split("␊")[start_line - 1 : end_line]]
if not s_lines:
return ""

Expand Down

0 comments on commit a80951b

Please sign in to comment.