diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pyramid/config/adapters.py | 13 | ||||
| -rw-r--r-- | src/pyramid/config/routes.py | 2 | ||||
| -rw-r--r-- | src/pyramid/config/tweens.py | 1 | ||||
| -rw-r--r-- | src/pyramid/config/views.py | 6 | ||||
| -rw-r--r-- | src/pyramid/encode.py | 2 | ||||
| -rw-r--r-- | src/pyramid/httpexceptions.py | 1 | ||||
| -rw-r--r-- | src/pyramid/interfaces.py | 2 | ||||
| -rw-r--r-- | src/pyramid/registry.py | 1 | ||||
| -rw-r--r-- | src/pyramid/resource.py | 1 | ||||
| -rw-r--r-- | src/pyramid/router.py | 1 | ||||
| -rw-r--r-- | src/pyramid/scripts/pserve.py | 1 | ||||
| -rw-r--r-- | src/pyramid/scripts/pshell.py | 6 | ||||
| -rw-r--r-- | src/pyramid/traversal.py | 1 | ||||
| -rw-r--r-- | src/pyramid/util.py | 6 |
14 files changed, 22 insertions, 22 deletions
diff --git a/src/pyramid/config/adapters.py b/src/pyramid/config/adapters.py index a64c251ca..8a043cf56 100644 --- a/src/pyramid/config/adapters.py +++ b/src/pyramid/config/adapters.py @@ -76,8 +76,6 @@ class AdaptersConfiguratorMixin: return subscriber def _derive_predicate(self, predicate): - derived_predicate = predicate - if eventonly(predicate): def derived_predicate(*arg): @@ -85,12 +83,12 @@ class AdaptersConfiguratorMixin: # seems pointless to try to fix __doc__, __module__, etc as # predicate will invariably be an instance + else: + derived_predicate = predicate return derived_predicate def _derive_subscriber(self, subscriber, predicates): - derived_subscriber = subscriber - if eventonly(subscriber): def derived_subscriber(*arg): @@ -98,6 +96,8 @@ class AdaptersConfiguratorMixin: if hasattr(subscriber, '__name__'): update_wrapper(derived_subscriber, subscriber) + else: + derived_subscriber = subscriber if not predicates: return derived_subscriber @@ -326,4 +326,7 @@ class AdaptersConfiguratorMixin: def eventonly(callee): - return takes_one_arg(callee, argname='event') + # we do not count a function as eventonly if it accepts *args + # which will open up the possibility for the function to receive + # all of the args + return takes_one_arg(callee, argname='event', allow_varargs=False) diff --git a/src/pyramid/config/routes.py b/src/pyramid/config/routes.py index a7ff66a47..409f36849 100644 --- a/src/pyramid/config/routes.py +++ b/src/pyramid/config/routes.py @@ -542,7 +542,7 @@ class RoutesConfiguratorMixin: def add_default_route_predicates(self): p = pyramid.predicates - for (name, factory) in ( + for name, factory in ( ('xhr', p.XHRPredicate), ('request_method', p.RequestMethodPredicate), ('path_info', p.PathInfoPredicate), diff --git a/src/pyramid/config/tweens.py b/src/pyramid/config/tweens.py index 0eeac333e..1cf6d9262 100644 --- a/src/pyramid/config/tweens.py +++ b/src/pyramid/config/tweens.py @@ -102,7 +102,6 @@ class TweensConfiguratorMixin: @action_method def _add_tween(self, tween_factory, under=None, over=None, explicit=False): - if not isinstance(tween_factory, str): raise ConfigurationError( 'The "tween_factory" argument to add_tween must be a ' diff --git a/src/pyramid/config/views.py b/src/pyramid/config/views.py index 4f5806df3..fababf542 100644 --- a/src/pyramid/config/views.py +++ b/src/pyramid/config/views.py @@ -886,7 +886,7 @@ class ViewsConfiguratorMixin: pvals = {} dvals = {} - for (k, v) in ovals.items(): + for k, v in ovals.items(): if k in valid_predicates: pvals[k] = v else: @@ -1206,7 +1206,7 @@ class ViewsConfiguratorMixin: def add_default_view_predicates(self): p = pyramid.predicates - for (name, factory) in ( + for name, factory in ( ('xhr', p.XHRPredicate), ('request_method', p.RequestMethodPredicate), ('path_info', p.PathInfoPredicate), @@ -2163,7 +2163,7 @@ class StaticURLInfo: self.cache_busters = [] def generate(self, path, request, **kw): - for (url, spec, route_name) in self.registrations: + for url, spec, route_name in self.registrations: if path.startswith(spec): subpath = path[len(spec) :] if WIN: # pragma: no cover diff --git a/src/pyramid/encode.py b/src/pyramid/encode.py index 153940534..f97af4fa4 100644 --- a/src/pyramid/encode.py +++ b/src/pyramid/encode.py @@ -64,7 +64,7 @@ def urlencode(query, doseq=True, quote_via=quote_plus): result = '' prefix = '' - for (k, v) in query: + for k, v in query: k = quote_via(k) if is_nonstr_iter(v): diff --git a/src/pyramid/httpexceptions.py b/src/pyramid/httpexceptions.py index 9d61acd8f..46589b1ec 100644 --- a/src/pyramid/httpexceptions.py +++ b/src/pyramid/httpexceptions.py @@ -129,6 +129,7 @@ redirections that require a ``Location`` field. Reflecting this, these subclasses have one additional keyword argument: ``location``, which indicates the location to which to redirect. """ + import json from string import Template from webob import html_escape as _html_escape diff --git a/src/pyramid/interfaces.py b/src/pyramid/interfaces.py index 6221cc21e..4ee294189 100644 --- a/src/pyramid/interfaces.py +++ b/src/pyramid/interfaces.py @@ -921,7 +921,6 @@ ILogger = IDebugLogger # b/c class IRoutePregenerator(Interface): def __call__(request, elements, kw): - """A pregenerator is a function associated by a developer with a :term:`route`. The pregenerator for a route is called by :meth:`pyramid.request.Request.route_url` in order to adjust the set @@ -1384,7 +1383,6 @@ class IIntrospectable(Interface): """ # noqa: E501 def __hash__(): - """Introspectables must be hashable. The typical implementation of an introsepectable's __hash__ is:: diff --git a/src/pyramid/registry.py b/src/pyramid/registry.py index 971ae786a..0b983a6c5 100644 --- a/src/pyramid/registry.py +++ b/src/pyramid/registry.py @@ -208,7 +208,6 @@ class Introspector: @implementer(IIntrospectable) class Introspectable(dict): - order = 0 # mutated by introspector.add action_info = None # mutated by self.register diff --git a/src/pyramid/resource.py b/src/pyramid/resource.py index 8ddf4c447..a89395f18 100644 --- a/src/pyramid/resource.py +++ b/src/pyramid/resource.py @@ -1,4 +1,5 @@ """ Backwards compatibility shim module (forever). """ + from pyramid.asset import * # noqa b/w compat resolve_resource_spec = resolve_asset_spec # noqa diff --git a/src/pyramid/router.py b/src/pyramid/router.py index 61660c41b..0b7554e23 100644 --- a/src/pyramid/router.py +++ b/src/pyramid/router.py @@ -28,7 +28,6 @@ from pyramid.view import _call_view @implementer(IRouter) class Router: - debug_notfound = False debug_routematch = False diff --git a/src/pyramid/scripts/pserve.py b/src/pyramid/scripts/pserve.py index b4a4af977..7504d9a1f 100644 --- a/src/pyramid/scripts/pserve.py +++ b/src/pyramid/scripts/pserve.py @@ -31,7 +31,6 @@ def main(argv=sys.argv, quiet=False, original_ignore_files=None): class PServeCommand: - description = """\ This command serves a web application that uses a PasteDeploy configuration file for the server and application. diff --git a/src/pyramid/scripts/pshell.py b/src/pyramid/scripts/pshell.py index 9122ab32e..63600abaf 100644 --- a/src/pyramid/scripts/pshell.py +++ b/src/pyramid/scripts/pshell.py @@ -164,9 +164,9 @@ class PShellCommand: env_help['root'] = 'Root of the default resource tree.' env_help['registry'] = 'Active Pyramid registry.' env_help['request'] = 'Active request object.' - env_help[ - 'root_factory' - ] = 'Default root factory used to create `root`.' + env_help['root_factory'] = ( + 'Default root factory used to create `root`.' + ) # load the pshell section of the ini file env.update(self.loaded_objects) diff --git a/src/pyramid/traversal.py b/src/pyramid/traversal.py index 00b64bae2..986069d1d 100644 --- a/src/pyramid/traversal.py +++ b/src/pyramid/traversal.py @@ -597,7 +597,6 @@ class ResourceTreeTraverser: matchdict = request.matchdict if matchdict is not None: - path = matchdict.get('traverse', '/') or '/' if is_nonstr_iter(path): # this is a *traverse stararg (not a {traverse}) diff --git a/src/pyramid/util.py b/src/pyramid/util.py index 8d384cc84..c71528a49 100644 --- a/src/pyramid/util.py +++ b/src/pyramid/util.py @@ -652,7 +652,7 @@ def make_contextmanager(fn): return wrapper -def takes_one_arg(callee, attr=None, argname=None): +def takes_one_arg(callee, attr=None, argname=None, allow_varargs=True): ismethod = False if attr is None: attr = '__call__' @@ -679,11 +679,13 @@ def takes_one_arg(callee, attr=None, argname=None): if not args: return False + if not allow_varargs and argspec.varargs: + return False + if len(args) == 1: return True if argname: - defaults = argspec[3] if defaults is None: defaults = () |
