diff options
author | Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> | 2023-03-03 14:31:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 14:31:40 +0100 |
commit | 7f24c414a3b4ec2af92e3eddaeb5a26207e4fe10 (patch) | |
tree | 6183a058db6525a181a1d737b9ab3435312a0dce /tests | |
parent | 43cc43202d3f08ec9da29d57a4655cc22ad160fa (diff) | |
download | pylint-git-7f24c414a3b4ec2af92e3eddaeb5a26207e4fe10.tar.gz |
Accept values of the form ``<class name>.<attribute name>`` for the `exclude-protected` list (#8364)
Closes #7343
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/p/protected_access.py | 11 | ||||
-rw-r--r-- | tests/functional/p/protected_access.rc | 2 | ||||
-rw-r--r-- | tests/functional/p/protected_access.txt | 8 |
3 files changed, 16 insertions, 5 deletions
diff --git a/tests/functional/p/protected_access.py b/tests/functional/p/protected_access.py index 209f571c4..6587e50a7 100644 --- a/tests/functional/p/protected_access.py +++ b/tests/functional/p/protected_access.py @@ -3,6 +3,8 @@ # pylint: disable=missing-function-docstring, invalid-metaclass, no-member # pylint: disable=no-self-argument, undefined-variable, unused-variable +import os + # Test that exclude-protected can be used to exclude names from protected-access warning class Protected: def __init__(self): @@ -41,3 +43,12 @@ class Light: def func(light: Light) -> None: print(light._light_internal) # [protected-access] + + +# os._exit is excluded from the protected-access check by default +print(os._exit) + +# BaseTomato._sauce is included in the `exclude-protected` list +# and does not emit a `protected-access` message: +class BaseTomato: + _sauce = 42 diff --git a/tests/functional/p/protected_access.rc b/tests/functional/p/protected_access.rc index 3ebab1b6f..c599f2a4a 100644 --- a/tests/functional/p/protected_access.rc +++ b/tests/functional/p/protected_access.rc @@ -1,2 +1,2 @@ [CLASSES] -exclude-protected=_meta,_manager +exclude-protected=_meta,_manager,os._exit,BaseTomato._sauce diff --git a/tests/functional/p/protected_access.txt b/tests/functional/p/protected_access.txt index 50e6c5d5b..e0bebb76a 100644 --- a/tests/functional/p/protected_access.txt +++ b/tests/functional/p/protected_access.txt @@ -1,4 +1,4 @@ -protected-access:17:0:17:9::Access to a protected member _teta of a client class:UNDEFINED -protected-access:29:16:29:26:Application.__no_special__:Access to a protected member _nargs of a client class:UNDEFINED -protected-access:39:14:39:35:Light.func:Access to a protected member _light_internal of a client class:UNDEFINED -protected-access:43:10:43:31:func:Access to a protected member _light_internal of a client class:UNDEFINED +protected-access:19:0:19:9::Access to a protected member _teta of a client class:UNDEFINED +protected-access:31:16:31:26:Application.__no_special__:Access to a protected member _nargs of a client class:UNDEFINED +protected-access:41:14:41:35:Light.func:Access to a protected member _light_internal of a client class:UNDEFINED +protected-access:45:10:45:31:func:Access to a protected member _light_internal of a client class:UNDEFINED |