Skip to content

Commit

Permalink
Add support for new keywords from CMake 3.22
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankSpruce committed Nov 18, 2021
1 parent 451c136 commit 997b0a9
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ disable=
too-few-public-methods,
too-many-ancestors,

unspecified-encoding,

unsubscriptable-object # false positives
2 changes: 1 addition & 1 deletion gersemi/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
__license__ = "MPL 2.0"
__title__ = "gersemi"
__url__ = "https://github.com/BlankSpruce/gersemi"
__version__ = "0.7.2"
__version__ = "0.7.3"
4 changes: 1 addition & 3 deletions gersemi/base_command_invocation_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def format_command_with_short_name(self, begin, arguments, end):
):
return "".join([self._indent(begin), formatted_arguments, end])

return "{}{}\n{}".format(
self._indent(begin), formatted_arguments, self._indent(end)
)
return f"{self._indent(begin)}{formatted_arguments}\n{self._indent(end)}"

def _format_command_with_long_name(self, begin, arguments, end):
with self.indented():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ class GTestDiscoverTests(
"DISCOVERY_TIMEOUT",
"XML_OUTPUT_DIR",
"DISCOVERY_MODE",
"TEST_FILTER",
]
multi_value_keywords = ["EXTRA_ARGS", "PROPERTIES"]
keyword_formatters = {
Expand Down
4 changes: 2 additions & 2 deletions gersemi/custom_command_definition_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def line_comment(self, children):

class CMakeInterpreter(Interpreter):
def __init__(self, stack=None):
self.stack = dict() if stack is None else stack
self.found_commands = dict()
self.stack = {} if stack is None else stack
self.found_commands = {}

@property
def _inner_scope(self):
Expand Down
4 changes: 2 additions & 2 deletions gersemi/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, width, custom_command_definitions):
super().__init__(width)

def file(self, tree):
result = "{}".format(self.__default__(tree))
result = self.__default__(tree)
if result.endswith("\n"):
return result
return result + "\n"
Expand All @@ -36,7 +36,7 @@ def non_command_element(self, tree):
return " ".join(self.visit(child) for child in tree.children)

def line_comment(self, tree):
return self._indent("#{}".format("".join(tree.children)))
return self._indent(f"#{''.join(tree.children)}")

def preformatted_block(self, tree):
disable_formatter, *body, enable_formatter = tree.children
Expand Down
4 changes: 2 additions & 2 deletions gersemi/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def find_custom_command_definitions_in_file_impl(filepath: Path) -> Dict[str, Ke
with smart_open(filepath, "r") as f:
code = f.read()
if not has_custom_command_definition(code):
return dict()
return {}

parse_tree = parser.parse(code)
return find_custom_command_definitions(parse_tree)
Expand All @@ -69,7 +69,7 @@ def find_custom_command_definitions_in_file(
def find_all_custom_command_definitions(
paths: Iterable[Path], pool
) -> Dict[str, Keywords]:
result = dict()
result = {}

files = get_files(paths)
find = find_custom_command_definitions_in_file
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ def parser_with_postprocessing(parser): # pylint: disable=redefined-outer-name
@pytest.fixture(scope="module")
def formatter():
return create_formatter(
do_sanity_check=False, line_length=80, custom_command_definitions=dict()
do_sanity_check=False, line_length=80, custom_command_definitions={}
)
4 changes: 2 additions & 2 deletions tests/tests_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def discover_input_only_cases(where, input_extension):


def get_matching_output_filename(input_filename, output_extension):
return "{}{}".format(remove_extension(input_filename), output_extension)
return f"{remove_extension(input_filename)}{output_extension}"


def make_input_output_case(input_filename, output_extension, where):
Expand All @@ -73,7 +73,7 @@ def discover_input_output_cases(where, input_extension, output_extension):
matching_output_file = get_matching_output_filename(inp, output_extension)
assert (
matching_output_file in output_files
), "Incomplete input-output pair, missing {}".format(matching_output_file)
), f"Incomplete input-output pair, missing {matching_output_file}"

return [make_input_output_case(inp, output_extension, where) for inp in input_files]

Expand Down

0 comments on commit 997b0a9

Please sign in to comment.