Skip to content

Reuse of code in goal_summary.py #5

@StroboBrain

Description

@StroboBrain

Following match statement used several times in your GoalSummery class.
Starting at line 154, 205, 252, 301, 457, 507, 552, 598.

example from your code

        match unit_value:
            case "kcal":
                unit = 'calories'
            case "km":
                unit = 'distance'
            case "min":
                unit = 'duration'

To reduce the lines of code, I suggest to turn this match statement into a function. This would reduce the amount of lines in your code.

your code refactored as function get_unit

def get_unit(unit_value: str)-> str:
    match unit_value:
            case "kcal":
                unit = 'calories'
            case "km":
                unit = 'distance'
            case "min":
                unit = 'duration'
    return unit

Additional Feedback

The main.py class runs perfectly after I cloned your repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions