Skip to content

adds linter warnings on unused imports #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

christophkloeffel
Copy link
Contributor

@christophkloeffel christophkloeffel commented Mar 9, 2025

closes #49

@christophkloeffel christophkloeffel requested a review from a team as a code owner March 9, 2025 20:51
@christophkloeffel christophkloeffel force-pushed the feature/linter_warning_on_unused_import branch 3 times, most recently from d8eb17d to 946a05f Compare March 9, 2025 21:31
@@ -41,7 +41,7 @@ def __init__(self, mh, stab, verify_checks, debug_vcg, cvc5_binary):
self.abstract_extensions = {}
self.checked_types = set()

def verify(self):
Copy link
Member

@phiwuu phiwuu Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you prefer the name perform_sanity_checks over verify? The new name is fine with me, I just want to understand the reason behind the renaming.

Copy link
Contributor Author

@christophkloeffel christophkloeffel Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was called perform_sanity_checks before, within the "process" method in the trlc.py file. so I kept the naming on this level, thus changing it in the lint.py file. reason: I got rid of the shell method that combined the initialization of the linter object and the verify method

@@ -202,3 +202,34 @@ def verify_array_type(self, n_typ):
"An array with 0 to 1 components should just\n"
"be an optional %s instead." %
n_typ.element_type.name)

def markup_ref(self, item, string_literals):
for string_literal in string_literals:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% clear on the goal of this function. Especially, what shall be returned if reference.package.name == item.name is never true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is not true then it will return None.
with other words: if it did not find a reference in the Markup_String then it does return nothing. and if it does return something. It will be added to the list of found tokens that are referencing the imported package

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an explicit return None at the end of the function. I am surprised pylint does not complain here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is recommended PEP8 to force clarity by explicitly setting the return value if it is meant to be caught. Although the design of python does not enforce this. Every function in python implicitly returns None. So the approach was that None is always expected and you only need to specify other return values than None.
That said, added for clarity

@christophkloeffel christophkloeffel force-pushed the feature/linter_warning_on_unused_import branch from 946a05f to 503d425 Compare March 10, 2025 19:31
phiwuu
phiwuu previously approved these changes Mar 12, 2025
@phiwuu
Copy link
Member

phiwuu commented Mar 12, 2025

@christophkloeffel I have reviewed the change, but there seem to be merge conflicts which cannot be resolved automatically. Please rebase and request a new review. Thanks!

@phiwuu phiwuu added the topic: analysis Affects the Linter or VCG label Mar 12, 2025
@phiwuu phiwuu merged commit 91d87f2 into bmw-software-engineering:main Mar 12, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: analysis Affects the Linter or VCG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter should warn on unused import
2 participants