summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pyramid/config/adapters.py2
-rw-r--r--src/pyramid/config/views.py2
-rw-r--r--src/pyramid/csrf.py2
-rw-r--r--src/pyramid/predicates.py2
-rw-r--r--src/pyramid/scripts/proutes.py2
-rw-r--r--src/pyramid/static.py4
-rw-r--r--src/pyramid/urldispatch.py2
-rw-r--r--src/pyramid/viewderivers.py6
-rw-r--r--tests/test_config/test_views.py2
-rw-r--r--tests/test_scripts/test_pserve.py12
-rw-r--r--tests/test_util.py2
11 files changed, 17 insertions, 21 deletions
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 = '<route mismatch>'
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):
diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py
index 6b34f1bd4..2a55ad45d 100644
--- a/tests/test_config/test_views.py
+++ b/tests/test_config/test_views.py
@@ -3099,7 +3099,7 @@ class TestMultiView(unittest.TestCase):
)
mv.add('view5', 100, accept='text/xml')
self.assertEqual(mv.media_views['text/xml'], [(100, 'view5', None)])
- self.assertEqual(set(mv.accepts), set(['text/xml', 'text/html']))
+ self.assertEqual(set(mv.accepts), {'text/xml', 'text/html'})
self.assertEqual(mv.views, [(99, 'view2', None), (100, 'view', None)])
def test_add_with_phash(self):
diff --git a/tests/test_scripts/test_pserve.py b/tests/test_scripts/test_pserve.py
index 2feecf3e0..5e5c28c7b 100644
--- a/tests/test_scripts/test_pserve.py
+++ b/tests/test_scripts/test_pserve.py
@@ -89,13 +89,11 @@ class TestPServeCommand(unittest.TestCase):
self.assertEqual(loader.calls[0]['defaults'], {'a': '1'})
self.assertEqual(
inst.watch_files,
- set(
- [
- os.path.abspath('/base/foo'),
- os.path.abspath('/baz'),
- os.path.abspath(os.path.join(here, '*.py')),
- ]
- ),
+ {
+ os.path.abspath('/base/foo'),
+ os.path.abspath('/baz'),
+ os.path.abspath(os.path.join(here, '*.py')),
+ },
)
def test_config_file_finds_open_url(self):
diff --git a/tests/test_util.py b/tests/test_util.py
index f79cdeb85..8ed082ee4 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -472,7 +472,7 @@ class Test_object_description(unittest.TestCase):
self.assertEqual(self._callFUT(('a', 'b')), "('a', 'b')")
def test_set(self):
- self.assertEqual(self._callFUT(set(['a'])), "{'a'}")
+ self.assertEqual(self._callFUT({'a'}), "{'a'}")
def test_list(self):
self.assertEqual(self._callFUT(['a']), "['a']")