File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
1
from collections import namedtuple
2
2
import contextlib
3
- from functools import wraps
3
+ from functools import lru_cache , wraps
4
4
import inspect
5
5
from inspect import Signature , Parameter
6
6
import logging
@@ -1494,17 +1494,29 @@ def get_setters(self):
1494
1494
continue
1495
1495
func = getattr (self .o , name )
1496
1496
if (not callable (func )
1497
- or len ( inspect . signature (func ). parameters ) < 2
1497
+ or self . number_of_parameters (func ) < 2
1498
1498
or self .is_alias (func )):
1499
1499
continue
1500
1500
setters .append (name [4 :])
1501
1501
return setters
1502
1502
1503
- def is_alias (self , o ):
1504
- """Return whether method object *o* is an alias for another method."""
1505
- ds = inspect .getdoc (o )
1503
+ @staticmethod
1504
+ @lru_cache (maxsize = None )
1505
+ def number_of_parameters (func ):
1506
+ """Return number of parameters of the callable *func*."""
1507
+ return len (inspect .signature (func ).parameters )
1508
+
1509
+ @staticmethod
1510
+ @lru_cache (maxsize = None )
1511
+ def is_alias (method ):
1512
+ """
1513
+ Return whether the object *method* is an alias for another method.
1514
+ """
1515
+
1516
+ ds = inspect .getdoc (method )
1506
1517
if ds is None :
1507
1518
return False
1519
+
1508
1520
return ds .startswith ('Alias for ' )
1509
1521
1510
1522
def aliased_name (self , s ):
You can’t perform that action at this time.
0 commit comments