From 66b88e8ca86660cbcc63770b29d7c8a370594753 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Wed, 6 May 2020 22:58:26 -0700 Subject: set() -> {} --- src/pyramid/config/adapters.py | 2 +- src/pyramid/config/views.py | 2 +- src/pyramid/csrf.py | 2 +- src/pyramid/predicates.py | 2 +- src/pyramid/scripts/proutes.py | 2 +- src/pyramid/static.py | 4 ++-- src/pyramid/urldispatch.py | 2 +- src/pyramid/viewderivers.py | 6 ++---- 8 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/pyramid/config/adapters.py b/src/pyramid/config/adapters.py index 6a8a0aa32..5035651cb 100644 --- a/src/pyramid/config/adapters.py +++ b/src/pyramid/config/adapters.py @@ -121,7 +121,7 @@ class AdaptersConfiguratorMixin: # with all args, the eventonly hack would not have been required. # At this point, though, using .subscriptions and manual execution # is not possible without badly breaking backwards compatibility. - if all((predicate(*arg) for predicate in predicates)): + if all(predicate(*arg) for predicate in predicates): return derived_subscriber(*arg) if hasattr(subscriber, '__name__'): diff --git a/src/pyramid/config/views.py b/src/pyramid/config/views.py index 466c31f94..a680eafb3 100644 --- a/src/pyramid/config/views.py +++ b/src/pyramid/config/views.py @@ -196,7 +196,7 @@ def predicated_view(view, info): return view(context, request) def checker(context, request): - return all((predicate(context, request) for predicate in preds)) + return all(predicate(context, request) for predicate in preds) predicate_wrapper.__predicated__ = checker predicate_wrapper.__predicates__ = preds diff --git a/src/pyramid/csrf.py b/src/pyramid/csrf.py index 75ad1b734..8e711c9a7 100644 --- a/src/pyramid/csrf.py +++ b/src/pyramid/csrf.py @@ -335,7 +335,7 @@ def check_csrf_origin( request.registry.settings.get("pyramid.csrf_trusted_origins", []) ) - if request.host_port not in set(["80", "443"]): + if request.host_port not in {"80", "443"}: trusted_origins.append("{0.domain}:{0.host_port}".format(request)) else: trusted_origins.append(request.domain) diff --git a/src/pyramid/predicates.py b/src/pyramid/predicates.py index f51ea3b21..8b443e79b 100644 --- a/src/pyramid/predicates.py +++ b/src/pyramid/predicates.py @@ -271,7 +271,7 @@ class EffectivePrincipalsPredicate: if is_nonstr_iter(val): self.val = set(val) else: - self.val = set((val,)) + self.val = {val} def text(self): return 'effective_principals = %s' % sorted(list(self.val)) diff --git a/src/pyramid/scripts/proutes.py b/src/pyramid/scripts/proutes.py index 75db52182..64cd37727 100644 --- a/src/pyramid/scripts/proutes.py +++ b/src/pyramid/scripts/proutes.py @@ -82,7 +82,7 @@ def _get_request_methods(route_request_methods, view_request_methods): if has_methods and not request_methods: request_methods = '' elif request_methods: - if excludes and request_methods == set([ANY_KEY]): + if excludes and request_methods == {ANY_KEY}: for exclude in excludes: request_methods.add('!%s' % exclude) diff --git a/src/pyramid/static.py b/src/pyramid/static.py index bf843f385..61baa0316 100644 --- a/src/pyramid/static.py +++ b/src/pyramid/static.py @@ -260,7 +260,7 @@ def _add_vary(response, option): response.vary = vary -_seps = set(['/', os.sep]) +_seps = {'/', os.sep} def _contains_slash(item): @@ -269,7 +269,7 @@ def _contains_slash(item): return True -_has_insecure_pathelement = set(['..', '.', '']).intersection +_has_insecure_pathelement = {'..', '.', ''}.intersection @lru_cache(1000) diff --git a/src/pyramid/urldispatch.py b/src/pyramid/urldispatch.py index 37bc70962..7aea1146b 100644 --- a/src/pyramid/urldispatch.py +++ b/src/pyramid/urldispatch.py @@ -85,7 +85,7 @@ class RoutesMapper: if match is not None: preds = route.predicates info = {'match': match, 'route': route} - if preds and not all((p(info, request) for p in preds)): + if preds and not all(p(info, request) for p in preds): continue return info diff --git a/src/pyramid/viewderivers.py b/src/pyramid/viewderivers.py index 7f15559b1..6461c4829 100644 --- a/src/pyramid/viewderivers.py +++ b/src/pyramid/viewderivers.py @@ -46,10 +46,8 @@ class DefaultViewMapper: def __call__(self, view): if is_unbound_method(view) and self.attr is None: raise ConfigurationError( - ( - 'Unbound method calls are not supported, please set the ' - 'class as your `view` and the method as your `attr`' - ) + 'Unbound method calls are not supported, please set the ' + 'class as your `view` and the method as your `attr`' ) if inspect.isclass(view): -- cgit v1.2.3