File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ Release date: TBA
114114
115115 Ref #5392
116116
117+ * ``interfaces.implements`` has been deprecated and will be removed in 3.0. Please use standard inheritance
118+ patterns instead of ``__implements__``.
119+
120+ Ref #2287
121+
117122* ``invalid-enum-extension``: Used when a class tries to extend an inherited Enum class.
118123
119124 Closes #5501
Original file line number Diff line number Diff line change @@ -164,6 +164,11 @@ Other Changes
164164
165165 Ref #5392
166166
167+ * ``interfaces.implements `` has been deprecated and will be removed in 3.0. Please use standard inheritance
168+ patterns instead of ``__implements__ ``.
169+
170+ Ref #2287
171+
167172* Added the ``generate-toml-config `` option.
168173
169174 Ref #5462
Original file line number Diff line number Diff line change @@ -162,13 +162,15 @@ def check_consistency(self):
162162 existing_ids .append (message .msgid )
163163
164164 def create_message_definition_from_tuple (self , msgid , msg_tuple ):
165- if isinstance (self , (BaseTokenChecker , BaseRawFileChecker )):
166- default_scope = WarningScope .LINE
167- # TODO: Interfaces: Deprecate looking for implements here # pylint: disable=fixme
168- elif implements (self , (IRawChecker , ITokenChecker )):
169- default_scope = WarningScope .LINE
170- else :
171- default_scope = WarningScope .NODE
165+ with warnings .catch_warnings ():
166+ warnings .filterwarnings ("ignore" , category = DeprecationWarning )
167+ if isinstance (self , (BaseTokenChecker , BaseRawFileChecker )):
168+ default_scope = WarningScope .LINE
169+ # TODO: Interfaces: Deprecate looking for implements here # pylint: disable=fixme
170+ elif implements (self , (IRawChecker , ITokenChecker )):
171+ default_scope = WarningScope .LINE
172+ else :
173+ default_scope = WarningScope .NODE
172174 options = {}
173175 if len (msg_tuple ) > 3 :
174176 (msg , symbol , descr , options ) = msg_tuple
Original file line number Diff line number Diff line change 66
77from __future__ import annotations
88
9+ import warnings
910from collections import namedtuple
1011from tokenize import TokenInfo
1112from typing import TYPE_CHECKING
@@ -52,14 +53,22 @@ class Interface:
5253
5354 @classmethod
5455 def is_implemented_by (cls , instance ):
55- return implements (instance , cls )
56+ with warnings .catch_warnings ():
57+ warnings .filterwarnings ("ignore" , category = DeprecationWarning )
58+ return implements (instance , cls )
5659
5760
5861def implements (
5962 obj : BaseChecker ,
6063 interface : type [Interface ] | tuple [type [Interface ], ...],
6164) -> bool :
6265 """Does the given object (maybe an instance or class) implement the interface."""
66+ # TODO: 3.0: Remove deprecated function # pylint: disable=fixme
67+ warnings .warn (
68+ "implements has been deprecated in favour of using basic "
69+ "inheritance patterns without using __implements__." ,
70+ DeprecationWarning ,
71+ )
6372 implements_ = getattr (obj , "__implements__" , ())
6473 if not isinstance (implements_ , (list , tuple )):
6574 implements_ = (implements_ ,)
Original file line number Diff line number Diff line change @@ -874,21 +874,25 @@ def _astroid_module_checker(self):
874874 """
875875 walker = ASTWalker (self )
876876 _checkers = self .prepare_checkers ()
877- tokencheckers = [
878- c
879- for c in _checkers
880- if (
881- interfaces .implements (c , interfaces .ITokenChecker )
882- or isinstance (c , checkers .BaseTokenChecker )
883- )
884- and c is not self
885- ]
886- rawcheckers = [
887- c
888- for c in _checkers
889- if interfaces .implements (c , interfaces .IRawChecker )
890- or isinstance (c , checkers .BaseRawFileChecker )
891- ]
877+ with warnings .catch_warnings ():
878+ warnings .filterwarnings ("ignore" , category = DeprecationWarning )
879+ tokencheckers = [
880+ c
881+ for c in _checkers
882+ if (
883+ interfaces .implements (c , interfaces .ITokenChecker )
884+ or isinstance (c , checkers .BaseTokenChecker )
885+ )
886+ and c is not self
887+ ]
888+ with warnings .catch_warnings ():
889+ warnings .filterwarnings ("ignore" , category = DeprecationWarning )
890+ rawcheckers = [
891+ c
892+ for c in _checkers
893+ if interfaces .implements (c , interfaces .IRawChecker )
894+ or isinstance (c , checkers .BaseRawFileChecker )
895+ ]
892896 # notify global begin
893897 for checker in _checkers :
894898 checker .open ()
You can’t perform that action at this time.
0 commit comments