Currently, all cortexutils is missing typing, but we should start with the worker module as it is the root of the inheritance.
This makes writing analyzers with any static type checker very tedious.
One example of a noisy/hard function to type is any that uses error with conditional branching:
from cortexutils.analyzer import Analyzer
class ExampleAnalyzer(Analyzer):
...
def preprocess_url(self, url: str) -> str:
if not url.startswith("http"):
self.error(f"Invalid URL: {url}")
else:
processed_url = url.lower()
return processed_url
cortexutils/example.py:5: error: Missing return statement [return]
Found 1 error in 1 file (checked 6 source files)
Current workaround is to add # type: ignore[return], which is not ideal as it invalidates most of the type safety.
Currently, all cortexutils is missing typing, but we should start with the worker module as it is the root of the inheritance.
This makes writing analyzers with any static type checker very tedious.
One example of a noisy/hard function to type is any that uses
errorwith conditional branching:Current workaround is to add
# type: ignore[return], which is not ideal as it invalidates most of the type safety.