diff options
author | Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> | 2021-10-10 09:08:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 09:08:31 +0200 |
commit | 087fe6856aac60c8781106c96a2b014fedffffb8 (patch) | |
tree | 0775e4f7c2d7c3e6d61f5504615c126235fef28e /tests/functional | |
parent | 220e27dc5bdd6bdd9dbee56d5c7d33a946c8ad17 (diff) | |
download | pylint-git-087fe6856aac60c8781106c96a2b014fedffffb8.tar.gz |
Add checkers for typing.final for Python version 3.8 or later (#5133)
* Add checkers for typing.final for Python version 3.8 or later
- overridden-final-method
- subclassed-final-class
Closes #3197
Diffstat (limited to 'tests/functional')
6 files changed, 39 insertions, 0 deletions
diff --git a/tests/functional/o/overridden_final_method_py38.py b/tests/functional/o/overridden_final_method_py38.py new file mode 100644 index 000000000..d951c26da --- /dev/null +++ b/tests/functional/o/overridden_final_method_py38.py @@ -0,0 +1,17 @@ +"""Since Python version 3.8, a method decorated with typing.final cannot be +overridden""" + +# pylint: disable=no-init, import-error, invalid-name, using-constant-test, useless-object-inheritance +# pylint: disable=missing-docstring, too-few-public-methods + +from typing import final + +class Base: + @final + def my_method(self): + pass + + +class Subclass(Base): + def my_method(self): # [overridden-final-method] + pass diff --git a/tests/functional/o/overridden_final_method_py38.rc b/tests/functional/o/overridden_final_method_py38.rc new file mode 100644 index 000000000..85fc502b3 --- /dev/null +++ b/tests/functional/o/overridden_final_method_py38.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.8 diff --git a/tests/functional/o/overridden_final_method_py38.txt b/tests/functional/o/overridden_final_method_py38.txt new file mode 100644 index 000000000..2c8bca442 --- /dev/null +++ b/tests/functional/o/overridden_final_method_py38.txt @@ -0,0 +1 @@ +overridden-final-method:16:4:Subclass.my_method:Method 'my_method' overrides a method decorated with typing.final which is defined in class 'Base':HIGH diff --git a/tests/functional/s/subclassed_final_class_py38.py b/tests/functional/s/subclassed_final_class_py38.py new file mode 100644 index 000000000..816ef537e --- /dev/null +++ b/tests/functional/s/subclassed_final_class_py38.py @@ -0,0 +1,16 @@ +"""Since Python version 3.8, a class decorated with typing.final cannot be +subclassed """ + +# pylint: disable=no-init, import-error, invalid-name, using-constant-test, useless-object-inheritance +# pylint: disable=missing-docstring, too-few-public-methods + +from typing import final + + +@final +class Base: + pass + + +class Subclass(Base): # [subclassed-final-class] + pass diff --git a/tests/functional/s/subclassed_final_class_py38.rc b/tests/functional/s/subclassed_final_class_py38.rc new file mode 100644 index 000000000..85fc502b3 --- /dev/null +++ b/tests/functional/s/subclassed_final_class_py38.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.8 diff --git a/tests/functional/s/subclassed_final_class_py38.txt b/tests/functional/s/subclassed_final_class_py38.txt new file mode 100644 index 000000000..46fb5200e --- /dev/null +++ b/tests/functional/s/subclassed_final_class_py38.txt @@ -0,0 +1 @@ +subclassed-final-class:15:0:Subclass:"Class 'Subclass' is a subclass of a class decorated with typing.final: 'Base'":HIGH |