Skip to content

refactor: Deduplicate scoring logic and cleanup unused code in scoring.py #6

@nice-bills

Description

@nice-bills

While reviewing the validator scoring logic in talisman_ai/analyzer/scoring.py, I identified several opportunities to improve maintainability and code quality through refactoring and cleanup.

Changes:

  1. Deduplicate Post Age Logic: Both compute_post_score and score_post_entry contain identical blocks of code for calculating post age and enforcing the 10-day cutoff rule. I propose extracting this into a helper function is_post_too_old(created_at).
  2. Remove Dead Code: The function _build_canonical_from_dict appears to be unused within the repository and contains a docstring inconsistency (claims to take a dict but treats it as a PostClassification object).
  3. Improve Type Safety: Add missing type hints for the analyzer arguments in score_post_entry and top_k_relevance_from_analyzer to ensure they are correctly identified as SubnetRelevanceAnalyzer instances.
  4. Cleanup Component Calculation: Refactor score_post_entry to use the unified scoring components to ensure consistent behavior across different entry points.

I would like to submit a PR to address these items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions