Skip to content

Thai lunar date functions may need refactoring - currently too complex #1017

@bact

Description

@bact

Description

Ruff warns that two of the functions for Thai lunar date are too complex.

It may possible to convert the long if/else to some values in arrays and compute according to values in the arrays.

Expected results

Simpler/shorter functions

Current results

pythainlp/util/thai_lunar_date.py:251:5: C901 calculate_f_year_f_dev is too complex (113 > 40)

pythainlp/util/thai_lunar_date.py:614:5: C901 to_lunar_date is too complex (108 > 40)

Steps to reproduce

Run ruff against the code

(currently already inside this workflow: https://github.com/PyThaiNLP/pythainlp/blob/dev/.github/workflows/lint.yml )

PyThaiNLP version

5.0.4

Python version

Any

Operating system and version

Any

More info

No response

Possible solution

No response

Files

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedno contributor yetrefactoringa technical improvement which does not add any new features or change existing features.

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions