mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Add `__match_args__` to node types

Open dosisod opened this issue 2 years ago • 4 comments

Closes #13243.

For the most part, in order to determine which fields where worth pattern matching against, I looked at what was being displayed in the StrConv class (defined in mypy/strconv.py). I might've missed some fields, but for the most part all of the important ones are there.

In addition, to make pattern matching feel more natural, I re-arranged the fields to better align with how they look in the source code. For example, when matching against OpExpr, you would do:

match o:
    case OpExpr(IntExpr(1), "+", IntExpr(2)):
        pass

instead of:

match o:
    case OpExpr("+", IntExpr(1), IntExpr(2)):
        pass

Also, deleted an old semantic analyzer-related field (imported_names, line 481). Didn't seem to be in use anymore.

dosisod avatar Aug 05 '22 04:08 dosisod

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 05 '22 04:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 05 '22 05:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 05 '22 05:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 05 '22 18:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 22 '22 05:08 github-actions[bot]

@sobolevn , do you know someone who would be able to review this PR? Thanks!

dosisod avatar Aug 22 '22 05:08 dosisod

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Oct 19 '22 02:10 github-actions[bot]

@JukkaL @ilevkivskyi can you please take a look? 🙏

sobolevn avatar Oct 19 '22 08:10 sobolevn

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Oct 21 '22 23:10 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Oct 23 '22 19:10 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Nov 03 '22 23:11 github-actions[bot]