1st1 avatar 1st1 committed 8c05c4e

pep 362: PEP-8-ify inspect.py (trim lines)

Comments (0)

Files changed (1)

         try:
             ba = sig.bind_partial(*partial_args, **partial_keywords)
         except TypeError as ex:
-            raise ValueError('partial object {!r} has incorrect arguments'. \
-                             format(obj)) from ex
+            msg = 'partial object {!r} has incorrect arguments'.format(obj)
+            raise ValueError(msg) from ex
 
         for arg_name, arg_value in ba.arguments.items():
             param = new_params[arg_name]
 
     if isinstance(obj, types.BuiltinFunctionType):
         # Raise a nicer error message for builtins
-        raise ValueError('no signature found for builtin '
-                         'function {!r}'.format(obj)) from None
+        msg = 'no signature found for builtin function {!r}'.format(obj)
+        raise ValueError(msg) from None
 
     raise ValueError('callable {!r} is not supported by signature'.format(obj))
 
         else:
             name = str(name)
             if kind != _POSITIONAL_ONLY and not name.isidentifier():
-                raise ValueError('{!r} is not a valid parameter name'. \
-                                 format(name))
+                msg = '{!r} is not a valid parameter name'.format(name)
+                raise ValueError(msg)
             self._name = name
 
         self._partial_kwarg = _partial_kwarg
         try:
             return self._default
         except AttributeError:
-            raise AttributeError('parameter does not have a default value') from None
+            msg = 'parameter does not have a default value'
+            raise AttributeError(msg) from None
 
     @property
     def annotation(self):
         try:
             return self._annotation
         except AttributeError:
-            raise AttributeError('parameter does not have an annotation') from None
+            msg = 'parameter does not have an annotation'
+            raise AttributeError(msg) from None
 
     @property
     def kind(self):
                 for idx, param in enumerate(parameters):
                     kind = param.kind
                     if kind < top_kind:
-                        raise ValueError('wrong parameter order: {} before {}'. \
-                                         format(top_kind, param.kind))
+                        msg = 'wrong parameter order: {} before {}'
+                        msg = msg.format(top_kind, param.kind)
+                        raise ValueError(msg)
                     else:
                         top_kind = kind
 
                         param = param.replace(name=name)
 
                     if name in params:
-                        raise ValueError('duplicate parameter name: {!r}'. \
-                                         format(name))
+                        msg = 'duplicate parameter name: {!r}'.format(name)
+                        raise ValueError(msg)
                     params[name] = param
             else:
                 params = OrderedDict(((param.name, param)
             return False
 
         other_positions = {param: idx
-                            for idx, param in enumerate(other.parameters.keys())}
+                           for idx, param in enumerate(other.parameters.keys())}
 
         for idx, (param_name, param) in enumerate(self.parameters.items()):
             if param.kind == _KEYWORD_ONLY:
                 except KeyError:
                     return False
                 else:
-                    if idx != other_idx or param != other.parameters[param_name]:
+                    if (idx != other_idx or
+                                    param != other.parameters[param_name]):
                         return False
 
         return True
                         break
                     elif param.name in kwargs:
                         if param.kind == _POSITIONAL_ONLY:
-                            raise TypeError('{arg!r} parameter is positional only, '
-                                            'but was passed as a keyword'. \
-                                            format(arg=param.name)) from None
+                            msg = '{arg!r} parameter is positional only, ' \
+                                  'but was passed as a keyword'
+                            msg = msg.format(arg=param.name)
+                            raise TypeError(msg) from None
                         parameters_ex = (param,)
                         break
-                    elif param.kind == _VAR_KEYWORD or hasattr(param, 'default'):
+                    elif (param.kind == _VAR_KEYWORD or
+                                                hasattr(param, 'default')):
                         # That's fine too - we have a default value for this
                         # parameter.  So, lets start parsing `kwargs`, starting
                         # with the current parameter
                             parameters_ex = (param,)
                             break
                         else:
-                            raise TypeError('{arg!r} parameter lacking default'
-                                            ' value'.format(arg=param.name)) from None
+                            msg = '{arg!r} parameter lacking default value'
+                            msg = msg.format(arg=param.name)
+                            raise TypeError(msg) from None
             else:
                 # We have a positional argument to process
                 try:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.