mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Automatically Detect Argument Defaults in attrs-Equivalent Decorators

Open t4lz opened this issue 3 years ago • 8 comments

Description

Fixes #12774

Instead of relying only on hardcoded default value, first try to find out the actuall default value of a bool argument to a the class/attrib-maker decorators, and only if the value could not be extracted from the code, fall back to the default value defined in mypy.

This enables the correct handling of decorators which wrap attrs decorators but set different defaults, for example to kw_only.

Test Plan

This commit also adds two test cases. testAttrsWrappedDecorators tests the existing support for wrapping attrs decorators, via a "fake plugin" and testAttrsWrappedDecoratorsWithDifferentDefaults tests the new support for decorators that have different default values than the attrs decorators.

t4lz avatar May 12 '22 16:05 t4lz

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

github-actions[bot] avatar May 12 '22 18:05 github-actions[bot]

Rebased on master and fixed fail.

t4lz avatar May 16 '22 09:05 t4lz

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

github-actions[bot] avatar May 16 '22 13:05 github-actions[bot]

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

github-actions[bot] avatar Jun 23 '22 08:06 github-actions[bot]

I think I'm ready for review :)

t4lz avatar Jun 29 '22 09:06 t4lz

Hey, is it likely this PR would be reviewed if I resolve the new conflicts?

t4lz avatar Aug 05 '22 10:08 t4lz

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

github-actions[bot] avatar Aug 05 '22 10: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 11:08 github-actions[bot]

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

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