File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 11from collections import namedtuple
22import contextlib
3- from functools import wraps
3+ from functools import lru_cache , wraps
44import inspect
55from inspect import Signature , Parameter
66import logging
@@ -1494,17 +1494,29 @@ def get_setters(self):
14941494 continue
14951495 func = getattr (self .o , name )
14961496 if (not callable (func )
1497- or len ( inspect . signature (func ). parameters ) < 2
1497+ or self . number_of_parameters (func ) < 2
14981498 or self .is_alias (func )):
14991499 continue
15001500 setters .append (name [4 :])
15011501 return setters
15021502
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 )
15061517 if ds is None :
15071518 return False
1519+
15081520 return ds .startswith ('Alias for ' )
15091521
15101522 def aliased_name (self , s ):
You can’t perform that action at this time.
0 commit comments