Skip to content

Add typing to Worker module #37

Open

Description

@JuanTecedor

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.

Activity

  1. added this to the 2.3.0 milestone on Jun 20, 2026
  2. linked a pull request that will close this issueAdd typing to worker module #38on Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions