qodo-cover icon indicating copy to clipboard operation
qodo-cover copied to clipboard

Improved typing and minor fix in yaml utils methods

Open kuutsav opened this issue 8 months ago โ€ข 3 comments

User Description

  • Changed default args to None, mutable defaults like lists are not recommend in python as they are stateful in subsequent calls.
  • Removed some f strings where the string was static.
  • load_yaml had a path which could have returned None, causing the dict read after that step to raise an exception, I've added an explicit exception in load_yaml in case try_fix_yaml fails as well.

PR Type

Enhancement, Bug fix


Description

  • Added from __future__ import annotations for forward compatibility.
  • Changed keys_fix_yaml parameter type from List[str] to Optional[List[str]] in load_yaml and try_fix_yaml functions.
  • Added checks for None and defaulted keys_fix_yaml to an empty list if not provided.
  • Improved error handling by raising an exception when YAML parsing fails after attempting to fix formatting.
  • Removed redundant f-strings in logging statements.

Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
utils.py
Improved typing, error handling, and logging in YAML utility methods.

cover_agent/utils.py

  • Added from __future__ import annotations for forward compatibility.
  • Changed keys_fix_yaml parameter type from List[str] to
    Optional[List[str]] in load_yaml and try_fix_yaml functions.
  • Added checks for None and defaulted keys_fix_yaml to an empty list if
    not provided.
  • Improved error handling by raising an exception when YAML parsing
    fails after attempting to fix formatting.
  • Removed redundant f-strings in logging statements.
  • +20/-8ย  ย 

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    kuutsav avatar Jun 17 '24 14:06 kuutsav