language-python icon indicating copy to clipboard operation
language-python copied to clipboard

Adds new keywords for match statements

Open BekaValentine opened this issue 3 years ago • 3 comments

Description of the Change

This PR adds keywords for the new match statements that were added to Python 3.10.

It does so by making them instances of 'keyword.control.conditional.python'.

Alternate Designs

One alternative option would be to have a separate type for the match statement keywords, however, match statements are arguably a flavor of conditional statement. For example,

match xs:
    case []:
        ...
    case [x,y]:
        ....

is functionally the same as

if type(xs) == list and len(xs) == 0:
    ...
elif type(xs) == list and len(xs) == 2:
    [x,y] = xs
    ...

Benefits

Python 3.10 will highlight correctly in Atom.

Possible Drawbacks

Code for previous versions of Python could have erroneous highlighting.

Applicable Issues

(https://github.com/atom/language-python/issues/335)

BekaValentine avatar Mar 17 '22 04:03 BekaValentine

I don't know enough about the testing library to properly implement tests for this, unfortunately.

BekaValentine avatar Mar 17 '22 04:03 BekaValentine

@maxbrunsfeld would you be up for reviewing this?

BekaValentine avatar Mar 17 '22 04:03 BekaValentine

I tried your patch and currently everything looks good to me. Except the print is highlighted as a keyword and built-in exception class is not highlighted.

Before: image

After: image

Note: I disabled the built-in language-python 0.53.6 package and cloned language-python master branch (HEAD=fd71825) with your patch applied under .atom/packages directory.

Yang-Wei-Ting avatar Jun 03 '22 11:06 Yang-Wei-Ting