From 4e2f1ac3cc9858ebc1fbeaa538881a055acc64ec Mon Sep 17 00:00:00 2001 From: "S.Sidarth" <38394431+sidarth16@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:03:45 +0530 Subject: [PATCH 1/5] deregister_printer This function would be helpful to de-register a printer class from the list of _printers already registered with the slither object. --- slither/slither.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/slither/slither.py b/slither/slither.py index 3e44944b34..ef995adce5 100644 --- a/slither/slither.py +++ b/slither/slither.py @@ -196,7 +196,17 @@ def register_printer(self, printer_class: Type[AbstractPrinter]) -> None: instance = printer_class(self, logger_printer) self._printers.append(instance) - + + def deregister_printer(self, printer_class: Type[AbstractPrinter]) -> None: + """ + :param printer_class: Class inheriting from `AbstractPrinter`. + """ + + for obj in self._printers: + if type(obj) == printer_class : + self._printers.remove(obj) + return + def run_detectors(self) -> List[Dict]: """ :return: List of registered detectors results. From 181ee42e71e6d67d8c3d60b8560e06b8ad604325 Mon Sep 17 00:00:00 2001 From: "S.Sidarth" <38394431+sidarth16@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:21:10 +0530 Subject: [PATCH 2/5] pylint: disable unidiomatic-typecheck --- slither/slither.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/slither.py b/slither/slither.py index ef995adce5..5453c186db 100644 --- a/slither/slither.py +++ b/slither/slither.py @@ -203,7 +203,7 @@ def deregister_printer(self, printer_class: Type[AbstractPrinter]) -> None: """ for obj in self._printers: - if type(obj) == printer_class : + if type(obj) == printer_class : # pylint: disable=unidiomatic-typecheck self._printers.remove(obj) return From e48351339c120f7e339ef5cc9e79d3314140aab0 Mon Sep 17 00:00:00 2001 From: sidarth16 Date: Thu, 9 Mar 2023 12:01:49 +0530 Subject: [PATCH 3/5] black --- slither/slither.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slither/slither.py b/slither/slither.py index 5453c186db..eebec65aa5 100644 --- a/slither/slither.py +++ b/slither/slither.py @@ -196,17 +196,17 @@ def register_printer(self, printer_class: Type[AbstractPrinter]) -> None: instance = printer_class(self, logger_printer) self._printers.append(instance) - + def deregister_printer(self, printer_class: Type[AbstractPrinter]) -> None: """ :param printer_class: Class inheriting from `AbstractPrinter`. """ - + for obj in self._printers: - if type(obj) == printer_class : # pylint: disable=unidiomatic-typecheck + if type(obj) == printer_class: # pylint: disable=unidiomatic-typecheck self._printers.remove(obj) return - + def run_detectors(self) -> List[Dict]: """ :return: List of registered detectors results. From 9b69da1cc84d2f51a33656414251dd521de6ba01 Mon Sep 17 00:00:00 2001 From: "S.Sidarth" <38394431+sidarth16@users.noreply.github.com> Date: Fri, 10 Mar 2023 08:59:01 +0530 Subject: [PATCH 4/5] isinstance() --- slither/slither.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/slither.py b/slither/slither.py index eebec65aa5..795f8794b7 100644 --- a/slither/slither.py +++ b/slither/slither.py @@ -203,7 +203,7 @@ def deregister_printer(self, printer_class: Type[AbstractPrinter]) -> None: """ for obj in self._printers: - if type(obj) == printer_class: # pylint: disable=unidiomatic-typecheck + if isinstance(obj, printer_class): self._printers.remove(obj) return From 660ccb9751588f143f613bbe17ef4070d5a77d33 Mon Sep 17 00:00:00 2001 From: "S.Sidarth" <38394431+sidarth16@users.noreply.github.com> Date: Fri, 10 Mar 2023 08:59:40 +0530 Subject: [PATCH 5/5] rename to unregister_printer() --- slither/slither.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/slither.py b/slither/slither.py index 795f8794b7..42f0346bec 100644 --- a/slither/slither.py +++ b/slither/slither.py @@ -197,7 +197,7 @@ def register_printer(self, printer_class: Type[AbstractPrinter]) -> None: instance = printer_class(self, logger_printer) self._printers.append(instance) - def deregister_printer(self, printer_class: Type[AbstractPrinter]) -> None: + def unregister_printer(self, printer_class: Type[AbstractPrinter]) -> None: """ :param printer_class: Class inheriting from `AbstractPrinter`. """