diff options
| author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-10-25 09:27:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-25 09:27:47 +0200 |
| commit | 8cfce138e9519f63e969e89359e86e140b2f0f13 (patch) | |
| tree | eff12c3d285d53b7a6e4cf387f265ca029c72b51 /tests | |
| parent | ed3449fee063d91f050c6b733030d3b3d7ad719f (diff) | |
| download | pylint-git-8cfce138e9519f63e969e89359e86e140b2f0f13.tar.gz | |
Add ``mixin-class-rgx`` option (#5203)
Co-authored-by: Alpha <alpha@pokesplash.net>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/functional/m/mixin_class_rgx.py | 60 | ||||
| -rw-r--r-- | tests/functional/m/mixin_class_rgx.rc | 3 | ||||
| -rw-r--r-- | tests/functional/m/mixin_class_rgx.txt | 3 |
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/functional/m/mixin_class_rgx.py b/tests/functional/m/mixin_class_rgx.py new file mode 100644 index 000000000..1f6ea21e6 --- /dev/null +++ b/tests/functional/m/mixin_class_rgx.py @@ -0,0 +1,60 @@ +"""Tests for the mixin-class-rgx option""" +# pylint: disable=too-few-public-methods + + +# Tests for not-async-context-manager + + +class AsyncManagerMixedin: + """Class that does not match the option pattern""" + + def __aenter__(self): + pass + + +class AsyncManagerMixin: + """Class that does match the option pattern""" + + def __aenter__(self): + pass + + +async def check_not_async_context_manager(): + """Function calling the classes for not-async-context-manager""" + async with AsyncManagerMixedin: # [not-async-context-manager] + pass + async with AsyncManagerMixin(): + pass + + +# Tests for attribute-defined-outside-init + + +class OutsideInitMixedin: + """Class that does not match the option pattern""" + + def set_attribute(self): + """Set an attribute outside of __init__""" + self.attr = 1 # [attribute-defined-outside-init] + + +class OutsideInitMixin: + """Class that does match the option pattern""" + + def set_attribute(self): + """Set an attribute outside of __init__""" + self.attr = 1 + + +# Tests for no-member + + +class NoMemberMixedin: + """Class that does not match the option pattern""" + +MY_CLASS = OutsideInitMixedin().method() # [no-member] + +class NoMemberMixin: + """Class that does match the option pattern""" + +MY_OTHER_CLASS = NoMemberMixin().method() diff --git a/tests/functional/m/mixin_class_rgx.rc b/tests/functional/m/mixin_class_rgx.rc new file mode 100644 index 000000000..4ca300e4a --- /dev/null +++ b/tests/functional/m/mixin_class_rgx.rc @@ -0,0 +1,3 @@ +[TYPECHECK] +ignore-mixin-members=yes +mixin-class-rgx=.*[Mm]ixin diff --git a/tests/functional/m/mixin_class_rgx.txt b/tests/functional/m/mixin_class_rgx.txt new file mode 100644 index 000000000..eb39a1185 --- /dev/null +++ b/tests/functional/m/mixin_class_rgx.txt @@ -0,0 +1,3 @@ +not-async-context-manager:24:4:check_not_async_context_manager:Async context manager 'AsyncManagerMixedin' doesn't implement __aenter__ and __aexit__.:HIGH +attribute-defined-outside-init:38:8:OutsideInitMixedin.set_attribute:Attribute 'attr' defined outside __init__:HIGH +no-member:55:11::Instance of 'OutsideInitMixedin' has no 'method' member:INFERENCE |
