radon icon indicating copy to clipboard operation
radon copied to clipboard

Added support of match pattern

Open DolajoCZ opened this issue 4 years ago • 7 comments

Added support of match pattern introduced in python 3.10. @rubik comments/proposals are welcomed.

DolajoCZ avatar Oct 08 '21 20:10 DolajoCZ

This is a very welcome and also a very much needed addition to radon. @DolajoCZ, thank you for this PR.

I would like to know whether case _: is treated the same way as else: is, i.e., it should not add complexity. Is that the case here? It wasn't obvious to me in this PR's code that I've read.

PedanticHacker avatar Oct 08 '21 21:10 PedanticHacker

Yes, case _: is covered by this line. You can try it with following code.

def match_test_with_else() -> None:
    """Match test - with _ (else) case."""
    a = 0

    match a:
        case 1:
            pass
        case 2:
            pass
        case _:
            pass


def match_test_without_else() -> None:
    """Match test - without _ (else) case."""
    a = 0

    match a:
        case 1:
            pass
        case 2:
            pass

For both functions you get rating A(3)

DolajoCZ avatar Oct 09 '21 06:10 DolajoCZ

Why is this still an open PR and not a merged one? Also, why is radon so slow at releasing a new version?

PedanticHacker avatar Dec 23 '21 19:12 PedanticHacker

@rubik, are you still alive?

PedanticHacker avatar Jan 21 '22 11:01 PedanticHacker

@DolajoCZ Thanks for the contribution, much appreciated. It would be great if you could document this addition in the table on this page: https://github.com/rubik/radon/blob/master/docs/intro.rst

The PR is otherwise ready for merging.

@PedanticHacker I am indeed alive, I'm just very busy. If you want to help maintain the project let me know.

rubik avatar Feb 23 '22 20:02 rubik

@rubik, it would actually be an honor for me to contribute to this project. I'm using radon quite often to test cyclomatic complexity in my chess GUI app named SuperChess, so I'd like to give back to the community.

PedanticHacker avatar Feb 23 '22 21:02 PedanticHacker

@rubik doc was updated. Thank you for notice.

Can you please also check status of this this PR. Thanks

DolajoCZ avatar Feb 24 '22 17:02 DolajoCZ

Any updates on this PR? I just found radon - what an awesome tool. It would be great if this PR was merged and a new release was issued to fully support python 10!

mkokotovich avatar Dec 15 '22 17:12 mkokotovich

Do we have an update on this one? Without it cyclomatic complexity is still wrongly detected as O(1) for match . @rubik

7ovana avatar Feb 06 '23 13:02 7ovana

This is batshit crazy to abandon a project like radon. It’s a very good tool.

PedanticHacker avatar Feb 06 '23 18:02 PedanticHacker

@DolajoCZ Thanks for the contribution, I finally got around to take a look again and merge it. Apologies everyone for the lack of maintenance, I've been very busy with personal and work commitments.

rubik avatar Mar 25 '23 15:03 rubik