From d888353df5222f022bdcb699be2a41b55b7282d0 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Sun, 7 Jul 2024 20:16:57 -0700 Subject: [PATCH] Update maplint --- tools/maplint/source/__main__.py | 2 +- tools/maplint/source/error.py | 9 +++++++-- tools/maplint/source/lint.py | 11 ++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/maplint/source/__main__.py b/tools/maplint/source/__main__.py index 27cddb160eb9..4509ef75893e 100644 --- a/tools/maplint/source/__main__.py +++ b/tools/maplint/source/__main__.py @@ -45,7 +45,7 @@ def print_error(message: str, filename: str, line_number: int, github_error_styl def print_maplint_error(error: MaplintError, github_error_style: bool): print_error( - f"{f'(in pop {error.pop_id}) ' if error.pop_id else ''}{f'(at {error.coordinates}) ' if error.coordinates else ''}{error}", + f"{f'(in pop {error.pop_id}) ' if error.pop_id else ''}{f'(at {error.coordinates}) ' if error.coordinates else ''}{error}" + (f"\n {error.help}" if error.help is not None else ""), error.file_name, error.line_number, github_error_style, diff --git a/tools/maplint/source/error.py b/tools/maplint/source/error.py index abb04cc22729..f12a629c2fd6 100644 --- a/tools/maplint/source/error.py +++ b/tools/maplint/source/error.py @@ -1,3 +1,5 @@ +from typing import Optional + """Linting error with associated filename and line number.""" class MaplintError(Exception): """The DMM file name the exception occurred in""" @@ -7,10 +9,13 @@ class MaplintError(Exception): line_number = 1 """The optional coordinates""" - coordinates: str = None + coordinates: Optional[str] = None """The optional pop ID""" - pop_id: str = None + pop_id: Optional[str] = None + + """The optional help message""" + help: Optional[str] = None def __init__(self, message: str, file_name: str, line_number = 1): Exception.__init__(self, message) diff --git a/tools/maplint/source/lint.py b/tools/maplint/source/lint.py index e3cb32467d77..ee86d29be52b 100644 --- a/tools/maplint/source/lint.py +++ b/tools/maplint/source/lint.py @@ -66,7 +66,13 @@ def __init__(self, typepath, data = {}): def matches(self, identified: Content, neighbor: Content): if self.identical: - return neighbor == identified + if identified.path != neighbor.path: + return False + + if identified.var_edits != neighbor.var_edits: + return False + + return True if self.typepath is not None: if self.typepath.matches_path(neighbor.path): @@ -260,9 +266,8 @@ def run(self, map_data: DMM) -> list[MaplintError]: coordinate_texts.append(f"and {leftover_coordinates} more") for failure in failures: - if self.help is not None: - failure.message += f"\n {self.help}" failure.coordinates = ', '.join(coordinate_texts) + failure.help = self.help failure.pop_id = pop all_failures.append(failure)