80
80
from astroid import nodes
81
81
from astroid .nodes import LocalsDictNodeNG
82
82
83
+ if sys .version_info >= (3 , 8 ) or TYPE_CHECKING :
84
+ # pylint: disable-next=ungrouped-imports
85
+ from functools import cached_property
86
+ else :
87
+ from astroid .decorators import cachedproperty as cached_property
88
+
83
89
84
90
def _is_const (value ):
85
91
return isinstance (value , tuple (CONST_CLS ))
@@ -824,7 +830,7 @@ def _infer_name(self, frame, name):
824
830
return name
825
831
return None
826
832
827
- @decorators . cachedproperty
833
+ @cached_property
828
834
def fromlineno (self ):
829
835
"""The first line that this node appears on in the source code.
830
836
@@ -833,7 +839,7 @@ def fromlineno(self):
833
839
lineno = super ().fromlineno
834
840
return max (lineno , self .parent .fromlineno or 0 )
835
841
836
- @decorators . cachedproperty
842
+ @cached_property
837
843
def arguments (self ):
838
844
"""Get all the arguments for this node, including positional only and positional and keyword"""
839
845
return list (itertools .chain ((self .posonlyargs or ()), self .args or ()))
@@ -2601,7 +2607,7 @@ def postinit(
2601
2607
if body is not None :
2602
2608
self .body = body
2603
2609
2604
- @decorators . cachedproperty
2610
+ @cached_property
2605
2611
def blockstart_tolineno (self ):
2606
2612
"""The line on which the beginning of this block ends.
2607
2613
@@ -2734,7 +2740,7 @@ def postinit(
2734
2740
See astroid/protocols.py for actual implementation.
2735
2741
"""
2736
2742
2737
- @decorators . cachedproperty
2743
+ @cached_property
2738
2744
def blockstart_tolineno (self ):
2739
2745
"""The line on which the beginning of this block ends.
2740
2746
@@ -3093,7 +3099,7 @@ def postinit(
3093
3099
if isinstance (self .parent , If ) and self in self .parent .orelse :
3094
3100
self .is_orelse = True
3095
3101
3096
- @decorators . cachedproperty
3102
+ @cached_property
3097
3103
def blockstart_tolineno (self ):
3098
3104
"""The line on which the beginning of this block ends.
3099
3105
@@ -3762,7 +3768,7 @@ def _wrap_attribute(self, attr):
3762
3768
return const
3763
3769
return attr
3764
3770
3765
- @decorators . cachedproperty
3771
+ @cached_property
3766
3772
def _proxied (self ):
3767
3773
builtins = AstroidManager ().builtins_module
3768
3774
return builtins .getattr ("slice" )[0 ]
@@ -4384,7 +4390,7 @@ def postinit(
4384
4390
if orelse is not None :
4385
4391
self .orelse = orelse
4386
4392
4387
- @decorators . cachedproperty
4393
+ @cached_property
4388
4394
def blockstart_tolineno (self ):
4389
4395
"""The line on which the beginning of this block ends.
4390
4396
@@ -4500,7 +4506,7 @@ def postinit(
4500
4506
See astroid/protocols.py for actual implementation.
4501
4507
"""
4502
4508
4503
- @decorators . cachedproperty
4509
+ @cached_property
4504
4510
def blockstart_tolineno (self ):
4505
4511
"""The line on which the beginning of this block ends.
4506
4512
0 commit comments