summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2020-09-29 22:12:52 -0700
committerSteve Piercy <web@stevepiercy.com>2020-09-29 22:12:52 -0700
commit9925a6251886e3692215f3c8ea052dc9a0687d28 (patch)
treef5fa501fa21ce99a4ffd108fce525572eb0b7370
parent6116c6c8be01909724127b055be633c53c4782fc (diff)
downloadpyramid-9925a6251886e3692215f3c8ea052dc9a0687d28.tar.gz
pyramid-9925a6251886e3692215f3c8ea052dc9a0687d28.tar.bz2
pyramid-9925a6251886e3692215f3c8ea052dc9a0687d28.zip
Blackify for v20.8b1
-rw-r--r--src/pyramid/asset.py4
-rw-r--r--src/pyramid/authentication.py40
-rw-r--r--src/pyramid/authorization.py12
-rw-r--r--src/pyramid/config/__init__.py16
-rw-r--r--src/pyramid/config/actions.py7
-rw-r--r--src/pyramid/config/adapters.py2
-rw-r--r--src/pyramid/config/assets.py16
-rw-r--r--src/pyramid/config/factories.py8
-rw-r--r--src/pyramid/config/i18n.py2
-rw-r--r--src/pyramid/config/routes.py6
-rw-r--r--src/pyramid/config/security.py2
-rw-r--r--src/pyramid/config/settings.py4
-rw-r--r--src/pyramid/config/views.py14
-rw-r--r--src/pyramid/config/zca.py4
-rw-r--r--src/pyramid/csrf.py18
-rw-r--r--src/pyramid/decorator.py2
-rw-r--r--src/pyramid/events.py10
-rw-r--r--src/pyramid/exceptions.py9
-rw-r--r--src/pyramid/i18n.py6
-rw-r--r--src/pyramid/interfaces.py229
-rw-r--r--src/pyramid/paster.py6
-rw-r--r--src/pyramid/path.py6
-rw-r--r--src/pyramid/registry.py6
-rw-r--r--src/pyramid/renderers.py20
-rw-r--r--src/pyramid/request.py4
-rw-r--r--src/pyramid/response.py6
-rw-r--r--src/pyramid/scripting.py6
-rw-r--r--src/pyramid/security.py4
-rw-r--r--src/pyramid/session.py4
-rw-r--r--src/pyramid/settings.py4
-rw-r--r--src/pyramid/static.py5
-rw-r--r--src/pyramid/testing.py12
-rw-r--r--src/pyramid/traversal.py14
-rw-r--r--src/pyramid/tweens.py2
-rw-r--r--src/pyramid/url.py4
-rw-r--r--src/pyramid/util.py18
-rw-r--r--src/pyramid/view.py18
-rw-r--r--src/pyramid/wsgi.py4
-rw-r--r--tests/test_path.py3
-rw-r--r--tests/test_testing.py4
-rw-r--r--tests/test_util.py4
41 files changed, 279 insertions, 286 deletions
diff --git a/src/pyramid/asset.py b/src/pyramid/asset.py
index b657bf68f..f5900f443 100644
--- a/src/pyramid/asset.py
+++ b/src/pyramid/asset.py
@@ -18,9 +18,9 @@ def resolve_asset_spec(spec, pname='__main__'):
def asset_spec_from_abspath(abspath, package):
- """ Try to convert an absolute path to a resource in a package to
+ """Try to convert an absolute path to a resource in a package to
a resource specification if possible; otherwise return the
- absolute path. """
+ absolute path."""
if getattr(package, '__name__', None) == '__main__':
return abspath
pp = package_path(package) + os.path.sep
diff --git a/src/pyramid/authentication.py b/src/pyramid/authentication.py
index 6b5305cf3..96946f427 100644
--- a/src/pyramid/authentication.py
+++ b/src/pyramid/authentication.py
@@ -43,7 +43,7 @@ class CallbackAuthenticationPolicy:
return princid
def authenticated_userid(self, request):
- """ Return the authenticated userid or ``None``.
+ """Return the authenticated userid or ``None``.
If no callback is registered, this will be the same as
``unauthenticated_userid``.
@@ -95,7 +95,7 @@ class CallbackAuthenticationPolicy:
)
def effective_principals(self, request):
- """ A list of effective principals derived from request.
+ """A list of effective principals derived from request.
This will return a list of principals including, at least,
:data:`pyramid.authorization.Everyone`. If there is no authenticated
@@ -179,7 +179,7 @@ class CallbackAuthenticationPolicy:
@implementer(IAuthenticationPolicy)
class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy):
- """ A :app:`Pyramid` :term:`authentication policy` which
+ """A :app:`Pyramid` :term:`authentication policy` which
obtains data from the :mod:`repoze.who` 1.X WSGI 'API' (the
``repoze.who.identity`` key in the WSGI environment).
@@ -218,7 +218,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy):
return identifier
def authenticated_userid(self, request):
- """ Return the authenticated userid or ``None``.
+ """Return the authenticated userid or ``None``.
If no callback is registered, this will be the same as
``unauthenticated_userid``.
@@ -272,7 +272,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy):
return identity['repoze.who.userid']
def effective_principals(self, request):
- """ A list of effective principals derived from the identity.
+ """A list of effective principals derived from the identity.
This will return a list of principals including, at least,
:data:`pyramid.authorization.Everyone`. If there is no identity, or
@@ -345,7 +345,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy):
return effective_principals
def remember(self, request, userid, **kw):
- """ Store the ``userid`` as ``repoze.who.userid``.
+ """Store the ``userid`` as ``repoze.who.userid``.
The identity to authenticated to :mod:`repoze.who`
will contain the given userid as ``userid``, and
@@ -361,7 +361,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy):
return identifier.remember(environ, identity)
def forget(self, request):
- """ Forget the current authenticated user.
+ """Forget the current authenticated user.
Return headers that, if included in a response, will delete the
cookie responsible for tracking the current user.
@@ -376,7 +376,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy):
@implementer(IAuthenticationPolicy)
class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy):
- """ A :app:`Pyramid` :term:`authentication policy` which
+ """A :app:`Pyramid` :term:`authentication policy` which
obtains data from the ``REMOTE_USER`` WSGI environment variable.
Constructor Arguments
@@ -415,13 +415,13 @@ class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy):
return request.environ.get(self.environ_key)
def remember(self, request, userid, **kw):
- """ A no-op. The ``REMOTE_USER`` does not provide a protocol for
+ """A no-op. The ``REMOTE_USER`` does not provide a protocol for
remembering the user. This will be application-specific and can
be done somewhere else or in a subclass."""
return []
def forget(self, request):
- """ A no-op. The ``REMOTE_USER`` does not provide a protocol for
+ """A no-op. The ``REMOTE_USER`` does not provide a protocol for
forgetting the user. This will be application-specific and can
be done somewhere else or in a subclass."""
return []
@@ -637,7 +637,7 @@ class AuthTktAuthenticationPolicy(CallbackAuthenticationPolicy):
return result['userid']
def remember(self, request, userid, **kw):
- """ Accepts the following kw args: ``max_age=<int-seconds>,
+ """Accepts the following kw args: ``max_age=<int-seconds>,
``tokens=<sequence-of-ascii-strings>``.
Return a list of headers which will set appropriate cookies on
@@ -1050,7 +1050,7 @@ class AuthTktCookieHelper:
return headers
def identify(self, request):
- """ Return a dictionary with authentication information, or ``None``
+ """Return a dictionary with authentication information, or ``None``
if no valid auth_tkt is attached to ``request``"""
environ = request.environ
cookie = request.cookies.get(self.cookie_name)
@@ -1118,13 +1118,13 @@ class AuthTktCookieHelper:
return identity
def forget(self, request):
- """ Return a set of expires Set-Cookie headers, which will destroy
+ """Return a set of expires Set-Cookie headers, which will destroy
any existing auth_tkt cookie when attached to a response"""
request._authtkt_reissue_revoked = True
return self._get_cookies(request, None)
def remember(self, request, userid, max_age=None, tokens=()):
- """ Return a set of Set-Cookie headers; when set into a response,
+ """Return a set of Set-Cookie headers; when set into a response,
these headers will represent a valid authentication ticket.
``max_age``
@@ -1204,7 +1204,7 @@ class AuthTktCookieHelper:
@implementer(IAuthenticationPolicy)
class SessionAuthenticationPolicy(CallbackAuthenticationPolicy):
- """ A :app:`Pyramid` authentication policy which gets its data from the
+ """A :app:`Pyramid` authentication policy which gets its data from the
configured :term:`session`. For this authentication policy to work, you
will have to follow the instructions in the :ref:`sessions_chapter` to
configure a :term:`session factory`.
@@ -1251,7 +1251,7 @@ class SessionAuthenticationPolicy(CallbackAuthenticationPolicy):
class SessionAuthenticationHelper:
- """ A helper for use with a :term:`security policy` which stores user data
+ """A helper for use with a :term:`security policy` which stores user data
in the configured :term:`session`.
Constructor Arguments
@@ -1284,7 +1284,7 @@ class SessionAuthenticationHelper:
@implementer(IAuthenticationPolicy)
class BasicAuthAuthenticationPolicy(CallbackAuthenticationPolicy):
- """ A :app:`Pyramid` authentication policy which uses HTTP standard basic
+ """A :app:`Pyramid` authentication policy which uses HTTP standard basic
authentication protocol to authenticate users. To use this policy you will
need to provide a callback which checks the supplied user credentials
against your source of login data.
@@ -1342,14 +1342,14 @@ class BasicAuthAuthenticationPolicy(CallbackAuthenticationPolicy):
return credentials.username
def remember(self, request, userid, **kw):
- """ A no-op. Basic authentication does not provide a protocol for
+ """A no-op. Basic authentication does not provide a protocol for
remembering the user. Credentials are sent on every request.
"""
return []
def forget(self, request):
- """ Returns challenge headers. This should be attached to a response
+ """Returns challenge headers. This should be attached to a response
to indicate that credentials are required."""
return [('WWW-Authenticate', 'Basic realm="%s"' % self.realm)]
@@ -1370,7 +1370,7 @@ HTTPBasicCredentials = namedtuple(
def extract_http_basic_credentials(request):
- """ A helper function for extraction of HTTP Basic credentials
+ """A helper function for extraction of HTTP Basic credentials
from a given :term:`request`.
Returns a :class:`.HTTPBasicCredentials` 2-tuple with ``username`` and
diff --git a/src/pyramid/authorization.py b/src/pyramid/authorization.py
index f9ce9c58a..eadd46f85 100644
--- a/src/pyramid/authorization.py
+++ b/src/pyramid/authorization.py
@@ -48,7 +48,7 @@ DENY_ALL = (Deny, Everyone, ALL_PERMISSIONS) # api
@implementer(IAuthorizationPolicy)
class ACLAuthorizationPolicy:
- """ An :term:`authorization policy` which consults an :term:`ACL`
+ """An :term:`authorization policy` which consults an :term:`ACL`
object attached to a :term:`context` to determine authorization
information about a :term:`principal` or multiple principals.
This class is a wrapper around :class:`.ACLHelper`, refer to that class for
@@ -68,14 +68,14 @@ class ACLAuthorizationPolicy:
self.helper = ACLHelper()
def permits(self, context, principals, permission):
- """ Return an instance of
+ """Return an instance of
:class:`pyramid.authorization.ACLAllowed` instance if the policy
permits access, return an instance of
:class:`pyramid.authorization.ACLDenied` if not."""
return self.helper.permits(context, principals, permission)
def principals_allowed_by_permission(self, context, permission):
- """ Return the set of principals explicitly granted the
+ """Return the set of principals explicitly granted the
permission named ``permission`` according to the ACL directly
attached to the ``context`` as well as inherited ACLs based on
the :term:`lineage`."""
@@ -85,7 +85,7 @@ class ACLAuthorizationPolicy:
class ACLHelper:
- """ A helper for use with constructing a :term:`security policy` which
+ """A helper for use with constructing a :term:`security policy` which
consults an :term:`ACL` object attached to a :term:`context` to determine
authorization information about a :term:`principal` or multiple principals.
If the context is part of a :term:`lineage`, the context's parents are
@@ -94,7 +94,7 @@ class ACLHelper:
"""
def permits(self, context, principals, permission):
- """ Return an instance of :class:`pyramid.authorization.ACLAllowed` if
+ """Return an instance of :class:`pyramid.authorization.ACLAllowed` if
the ACL allows access a user with the given principals, return an
instance of :class:`pyramid.authorization.ACLDenied` if not.
@@ -152,7 +152,7 @@ class ACLHelper:
)
def principals_allowed_by_permission(self, context, permission):
- """ Return the set of principals explicitly granted the permission
+ """Return the set of principals explicitly granted the permission
named ``permission`` according to the ACL directly attached to the
``context`` as well as inherited ACLs based on the :term:`lineage`.
diff --git a/src/pyramid/config/__init__.py b/src/pyramid/config/__init__.py
index 3d05617ca..fa90f2dd2 100644
--- a/src/pyramid/config/__init__.py
+++ b/src/pyramid/config/__init__.py
@@ -334,7 +334,7 @@ class Configurator(
default_view_mapper=None,
exceptionresponse_view=default_exceptionresponse_view,
):
- """ When you pass a non-``None`` ``registry`` argument to the
+ """When you pass a non-``None`` ``registry`` argument to the
:term:`Configurator` constructor, no initial setup is performed
against the registry. This is because the registry you pass in may
have already been initialized for use under :app:`Pyramid` via a
@@ -450,7 +450,7 @@ class Configurator(
return '%s:%s' % (package, filename)
def _fix_registry(self):
- """ Fix up a ZCA component registry that is not a
+ """Fix up a ZCA component registry that is not a
pyramid.registry.Registry by adding analogues of ``has_listeners``,
``notify``, ``queryAdapterOrSelf``, and ``registerSelfAdapter``
through monkey-patching."""
@@ -714,7 +714,7 @@ class Configurator(
return m
def with_package(self, package):
- """ Return a new Configurator instance with the same registry
+ """Return a new Configurator instance with the same registry
as this configurator. ``package`` may be an actual Python package
object or a :term:`dotted Python name` representing a package."""
configurator = self.__class__(
@@ -731,7 +731,7 @@ class Configurator(
return configurator
def maybe_dotted(self, dotted):
- """ Resolve the :term:`dotted Python name` ``dotted`` to a
+ """Resolve the :term:`dotted Python name` ``dotted`` to a
global Python object. If ``dotted`` is not a string, return
it without attempting to do any name resolution. If
``dotted`` is a relative dotted name (e.g. ``.foo.bar``,
@@ -740,7 +740,7 @@ class Configurator(
return self.name_resolver.maybe_resolve(dotted)
def absolute_asset_spec(self, relative_spec):
- """ Resolve the potentially relative :term:`asset
+ """Resolve the potentially relative :term:`asset
specification` string passed as ``relative_spec`` into an
absolute asset specification string and return the string.
Use the ``package`` of this configurator as the package to
@@ -755,7 +755,7 @@ class Configurator(
absolute_resource_spec = absolute_asset_spec # b/w compat forever
def begin(self, request=_marker):
- """ Indicate that application or test configuration has begun.
+ """Indicate that application or test configuration has begun.
This pushes a dictionary containing the :term:`application
registry` implied by ``registry`` attribute of this
configurator and the :term:`request` implied by the
@@ -781,7 +781,7 @@ class Configurator(
self.manager.push({'registry': self.registry, 'request': request})
def end(self):
- """ Indicate that application or test configuration has ended.
+ """Indicate that application or test configuration has ended.
This pops the last value pushed onto the :term:`thread local`
stack (usually by the ``begin`` method) and returns that
value.
@@ -882,7 +882,7 @@ class Configurator(
)
def make_wsgi_app(self):
- """ Commits any pending configuration statements, sends a
+ """Commits any pending configuration statements, sends a
:class:`pyramid.events.ApplicationCreated` event to all listeners,
adds this configuration's registry to
:attr:`pyramid.config.global_registries`, and returns a
diff --git a/src/pyramid/config/actions.py b/src/pyramid/config/actions.py
index b19f35b9b..9559de9ae 100644
--- a/src/pyramid/config/actions.py
+++ b/src/pyramid/config/actions.py
@@ -37,7 +37,7 @@ class ActionConfiguratorMixin:
introspectables=(),
**extra
):
- """ Register an action which will be executed when
+ """Register an action which will be executed when
:meth:`pyramid.config.Configurator.commit` is called (or executed
immediately if ``autocommit`` is ``True``).
@@ -187,8 +187,7 @@ class ActionState:
introspectables=(),
**extra
):
- """Add an action with the given discriminator, callable and arguments
- """
+ """Add an action with the given discriminator, callable and arguments"""
if kw is None:
kw = {}
action = extra
@@ -541,7 +540,7 @@ class ActionInfo:
def action_method(wrapped):
- """ Wrapper to provide the right conflict info report data when a method
+ """Wrapper to provide the right conflict info report data when a method
that calls Configurator.action calls another that does the same. Not a
documented API but used by some external systems."""
diff --git a/src/pyramid/config/adapters.py b/src/pyramid/config/adapters.py
index 5035651cb..a64c251ca 100644
--- a/src/pyramid/config/adapters.py
+++ b/src/pyramid/config/adapters.py
@@ -161,7 +161,7 @@ class AdaptersConfiguratorMixin:
@action_method
def add_response_adapter(self, adapter, type_or_iface):
- """ When an object of type (or interface) ``type_or_iface`` is
+ """When an object of type (or interface) ``type_or_iface`` is
returned from a view callable, Pyramid will use the adapter
``adapter`` to convert it into an object which implements the
:class:`pyramid.interfaces.IResponse` interface. If ``adapter`` is
diff --git a/src/pyramid/config/assets.py b/src/pyramid/config/assets.py
index 0522f8d2d..0dd7cf2c2 100644
--- a/src/pyramid/config/assets.py
+++ b/src/pyramid/config/assets.py
@@ -20,7 +20,7 @@ class OverrideProvider(pkg_resources.DefaultProvider):
return overrides
def get_resource_filename(self, manager, resource_name):
- """ Return a true filesystem path for resource_name,
+ """Return a true filesystem path for resource_name,
co-ordinating the extraction with manager, if the resource
must be unpacked to the filesystem.
"""
@@ -164,23 +164,19 @@ class PackageOverrides:
return self._real_loader
def get_data(self, path):
- """ See IPEP302Loader.
- """
+ """See IPEP302Loader."""
return self.real_loader.get_data(path)
def is_package(self, fullname):
- """ See IPEP302Loader.
- """
+ """See IPEP302Loader."""
return self.real_loader.is_package(fullname)
def get_code(self, fullname):
- """ See IPEP302Loader.
- """
+ """See IPEP302Loader."""
return self.real_loader.get_code(fullname)
def get_source(self, fullname):
- """ See IPEP302Loader.
- """
+ """See IPEP302Loader."""
return self.real_loader.get_source(fullname)
@@ -321,7 +317,7 @@ class AssetsConfiguratorMixin:
@action_method
def override_asset(self, to_override, override_with, _override=None):
- """ Add a :app:`Pyramid` asset override to the current
+ """Add a :app:`Pyramid` asset override to the current
configuration state.
``to_override`` is an :term:`asset specification` to the
diff --git a/src/pyramid/config/factories.py b/src/pyramid/config/factories.py
index 9636d0bad..9e1d3a747 100644
--- a/src/pyramid/config/factories.py
+++ b/src/pyramid/config/factories.py
@@ -18,7 +18,7 @@ from pyramid.util import InstancePropertyHelper, get_callable_name
class FactoriesConfiguratorMixin:
@action_method
def set_root_factory(self, factory):
- """ Add a :term:`root factory` to the current configuration
+ """Add a :term:`root factory` to the current configuration
state. If the ``factory`` argument is ``None`` a default root
factory will be registered.
@@ -76,7 +76,7 @@ class FactoriesConfiguratorMixin:
@action_method
def set_request_factory(self, factory):
- """ The object passed as ``factory`` should be an object (or a
+ """The object passed as ``factory`` should be an object (or a
:term:`dotted Python name` which refers to an object) which
will be used by the :app:`Pyramid` router to create all
request objects. This factory object must have the same
@@ -110,7 +110,7 @@ class FactoriesConfiguratorMixin:
@action_method
def set_response_factory(self, factory):
- """ The object passed as ``factory`` should be an object (or a
+ """The object passed as ``factory`` should be an object (or a
:term:`dotted Python name` which refers to an object) which
will be used by the :app:`Pyramid` as the default response
objects. The factory should conform to the
@@ -140,7 +140,7 @@ class FactoriesConfiguratorMixin:
def add_request_method(
self, callable=None, name=None, property=False, reify=False
):
- """ Add a property or method to the request object.
+ """Add a property or method to the request object.
When adding a method to the request, ``callable`` may be any
function that receives the request object as the first
diff --git a/src/pyramid/config/i18n.py b/src/pyramid/config/i18n.py
index f4bea0d71..d70a8f25a 100644
--- a/src/pyramid/config/i18n.py
+++ b/src/pyramid/config/i18n.py
@@ -45,7 +45,7 @@ class I18NConfiguratorMixin:
@action_method
def add_translation_dirs(self, *specs, **kw):
- """ Add one or more :term:`translation directory` paths to the
+ """Add one or more :term:`translation directory` paths to the
current configuration state. The ``specs`` argument is a
sequence that may contain absolute directory paths
(e.g. ``/usr/share/locale``) or :term:`asset specification`
diff --git a/src/pyramid/config/routes.py b/src/pyramid/config/routes.py
index 4f3440c40..4ebae89cc 100644
--- a/src/pyramid/config/routes.py
+++ b/src/pyramid/config/routes.py
@@ -40,7 +40,7 @@ class RoutesConfiguratorMixin:
inherit_slash=None,
**predicates
):
- """ Add a :term:`route configuration` to the current configuration
+ """Add a :term:`route configuration` to the current configuration
state. Arguments to ``add_route`` are divided into *predicate*
and *non-predicate* types. :term:`Route predicate` arguments
narrow the circumstances in which a route will match a
@@ -517,7 +517,7 @@ class RoutesConfiguratorMixin:
def add_route_predicate(
self, name, factory, weighs_more_than=None, weighs_less_than=None
):
- """ Adds a route predicate factory. The view predicate can later be
+ """Adds a route predicate factory. The view predicate can later be
named as a keyword argument to
:meth:`pyramid.config.Configurator.add_route`.
@@ -557,7 +557,7 @@ class RoutesConfiguratorMixin:
self.add_route_predicate(name, factory)
def get_routes_mapper(self):
- """ Return the :term:`routes mapper` object associated with
+ """Return the :term:`routes mapper` object associated with
this configurator's :term:`registry`."""
mapper = self.registry.queryUtility(IRoutesMapper)
if mapper is None:
diff --git a/src/pyramid/config/security.py b/src/pyramid/config/security.py
index a661bef96..8939cf62e 100644
--- a/src/pyramid/config/security.py
+++ b/src/pyramid/config/security.py
@@ -24,7 +24,7 @@ class SecurityConfiguratorMixin:
@action_method
def set_security_policy(self, policy):
- """ Override the :app:`Pyramid` :term:`security policy` in the current
+ """Override the :app:`Pyramid` :term:`security policy` in the current
configuration. The ``policy`` argument must be an instance
of a security policy or a :term:`dotted Python name`
that points at an instance of a security policy.
diff --git a/src/pyramid/config/settings.py b/src/pyramid/config/settings.py
index 076c455d4..3ed0bbccd 100644
--- a/src/pyramid/config/settings.py
+++ b/src/pyramid/config/settings.py
@@ -46,12 +46,12 @@ class SettingsConfiguratorMixin:
.. note:: the :attr:`pyramid.registry.Registry.settings` API
performs the same duty.
- """
+ """
return self.registry.settings
def Settings(d=None, _environ_=os.environ, **kw):
- """ Deployment settings. Update application settings (usually
+ """Deployment settings. Update application settings (usually
from PasteDeploy keywords) with framework-specific key/value pairs
(e.g. find ``PYRAMID_DEBUG_AUTHORIZATION`` in os.environ and jam into
keyword args)."""
diff --git a/src/pyramid/config/views.py b/src/pyramid/config/views.py
index 26b69beb9..0d0002f83 100644
--- a/src/pyramid/config/views.py
+++ b/src/pyramid/config/views.py
@@ -204,7 +204,7 @@ def predicated_view(view, info):
def viewdefaults(wrapped):
- """ Decorator for add_view-like methods which takes into account
+ """Decorator for add_view-like methods which takes into account
__view_defaults__ attached to view it is passed. Not a documented API but
used by some external systems."""
@@ -266,7 +266,7 @@ class ViewsConfiguratorMixin:
exception_only=False,
**view_options
):
- """ Add a :term:`view configuration` to the current
+ """Add a :term:`view configuration` to the current
configuration state. Arguments to ``add_view`` are broken
down below into *predicate* arguments and *non-predicate*
arguments. Predicate arguments narrow the circumstances in
@@ -1518,7 +1518,7 @@ class ViewsConfiguratorMixin:
a :term:`renderer` to convert the user-supplied view result to
a :term:`response` object. If a ``renderer`` argument is not
supplied, the user-supplied view must itself return a
- :term:`response` object. """
+ :term:`response` object."""
return self._derive_view(view, attr=attr, renderer=renderer)
# b/w compat
@@ -1613,7 +1613,7 @@ class ViewsConfiguratorMixin:
match_param=None,
**view_options
):
- """ Add a forbidden view to the current configuration state. The
+ """Add a forbidden view to the current configuration state. The
view will be called when Pyramid or application code raises a
:exc:`pyramid.httpexceptions.HTTPForbidden` exception and the set of
circumstances implied by the predicates provided are matched. The
@@ -1714,7 +1714,7 @@ class ViewsConfiguratorMixin:
append_slash=False,
**view_options
):
- """ Add a default :term:`Not Found View` to the current configuration
+ """Add a default :term:`Not Found View` to the current configuration
state. The view will be called when Pyramid or application code raises
an :exc:`pyramid.httpexceptions.HTTPNotFound` exception (e.g., when a
view cannot be found for the request). The simplest example is:
@@ -1852,7 +1852,7 @@ class ViewsConfiguratorMixin:
# force all other arguments to be specified as key=value
**view_options
):
- """ Add an :term:`exception view` for the specified ``exception`` to
+ """Add an :term:`exception view` for the specified ``exception`` to
the current configuration state. The view will be called when Pyramid
or application code raises the given exception.
@@ -1938,7 +1938,7 @@ class ViewsConfiguratorMixin:
@action_method
def add_static_view(self, name, path, **kw):
- """ Add a view used to render static assets such as images
+ """Add a view used to render static assets such as images
and CSS files.
The ``name`` argument is a string representing an
diff --git a/src/pyramid/config/zca.py b/src/pyramid/config/zca.py
index 69b65a8eb..aec38b885 100644
--- a/src/pyramid/config/zca.py
+++ b/src/pyramid/config/zca.py
@@ -3,7 +3,7 @@ from pyramid.threadlocal import get_current_registry
class ZCAConfiguratorMixin:
def hook_zca(self):
- """ Call :func:`zope.component.getSiteManager.sethook` with the
+ """Call :func:`zope.component.getSiteManager.sethook` with the
argument :data:`pyramid.threadlocal.get_current_registry`, causing
the :term:`Zope Component Architecture` 'global' APIs such as
:func:`zope.component.getSiteManager`,
@@ -15,7 +15,7 @@ class ZCAConfiguratorMixin:
getSiteManager.sethook(get_current_registry)
def unhook_zca(self):
- """ Call :func:`zope.component.getSiteManager.reset` to undo the
+ """Call :func:`zope.component.getSiteManager.reset` to undo the
action of :meth:`pyramid.config.Configurator.hook_zca`."""
from zope.component import getSiteManager
diff --git a/src/pyramid/csrf.py b/src/pyramid/csrf.py
index 4c3689714..7f4f72f44 100644
--- a/src/pyramid/csrf.py
+++ b/src/pyramid/csrf.py
@@ -17,7 +17,7 @@ from pyramid.util import (
@implementer(ICSRFStoragePolicy)
class LegacySessionCSRFStoragePolicy:
- """ A CSRF storage policy that defers control of CSRF storage to the
+ """A CSRF storage policy that defers control of CSRF storage to the
session.
This policy maintains compatibility with legacy ISession implementations
@@ -36,7 +36,7 @@ class LegacySessionCSRFStoragePolicy:
return request.session.new_csrf_token()
def get_csrf_token(self, request):
- """ Returns the currently active CSRF token from the session,
+ """Returns the currently active CSRF token from the session,
generating a new one if needed."""
return request.session.get_csrf_token()
@@ -50,7 +50,7 @@ class LegacySessionCSRFStoragePolicy:
@implementer(ICSRFStoragePolicy)
class SessionCSRFStoragePolicy:
- """ A CSRF storage policy that persists the CSRF token in the session.
+ """A CSRF storage policy that persists the CSRF token in the session.
Note that using this CSRF implementation requires that
a :term:`session factory` is configured.
@@ -76,7 +76,7 @@ class SessionCSRFStoragePolicy:
return token
def get_csrf_token(self, request):
- """ Returns the currently active CSRF token from the session,
+ """Returns the currently active CSRF token from the session,
generating a new one if needed."""
token = request.session.get(self.key, None)
if not token:
@@ -93,7 +93,7 @@ class SessionCSRFStoragePolicy:
@implementer(ICSRFStoragePolicy)
class CookieCSRFStoragePolicy:
- """ An alternative CSRF implementation that stores its information in
+ """An alternative CSRF implementation that stores its information in
unauthenticated cookies, known as the 'Double Submit Cookie' method in the
`OWASP CSRF guidelines
<https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie>`_.
@@ -145,7 +145,7 @@ class CookieCSRFStoragePolicy:
return token
def get_csrf_token(self, request):
- """ Returns the currently active CSRF token by checking the cookies
+ """Returns the currently active CSRF token by checking the cookies
sent with the current request."""
bound_cookies = self.cookie_profile.bind(request)
token = bound_cookies.get_value()
@@ -162,7 +162,7 @@ class CookieCSRFStoragePolicy:
def get_csrf_token(request):
- """ Get the currently active CSRF token for the request passed, generating
+ """Get the currently active CSRF token for the request passed, generating
a new one using ``new_csrf_token(request)`` if one does not exist. This
calls the equivalent method in the chosen CSRF protection implementation.
@@ -175,7 +175,7 @@ def get_csrf_token(request):
def new_csrf_token(request):
- """ Generate a new CSRF token for the request passed and persist it in an
+ """Generate a new CSRF token for the request passed and persist it in an
implementation defined manner. This calls the equivalent method in the
chosen CSRF protection implementation.
@@ -190,7 +190,7 @@ def new_csrf_token(request):
def check_csrf_token(
request, token='csrf_token', header='X-CSRF-Token', raises=True
):
- """ Check the CSRF token returned by the
+ """Check the CSRF token returned by the
:class:`pyramid.interfaces.ICSRFStoragePolicy` implementation against the
value in ``request.POST.get(token)`` (if a POST request) or
``request.headers.get(header)``. If a ``token`` keyword is not supplied to
diff --git a/src/pyramid/decorator.py b/src/pyramid/decorator.py
index 82579182a..56c74c5b6 100644
--- a/src/pyramid/decorator.py
+++ b/src/pyramid/decorator.py
@@ -2,7 +2,7 @@ from functools import update_wrapper
class reify:
- """ Use as a class method decorator. It operates almost exactly like the
+ """Use as a class method decorator. It operates almost exactly like the
Python ``@property`` decorator, but it puts the result of the method it
decorates into the instance dict after the first call, effectively
replacing the function it decorates with an instance variable. It is, in
diff --git a/src/pyramid/events.py b/src/pyramid/events.py
index 86e7c3454..648f5ce98 100644
--- a/src/pyramid/events.py
+++ b/src/pyramid/events.py
@@ -12,7 +12,7 @@ from pyramid.interfaces import (
class subscriber:
- """ Decorator activated via a :term:`scan` which treats the function
+ """Decorator activated via a :term:`scan` which treats the function
being decorated as an event subscriber for the set of interfaces passed
as ``*ifaces`` and the set of predicate terms passed as ``**predicates``
to the decorator constructor.
@@ -112,7 +112,7 @@ class subscriber:
@implementer(INewRequest)
class NewRequest:
- """ An instance of this class is emitted as an :term:`event`
+ """An instance of this class is emitted as an :term:`event`
whenever :app:`Pyramid` begins to process a new request. The
event instance has an attribute, ``request``, which is a
:term:`request` object. This event class implements the
@@ -124,7 +124,7 @@ class NewRequest:
@implementer(INewResponse)
class NewResponse:
- """ An instance of this class is emitted as an :term:`event`
+ """An instance of this class is emitted as an :term:`event`
whenever any :app:`Pyramid` :term:`view` or :term:`exception
view` returns a :term:`response`.
@@ -183,7 +183,7 @@ class BeforeTraversal:
@implementer(IContextFound)
class ContextFound:
- """ An instance of this class is emitted as an :term:`event` after
+ """An instance of this class is emitted as an :term:`event` after
the :app:`Pyramid` :term:`router` finds a :term:`context`
object (after it performs traversal) but before any view code is
executed. The instance has an attribute, ``request``, which is
@@ -212,7 +212,7 @@ AfterTraversal = ContextFound # b/c as of 1.0
@implementer(IApplicationCreated)
class ApplicationCreated:
- """ An instance of this class is emitted as an :term:`event` when
+ """An instance of this class is emitted as an :term:`event` when
the :meth:`pyramid.config.Configurator.make_wsgi_app` is
called. The instance has an attribute, ``app``, which is an
instance of the :term:`router` that will handle WSGI requests.
diff --git a/src/pyramid/exceptions.py b/src/pyramid/exceptions.py
index 122209d48..a82463498 100644
--- a/src/pyramid/exceptions.py
+++ b/src/pyramid/exceptions.py
@@ -77,12 +77,12 @@ class URLDecodeError(UnicodeDecodeError):
class ConfigurationError(Exception):
- """ Raised when inappropriate input values are supplied to an API
+ """Raised when inappropriate input values are supplied to an API
method of a :term:`Configurator`"""
class ConfigurationConflictError(ConfigurationError):
- """ Raised when a configuration conflict is detected during action
+ """Raised when a configuration conflict is detected during action
processing"""
def __init__(self, conflicts):
@@ -100,8 +100,7 @@ class ConfigurationConflictError(ConfigurationError):
class ConfigurationExecutionError(ConfigurationError):
- """An error occurred during execution of a configuration action
- """
+ """An error occurred during execution of a configuration action"""
def __init__(self, etype, evalue, info):
self.etype, self.evalue, self.info = etype, evalue, info
@@ -111,7 +110,7 @@ class ConfigurationExecutionError(ConfigurationError):
class CyclicDependencyError(Exception):
- """ The exception raised when the Pyramid topological sorter detects a
+ """The exception raised when the Pyramid topological sorter detects a
cyclic dependency."""
def __init__(self, cycles):
diff --git a/src/pyramid/i18n.py b/src/pyramid/i18n.py
index 8bf091c58..29ab395ef 100644
--- a/src/pyramid/i18n.py
+++ b/src/pyramid/i18n.py
@@ -112,7 +112,7 @@ class Localizer:
def default_locale_negotiator(request):
- """ The default :term:`locale negotiator`. Returns a locale name
+ """The default :term:`locale negotiator`. Returns a locale name
or ``None``.
- First, the negotiator looks for the ``_LOCALE_`` attribute of
@@ -139,7 +139,7 @@ def default_locale_negotiator(request):
def negotiate_locale_name(request):
- """ Negotiate and return the :term:`locale name` associated with
+ """Negotiate and return the :term:`locale name` associated with
the current request."""
try:
registry = request.registry
@@ -167,7 +167,7 @@ def get_locale_name(request):
def make_localizer(current_locale_name, translation_directories):
- """ Create a :class:`pyramid.i18n.Localizer` object
+ """Create a :class:`pyramid.i18n.Localizer` object
corresponding to the provided locale name from the
translations found in the list of translation directories."""
translations = Translations()
diff --git a/src/pyramid/interfaces.py b/src/pyramid/interfaces.py
index b8c8d06a9..ffac7f641 100644
--- a/src/pyramid/interfaces.py
+++ b/src/pyramid/interfaces.py
@@ -4,7 +4,7 @@ from zope.interface import Attribute, Interface
class IContextFound(Interface):
- """ An event type that is emitted after :app:`Pyramid` finds a
+ """An event type that is emitted after :app:`Pyramid` finds a
:term:`context` object but before it calls any view code. See the
documentation attached to :class:`pyramid.events.ContextFound`
for more information.
@@ -33,7 +33,7 @@ class IBeforeTraversal(Interface):
class INewRequest(Interface):
- """ An event type that is emitted whenever :app:`Pyramid`
+ """An event type that is emitted whenever :app:`Pyramid`
begins to process a new request. See the documentation attached
to :class:`pyramid.events.NewRequest` for more information."""
@@ -41,7 +41,7 @@ class INewRequest(Interface):
class INewResponse(Interface):
- """ An event type that is emitted whenever any :app:`Pyramid`
+ """An event type that is emitted whenever any :app:`Pyramid`
view returns a response. See the
documentation attached to :class:`pyramid.events.NewResponse`
for more information."""
@@ -51,7 +51,7 @@ class INewResponse(Interface):
class IApplicationCreated(Interface):
- """ Event issued when the
+ """Event issued when the
:meth:`pyramid.config.Configurator.make_wsgi_app` method
is called. See the documentation attached to
:class:`pyramid.events.ApplicationCreated` for more
@@ -71,7 +71,7 @@ IWSGIApplicationCreatedEvent = IApplicationCreated # b /c
class IResponse(Interface):
- """ Represents a WSGI response using the WebOb response interface.
+ """Represents a WSGI response using the WebOb response interface.
Some attribute and method documentation of this interface references
:rfc:`2616`.
@@ -84,7 +84,7 @@ class IResponse(Interface):
)
def __call__(environ, start_response):
- """ :term:`WSGI` call interface, should call the start_response
+ """:term:`WSGI` call interface, should call the start_response
callback and should return an iterable"""
accept_ranges = Attribute(
@@ -110,8 +110,8 @@ class IResponse(Interface):
)
def app_iter_range(start, stop):
- """ Return a new app_iter built from the response app_iter that
- serves up only the given start:stop range. """
+ """Return a new app_iter built from the response app_iter that
+ serves up only the given start:stop range."""
authenticated_identity = Attribute(
"""An object representing the authenticated user, as determined by
@@ -145,7 +145,7 @@ class IResponse(Interface):
charset = Attribute("""Get/set the charset (in the Content-Type)""")
def conditional_response_app(environ, start_response):
- """ Like the normal __call__ interface, but checks conditional
+ """Like the normal __call__ interface, but checks conditional
headers:
- If-Modified-Since (304 Not Modified; only on GET, HEAD)
@@ -215,12 +215,12 @@ class IResponse(Interface):
)
def delete_cookie(name, path='/', domain=None):
- """ Delete a cookie from the client. Note that path and domain must
+ """Delete a cookie from the client. Note that path and domain must
match how the cookie was originally set. This sets the cookie to the
- empty string, and max_age=0 so that it should expire immediately. """
+ empty string, and max_age=0 so that it should expire immediately."""
def encode_content(encoding='gzip', lazy=False):
- """ Encode the content with the given encoding (only gzip and
+ """Encode the content with the given encoding (only gzip and
identity are supported)."""
environ = Attribute(
@@ -260,15 +260,15 @@ class IResponse(Interface):
)
def md5_etag(body=None, set_content_md5=False):
- """ Generate an etag for the response object using an MD5 hash of the
+ """Generate an etag for the response object using an MD5 hash of the
body (the body parameter, or self.body if not given). Sets self.etag.
- If set_content_md5 is True sets self.content_md5 as well """
+ If set_content_md5 is True sets self.content_md5 as well"""
def merge_cookies(resp):
- """ Merge the cookies that were set on this response with the given
+ """Merge the cookies that were set on this response with the given
resp object (which can be any WSGI application). If the resp is a
webob.Response object, then the other object will be modified
- in-place. """
+ in-place."""
pragma = Attribute(
""" Gets and sets and deletes the Pragma header. For more information
@@ -314,7 +314,7 @@ class IResponse(Interface):
)
def unset_cookie(name, strict=True):
- """ Unset a cookie with the given name (remove it from the
+ """Unset a cookie with the given name (remove it from the
response)."""
vary = Attribute(
@@ -334,7 +334,7 @@ class IException(Interface): # not an API
class IExceptionResponse(IException, IResponse):
- """ An interface representing a WSGI response which is also an exception
+ """An interface representing a WSGI response which is also an exception
object. Register an exception view using this interface as a ``context``
to apply the registered view for all exception types raised by
:app:`Pyramid` internally (any exception that inherits from
@@ -356,18 +356,18 @@ class IDict(Interface):
""" Set a key/value pair into the dictionary"""
def __delitem__(k):
- """ Delete an item from the dictionary which is passed to the
+ """Delete an item from the dictionary which is passed to the
renderer as the renderer globals dictionary."""
def __getitem__(k):
- """ Return the value for key ``k`` from the dictionary or raise a
+ """Return the value for key ``k`` from the dictionary or raise a
KeyError if the key doesn't exist"""
def __iter__():
""" Return an iterator over the keys of this dictionary """
def get(k, default=None):
- """ Return the value for key ``k`` from the renderer dictionary, or
+ """Return the value for key ``k`` from the renderer dictionary, or
the default if no such value exists."""
def items():
@@ -380,20 +380,20 @@ class IDict(Interface):
""" Return a list of values from the dictionary """
def pop(k, default=None):
- """ Pop the key k from the dictionary and return its value. If k
+ """Pop the key k from the dictionary and return its value. If k
doesn't exist, and default is provided, return the default. If k
doesn't exist and default is not provided, raise a KeyError."""
def popitem():
- """ Pop the item with key k from the dictionary and return it as a
+ """Pop the item with key k from the dictionary and return it as a
two-tuple (k, v). If k doesn't exist, raise a KeyError."""
def setdefault(k, default=None):
- """ Return the existing value for key ``k`` in the dictionary. If no
- value with ``k`` exists in the dictionary, set the ``default``
- value into the dictionary under the k name passed. If a value already
- existed in the dictionary, return it. If a value did not exist in
- the dictionary, return the default"""
+ """Return the existing value for key ``k`` in the dictionary. If no
+ value with ``k`` exists in the dictionary, set the ``default``
+ value into the dictionary under the k name passed. If a value already
+ existed in the dictionary, return it. If a value did not exist in
+ the dictionary, return the default"""
def update(d):
""" Update the renderer dictionary with another dictionary ``d``."""
@@ -430,7 +430,7 @@ class IBeforeRender(IDict):
class IRendererInfo(Interface):
- """ An object implementing this interface is passed to every
+ """An object implementing this interface is passed to every
:term:`renderer factory` constructor as its only argument (conventionally
named ``info``)"""
@@ -454,7 +454,7 @@ class IRendererInfo(Interface):
class IRendererFactory(Interface):
def __call__(info):
- """ Return an object that implements
+ """Return an object that implements
:class:`pyramid.interfaces.IRenderer`. ``info`` is an
object that implements :class:`pyramid.interfaces.IRendererInfo`.
"""
@@ -462,7 +462,7 @@ class IRendererFactory(Interface):
class IRenderer(Interface):
def __call__(value, system):
- """ Call the renderer with the result of the
+ """Call the renderer with the result of the
view (``value``) passed in and return a result (a string or
unicode object useful as a response body). Values computed by
the system are passed by the system in the ``system``
@@ -476,7 +476,7 @@ class IRenderer(Interface):
class IViewMapper(Interface):
def __call__(self, object):
- """ Provided with an arbitrary object (a function, class, or
+ """Provided with an arbitrary object (a function, class, or
instance), returns a callable with the call signature ``(context,
request)``. The callable returned should itself return a Response
object. An IViewMapper is returned by
@@ -499,38 +499,38 @@ class IViewMapperFactory(Interface):
class ISecurityPolicy(Interface):
def authenticated_identity(request):
- """ Return the :term:`identity` of the current user. The object can be
+ """Return the :term:`identity` of the current user. The object can be
of any shape, such as a simple ID string or an ORM object.
"""
def authenticated_userid(request):
- """ Return a :term:`userid` string identifying the trusted and
+ """Return a :term:`userid` string identifying the trusted and
verified user, or ``None`` if unauthenticated.
"""
def permits(request, context, permission):
- """ Return an instance of :class:`pyramid.security.Allowed` if a user
+ """Return an instance of :class:`pyramid.security.Allowed` if a user
of the given identity is allowed the ``permission`` in the current
``context``, else return an instance of
:class:`pyramid.security.Denied`.
"""
def remember(request, userid, **kw):
- """ Return a set of headers suitable for 'remembering' the
+ """Return a set of headers suitable for 'remembering' the
:term:`userid` named ``userid`` when set in a response. An individual
security policy and its consumers can decide on the composition and
meaning of ``**kw``.
"""
def forget(request, **kw):
- """ Return a set of headers suitable for 'forgetting' the
+ """Return a set of headers suitable for 'forgetting' the
current user on subsequent requests. An individual security policy and
its consumers can decide on the composition and meaning of ``**kw``.
"""
class IAuthenticationPolicy(Interface):
- """ An object representing a Pyramid authentication policy.
+ """An object representing a Pyramid authentication policy.
.. deprecated:: 2.0
@@ -540,7 +540,7 @@ class IAuthenticationPolicy(Interface):
"""
def authenticated_userid(request):
- """ Return the authenticated :term:`userid` or ``None`` if
+ """Return the authenticated :term:`userid` or ``None`` if
no authenticated userid can be found. This method of the
policy should ensure that a record exists in whatever
persistent store is used related to the user (the user
@@ -551,7 +551,7 @@ class IAuthenticationPolicy(Interface):
"""
def unauthenticated_userid(request):
- """ Return the *unauthenticated* userid. This method
+ """Return the *unauthenticated* userid. This method
performs the same duty as ``authenticated_userid`` but is
permitted to return the userid based only on data present
in the request; it needn't (and shouldn't) check any
@@ -566,7 +566,7 @@ class IAuthenticationPolicy(Interface):
"""
def effective_principals(request):
- """ Return a sequence representing the effective principals
+ """Return a sequence representing the effective principals
typically including the :term:`userid` and any groups belonged
to by the current user, always including 'system' groups such
as ``pyramid.authorization.Everyone`` and
@@ -575,7 +575,7 @@ class IAuthenticationPolicy(Interface):
"""
def remember(request, userid, **kw):
- """ Return a set of headers suitable for 'remembering' the
+ """Return a set of headers suitable for 'remembering' the
:term:`userid` named ``userid`` when set in a response. An
individual authentication policy and its consumers can
decide on the composition and meaning of ``**kw``.
@@ -583,14 +583,14 @@ class IAuthenticationPolicy(Interface):
"""
def forget(request):
- """ Return a set of headers suitable for 'forgetting' the
+ """Return a set of headers suitable for 'forgetting' the
current user on subsequent requests.
"""
class IAuthorizationPolicy(Interface):
- """ An object representing a Pyramid authorization policy.
+ """An object representing a Pyramid authorization policy.
.. deprecated:: 2.0
@@ -600,14 +600,14 @@ class IAuthorizationPolicy(Interface):
"""
def permits(context, principals, permission):
- """ Return an instance of :class:`pyramid.security.Allowed` if any
+ """Return an instance of :class:`pyramid.security.Allowed` if any
of the ``principals`` is allowed the ``permission`` in the current
``context``, else return an instance of
:class:`pyramid.security.Denied`.
"""
def principals_allowed_by_permission(context, permission):
- """ Return a set of principal identifiers allowed by the
+ """Return a set of principal identifiers allowed by the
``permission`` in ``context``. This behavior is optional; if you
choose to not implement it you should define this method as
something which raises a ``NotImplementedError``. This method
@@ -635,24 +635,24 @@ class IMultiDict(IDict): # docs-only interface
"""
def extend(other=None, **kwargs):
- """ Add a set of keys and values, not overwriting any previous
+ """Add a set of keys and values, not overwriting any previous
values. The ``other`` structure may be a list of two-tuples or a
dictionary. If ``**kwargs`` is passed, its value *will* overwrite
existing values."""
def getall(key):
- """ Return a list of all values matching the key (may be an empty
- list) """
+ """Return a list of all values matching the key (may be an empty
+ list)"""
def getone(key):
- """ Get one value matching the key, raising a KeyError if multiple
- values were found. """
+ """Get one value matching the key, raising a KeyError if multiple
+ values were found."""
def mixed():
- """ Returns a dictionary where the values are either single values,
+ """Returns a dictionary where the values are either single values,
or a list of values when a key/value appears more than once in this
dictionary. This is similar to the kind of dictionary often used to
- represent the variables in a web request. """
+ represent the variables in a web request."""
# internal interfaces
@@ -663,7 +663,7 @@ class IRequest(Interface):
class ITweens(Interface):
- """ Marker interface for utility registration representing the ordered
+ """Marker interface for utility registration representing the ordered
set of a configuration's tween factories"""
@@ -671,7 +671,7 @@ class IRequestHandler(Interface):
""" """
def __call__(self, request):
- """ Must return a tuple of IReqest, IResponse or raise an exception.
+ """Must return a tuple of IReqest, IResponse or raise an exception.
The ``request`` argument will be an instance of an object that
provides IRequest."""
@@ -680,7 +680,7 @@ IRequest.combined = IRequest # for exception view lookups
class IRequestExtensions(Interface):
- """ Marker interface for storing request extensions (properties and
+ """Marker interface for storing request extensions (properties and
methods) which will be added to the request object."""
descriptors = Attribute(
@@ -690,7 +690,7 @@ class IRequestExtensions(Interface):
class IRouteRequest(Interface):
- """ *internal only* interface used as in a utility lookup to find
+ """*internal only* interface used as in a utility lookup to find
route-specific interfaces. Not an API."""
@@ -719,7 +719,7 @@ class IResponseFactory(Interface):
""" A utility which generates a response """
def __call__(request):
- """ Return a response object implementing IResponse,
+ """Return a response object implementing IResponse,
e.g. :class:`pyramid.response.Response`). It should handle the
case when ``request`` is ``None``."""
@@ -731,7 +731,7 @@ class IRequestFactory(Interface):
""" Return an instance of ``pyramid.request.Request``"""
def blank(path):
- """ Return an empty request object (see
+ """Return an empty request object (see
:meth:`pyramid.request.Request.blank`)"""
@@ -755,12 +755,12 @@ class ISecuredView(IView):
""" Guaranteed-permissive version of __call__ """
def __permitted__(context, request):
- """ Return True if view execution will be permitted using the
+ """Return True if view execution will be permitted using the
context and request, False otherwise"""
class IMultiView(ISecuredView):
- """ *internal only*. A multiview is a secured view that is a
+ """*internal only*. A multiview is a secured view that is a
collection of other views. Each of the views is associated with
zero or more predicates. Not an API."""
@@ -780,7 +780,7 @@ class IDefaultRootFactory(Interface):
class ITraverser(Interface):
def __call__(request):
- """ Return a dictionary with (at least) the keys ``root``,
+ """Return a dictionary with (at least) the keys ``root``,
``context``, ``view_name``, ``subpath``, ``traversed``,
``virtual_root``, and ``virtual_root_path``. These values are
typically the result of an object graph traversal. ``root`` is the
@@ -808,8 +808,7 @@ ITraverserFactory = ITraverser # b / c for 1.0 code
class IViewPermission(Interface):
def __call__(context, request):
- """ Return True if the permission allows, return False if it denies.
- """
+ """Return True if the permission allows, return False if it denies."""
class IRouter(Interface):
@@ -894,7 +893,7 @@ class IExecutionPolicy(Interface):
class ISettings(IDict):
- """ Runtime settings utility for pyramid; represents the
+ """Runtime settings utility for pyramid; represents the
deployment settings for the application. Implements a mapping
interface."""
@@ -918,7 +917,7 @@ ILogger = IDebugLogger # b/c
class IRoutePregenerator(Interface):
def __call__(request, elements, kw):
- """ A pregenerator is a function associated by a developer with a
+ """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
of arguments passed to it by the user for special purposes, such as
@@ -942,7 +941,7 @@ class IRoutePregenerator(Interface):
class IRoute(Interface):
- """ Interface representing the type of object returned from
+ """Interface representing the type of object returned from
``IRoutesMapper.get_route``"""
name = Attribute('The route name')
@@ -985,14 +984,14 @@ class IRoutesMapper(Interface):
""" Interface representing a Routes ``Mapper`` object """
def get_routes():
- """ Return a sequence of Route objects registered in the mapper.
+ """Return a sequence of Route objects registered in the mapper.
Static routes will not be returned in this sequence."""
def has_routes():
""" Returns ``True`` if any route has been registered. """
def get_route(name):
- """ Returns an ``IRoute`` object if a route with the name ``name``
+ """Returns an ``IRoute`` object if a route with the name ``name``
was registered, otherwise return ``None``."""
def connect(
@@ -1006,15 +1005,15 @@ class IRoutesMapper(Interface):
""" Add a new route. """
def generate(name, kw):
- """ Generate a URL using the route named ``name`` with the
+ """Generate a URL using the route named ``name`` with the
keywords implied by kw"""
def __call__(request):
- """ Return a dictionary containing matching information for
+ """Return a dictionary containing matching information for
the request; the ``route`` key of this dictionary will either
be a Route object or ``None`` if no route matched; the
``match`` key will be the matchdict or ``None`` if no route
- matched. Static routes will not be considered for matching. """
+ matched. Static routes will not be considered for matching."""
class IResourceURL(Interface):
@@ -1033,11 +1032,10 @@ class IResourceURL(Interface):
class IPEP302Loader(Interface):
- """ See http://www.python.org/dev/peps/pep-0302/#id30.
- """
+ """See http://www.python.org/dev/peps/pep-0302/#id30."""
def get_data(path):
- """ Retrieve data for and arbitrary "files" from storage backend.
+ """Retrieve data for and arbitrary "files" from storage backend.
Raise IOError for not found.
@@ -1045,11 +1043,10 @@ class IPEP302Loader(Interface):
"""
def is_package(fullname):
- """ Return True if the module specified by 'fullname' is a package.
- """
+ """Return True if the module specified by 'fullname' is a package."""
def get_code(fullname):
- """ Return the code object for the module identified by 'fullname'.
+ """Return the code object for the module identified by 'fullname'.
Return 'None' if it's a built-in or extension module.
@@ -1060,7 +1057,7 @@ class IPEP302Loader(Interface):
"""
def get_source(fullname):
- """ Return the source code for the module identified by 'fullname'.
+ """Return the source code for the module identified by 'fullname'.
Return a string, using newline characters for line endings, or None
if the source is not available.
@@ -1069,7 +1066,7 @@ class IPEP302Loader(Interface):
"""
def get_filename(fullname):
- """ Return the value of '__file__' if the named module was loaded.
+ """Return the value of '__file__' if the named module was loaded.
If the module is not found, raise ImportError.
"""
@@ -1094,18 +1091,18 @@ class ILocaleNegotiator(Interface):
class ITranslationDirectories(Interface):
- """ A list object representing all known translation directories
+ """A list object representing all known translation directories
for an application"""
class IDefaultPermission(Interface):
- """ A string object representing the default permission to be used
+ """A string object representing the default permission to be used
for all view configurations which do not explicitly declare their
own."""
class IDefaultCSRFOptions(Interface):
- """ An object representing the default CSRF settings to be used for
+ """An object representing the default CSRF settings to be used for
all view configurations which do not explicitly declare their own."""
require_csrf = Attribute(
@@ -1123,15 +1120,15 @@ class IDefaultCSRFOptions(Interface):
class ISessionFactory(Interface):
- """ An interface representing a factory which accepts a request object and
- returns an ISession object """
+ """An interface representing a factory which accepts a request object and
+ returns an ISession object"""
def __call__(request):
""" Return an ISession object """
class ISession(IDict):
- """ An interface representing a session (a web session object,
+ """An interface representing a session (a web session object,
usually accessed via ``request.session``.
Keys and values of a session must be JSON-serializable.
@@ -1166,7 +1163,7 @@ class ISession(IDict):
# special methods
def invalidate():
- """ Invalidate the session. The action caused by
+ """Invalidate the session. The action caused by
``invalidate`` is implementation-dependent, but it should have
the effect of completely dissociating any data stored in the
session with the current request. It might set response
@@ -1179,7 +1176,7 @@ class ISession(IDict):
"""
def changed():
- """ Mark the session as changed. A user of a session should
+ """Mark the session as changed. A user of a session should
call this method after he or she mutates a mutable object that
is *a value of the session* (it should not be required after
mutating the session itself). For example, if the user has
@@ -1191,20 +1188,20 @@ class ISession(IDict):
internal dictionary."""
def flash(msg, queue='', allow_duplicate=True):
- """ Push a flash message onto the end of the flash queue represented
+ """Push a flash message onto the end of the flash queue represented
by ``queue``. An alternate flash message queue can used by passing
an optional ``queue``, which must be a string. If
``allow_duplicate`` is false, if the ``msg`` already exists in the
queue, it will not be re-added."""
def pop_flash(queue=''):
- """ Pop a queue from the flash storage. The queue is removed from
+ """Pop a queue from the flash storage. The queue is removed from
flash storage after this message is called. The queue is returned;
it is a list of flash messages added by
:meth:`pyramid.interfaces.ISession.flash`"""
def peek_flash(queue=''):
- """ Peek at a queue in the flash storage. The queue remains in
+ """Peek at a queue in the flash storage. The queue remains in
flash storage after this message is called. The queue is returned;
it is a list of flash messages added by
:meth:`pyramid.interfaces.ISession.flash`
@@ -1212,18 +1209,18 @@ class ISession(IDict):
class ICSRFStoragePolicy(Interface):
- """ An object that offers the ability to verify CSRF tokens and generate
+ """An object that offers the ability to verify CSRF tokens and generate
new ones."""
def new_csrf_token(request):
- """ Create and return a new, random cross-site request forgery
+ """Create and return a new, random cross-site request forgery
protection token. The token will be an ascii-compatible unicode
string.
"""
def get_csrf_token(request):
- """ Return a cross-site request forgery protection token. It
+ """Return a cross-site request forgery protection token. It
will be an ascii-compatible unicode string. If a token was previously
set for this user via ``new_csrf_token``, that token will be returned.
If no CSRF token was previously set, ``new_csrf_token`` will be
@@ -1233,7 +1230,7 @@ class ICSRFStoragePolicy(Interface):
"""
def check_csrf_token(request, token):
- """ Determine if the supplied ``token`` is valid. Most implementations
+ """Determine if the supplied ``token`` is valid. Most implementations
should simply compare the ``token`` to the current value of
``get_csrf_token`` but it is possible to verify the token using
any mechanism necessary using this method.
@@ -1245,12 +1242,12 @@ class ICSRFStoragePolicy(Interface):
class IIntrospector(Interface):
def get(category_name, discriminator, default=None):
- """ Get the IIntrospectable related to the category_name and the
+ """Get the IIntrospectable related to the category_name and the
discriminator (or discriminator hash) ``discriminator``. If it does
- not exist in the introspector, return the value of ``default`` """
+ not exist in the introspector, return the value of ``default``"""
def get_category(category_name, default=None, sort_key=None):
- """ Get a sequence of dictionaries in the form
+ """Get a sequence of dictionaries in the form
``[{'introspectable':IIntrospectable, 'related':[sequence of related
IIntrospectables]}, ...]`` where each introspectable is part of the
category associated with ``category_name`` .
@@ -1265,11 +1262,11 @@ class IIntrospector(Interface):
``sorted`` callable)."""
def categories():
- """ Return a sorted sequence of category names known by
- this introspector """
+ """Return a sorted sequence of category names known by
+ this introspector"""
def categorized(sort_key=None):
- """ Get a sequence of tuples in the form ``[(category_name,
+ """Get a sequence of tuples in the form ``[(category_name,
[{'introspectable':IIntrospectable, 'related':[sequence of related
IIntrospectables]}, ...])]`` representing all known
introspectables. If ``sort_key`` is ``None``, each introspectables
@@ -1279,19 +1276,19 @@ class IIntrospector(Interface):
``key`` function of Python's ``sorted`` callable)."""
def remove(category_name, discriminator):
- """ Remove the IIntrospectable related to ``category_name`` and
+ """Remove the IIntrospectable related to ``category_name`` and
``discriminator`` from the introspector, and fix up any relations
that the introspectable participates in. This method will not raise
an error if an introspectable related to the category name and
discriminator does not exist."""
def related(intr):
- """ Return a sequence of IIntrospectables related to the
+ """Return a sequence of IIntrospectables related to the
IIntrospectable ``intr``. Return the empty sequence if no relations
for exist."""
def add(intr):
- """ Add the IIntrospectable ``intr`` (use instead of
+ """Add the IIntrospectable ``intr`` (use instead of
:meth:`pyramid.interfaces.IIntrospector.add` when you have a custom
IIntrospectable). Replaces any existing introspectable registered
using the same category/discriminator.
@@ -1300,7 +1297,7 @@ class IIntrospector(Interface):
indirectly by :meth:`pyramid.interfaces.IIntrospector.register`"""
def relate(*pairs):
- """ Given any number of ``(category_name, discriminator)`` pairs
+ """Given any number of ``(category_name, discriminator)`` pairs
passed as positional arguments, relate the associated introspectables
to each other. The introspectable related to each pair must have
already been added via ``.add`` or ``.add_intr``; a :exc:`KeyError`
@@ -1312,7 +1309,7 @@ class IIntrospector(Interface):
"""
def unrelate(*pairs):
- """ Given any number of ``(category_name, discriminator)`` pairs
+ """Given any number of ``(category_name, discriminator)`` pairs
passed as positional arguments, unrelate the associated introspectables
from each other. The introspectable related to each pair must have
already been added via ``.add`` or ``.add_intr``; a :exc:`KeyError`
@@ -1325,7 +1322,7 @@ class IIntrospector(Interface):
class IIntrospectable(Interface):
- """ An introspectable object used for configuration introspection. In
+ """An introspectable object used for configuration introspection. In
addition to the methods below, objects which implement this interface
must also implement all the methods of Python's
``collections.MutableMapping`` (the "dictionary interface"), and must be
@@ -1350,19 +1347,19 @@ class IIntrospectable(Interface):
)
def relate(category_name, discriminator):
- """ Indicate an intent to relate this IIntrospectable with another
+ """Indicate an intent to relate this IIntrospectable with another
IIntrospectable (the one associated with the ``category_name`` and
``discriminator``) during action execution.
"""
def unrelate(category_name, discriminator):
- """ Indicate an intent to break the relationship between this
+ """Indicate an intent to break the relationship between this
IIntrospectable with another IIntrospectable (the one associated with
the ``category_name`` and ``discriminator``) during action execution.
"""
def register(introspector, action_info):
- """ Register this IIntrospectable with an introspector. This method
+ """Register this IIntrospectable with an introspector. This method
is invoked during action execution. Adds the introspectable and its
relations to the introspector. ``introspector`` should be an object
implementing IIntrospector. ``action_info`` should be a object
@@ -1383,7 +1380,7 @@ class IIntrospectable(Interface):
def __hash__():
- """ Introspectables must be hashable. The typical implementation of
+ """Introspectables must be hashable. The typical implementation of
an introsepectable's __hash__ is::
return hash((self.category_name,) + (self.discriminator,))
@@ -1391,7 +1388,7 @@ class IIntrospectable(Interface):
class IActionInfo(Interface):
- """ Class which provides code introspection capability associated with an
+ """Class which provides code introspection capability associated with an
action. The ParserInfo class used by ZCML implements the same interface.
"""
@@ -1402,8 +1399,8 @@ class IActionInfo(Interface):
)
def __str__():
- """ Return a representation of the action information (including
- source code from file, if possible) """
+ """Return a representation of the action information (including
+ source code from file, if possible)"""
class IAssetDescriptor(Interface):
@@ -1470,7 +1467,7 @@ class IPredicateInfo(Interface):
)
def maybe_dotted(value):
- """ Resolve the :term:`dotted Python name` ``dotted`` to a
+ """Resolve the :term:`dotted Python name` ``dotted`` to a
global Python object. If ``dotted`` is not a string, return
it without attempting to do any name resolution. If
``dotted`` is a relative dotted name (e.g. ``.foo.bar``,
@@ -1561,7 +1558,7 @@ class IViewDeriver(Interface):
class IViewDeriverInfo(Interface):
- """ An object implementing this interface is passed to every
+ """An object implementing this interface is passed to every
:term:`view deriver` during configuration."""
registry = Attribute(
diff --git a/src/pyramid/paster.py b/src/pyramid/paster.py
index 00c1a8915..f14acacf7 100644
--- a/src/pyramid/paster.py
+++ b/src/pyramid/paster.py
@@ -14,7 +14,7 @@ def setup_logging(config_uri, global_conf=None):
def get_app(config_uri, name=None, options=None):
- """ Return the WSGI application named ``name`` in the PasteDeploy
+ """Return the WSGI application named ``name`` in the PasteDeploy
config file specified by ``config_uri``.
``options``, if passed, should be a dictionary used as variable assignments
@@ -31,7 +31,7 @@ def get_app(config_uri, name=None, options=None):
def get_appsettings(config_uri, name=None, options=None):
- """ Return a dictionary representing the key/value pairs in an ``app``
+ """Return a dictionary representing the key/value pairs in an ``app``
section within the file represented by ``config_uri``.
``options``, if passed, should be a dictionary used as variable assignments
@@ -48,7 +48,7 @@ def get_appsettings(config_uri, name=None, options=None):
def bootstrap(config_uri, request=None, options=None):
- """ Load a WSGI application from the PasteDeploy config file specified
+ """Load a WSGI application from the PasteDeploy config file specified
by ``config_uri``. The environment will be configured as if it is
currently serving ``request``, leaving a natural environment in place
to write scripts that can generate URLs and utilize renderers.
diff --git a/src/pyramid/path.py b/src/pyramid/path.py
index 6d387f55b..3c0c1a682 100644
--- a/src/pyramid/path.py
+++ b/src/pyramid/path.py
@@ -25,7 +25,7 @@ def caller_module(level=2, sys=sys):
def package_name(pkg_or_module):
- """ If this function is passed a module, return the dotted Python
+ """If this function is passed a module, return the dotted Python
package name of the package in which the module lives. If this
function is passed a package, return the dotted Python package
name of the package itself."""
@@ -119,7 +119,7 @@ class Resolver:
class AssetResolver(Resolver):
- """ A class used to resolve an :term:`asset specification` to an
+ """A class used to resolve an :term:`asset specification` to an
:term:`asset descriptor`.
.. versionadded:: 1.3
@@ -215,7 +215,7 @@ class AssetResolver(Resolver):
class DottedNameResolver(Resolver):
- """ A class used to resolve a :term:`dotted Python name` to a package or
+ """A class used to resolve a :term:`dotted Python name` to a package or
module object.
.. versionadded:: 1.3
diff --git a/src/pyramid/registry.py b/src/pyramid/registry.py
index 6f6ef5f77..66519398c 100644
--- a/src/pyramid/registry.py
+++ b/src/pyramid/registry.py
@@ -9,7 +9,7 @@ from pyramid.path import CALLER_PACKAGE, caller_package
class Registry(Components, dict):
- """ A registry object is an :term:`application registry`.
+ """A registry object is an :term:`application registry`.
It is used by the framework itself to perform mappings of URLs to view
callables, as well as servicing other various framework duties. A registry
@@ -265,7 +265,7 @@ class Introspectable(dict):
class Deferred:
- """ Can be used by a third-party configuration extender to wrap a
+ """Can be used by a third-party configuration extender to wrap a
:term:`discriminator` during configuration if an immediately hashable
discriminator cannot be computed because it relies on unresolved values.
The function should accept no arguments and should return a hashable
@@ -285,7 +285,7 @@ class Deferred:
def undefer(v):
- """ Function which accepts an object and returns it unless it is a
+ """Function which accepts an object and returns it unless it is a
:class:`pyramid.registry.Deferred` instance. If it is an instance of
that class, its ``resolve`` method is called, and the result of the
method is returned."""
diff --git a/src/pyramid/renderers.py b/src/pyramid/renderers.py
index 8da6270c3..a15909cc0 100644
--- a/src/pyramid/renderers.py
+++ b/src/pyramid/renderers.py
@@ -19,7 +19,7 @@ from pyramid.util import hide_attrs
def render(renderer_name, value, request=None, package=None):
- """ Using the renderer ``renderer_name`` (a template
+ """Using the renderer ``renderer_name`` (a template
or a static renderer), render the value (or set of values) present
in ``value``. Return the result of the renderer's ``__call__``
method (usually a string or Unicode).
@@ -72,7 +72,7 @@ def render(renderer_name, value, request=None, package=None):
def render_to_response(
renderer_name, value, request=None, package=None, response=None
):
- """ Using the renderer ``renderer_name`` (a template
+ """Using the renderer ``renderer_name`` (a template
or a static renderer), render the value (or set of values) using
the result of the renderer's ``__call__`` method (usually a string
or Unicode) as the response body.
@@ -133,7 +133,7 @@ def render_to_response(
def get_renderer(renderer_name, package=None, registry=None):
- """ Return the renderer object for the renderer ``renderer_name``.
+ """Return the renderer object for the renderer ``renderer_name``.
You may supply a relative asset spec as ``renderer_name``. If
the ``package`` argument is supplied, a relative renderer name
@@ -178,7 +178,7 @@ _marker = object()
class JSON:
- """ Renderer that returns a JSON-encoded string.
+ """Renderer that returns a JSON-encoded string.
Configure a custom JSON renderer using the
:meth:`~pyramid.config.Configurator.add_renderer` API at application
@@ -226,7 +226,7 @@ class JSON:
"""
def __init__(self, serializer=json.dumps, adapters=(), **kw):
- """ Any keyword arguments will be passed to the ``serializer``
+ """Any keyword arguments will be passed to the ``serializer``
function."""
self.serializer = serializer
self.kw = kw
@@ -235,7 +235,7 @@ class JSON:
self.add_adapter(type, adapter)
def add_adapter(self, type_or_iface, adapter):
- """ When an object of the type (or interface) ``type_or_iface`` fails
+ """When an object of the type (or interface) ``type_or_iface`` fails
to automatically encode using the serializer, the renderer will use
the adapter ``adapter`` to convert it into a JSON-serializable
object. The adapter must accept two arguments: the object and the
@@ -261,7 +261,7 @@ class JSON:
)
def __call__(self, info):
- """ Returns a plain JSON-encoded string with content-type
+ """Returns a plain JSON-encoded string with content-type
``application/json``. The content-type may be overridden by
setting ``request.response.content_type``."""
@@ -299,7 +299,7 @@ JSONP_VALID_CALLBACK = re.compile(r"^[$a-z_][$0-9a-z_\.\[\]]+[^.]$", re.I)
class JSONP(JSON):
- """ `JSONP <https://en.wikipedia.org/wiki/JSONP>`_ renderer factory helper
+ """`JSONP <https://en.wikipedia.org/wiki/JSONP>`_ renderer factory helper
which implements a hybrid json/jsonp renderer. JSONP is useful for
making cross-domain AJAX requests.
@@ -366,7 +366,7 @@ class JSONP(JSON):
JSON.__init__(self, **kw)
def __call__(self, info):
- """ Returns JSONP-encoded string with content-type
+ """Returns JSONP-encoded string with content-type
``application/javascript`` if query parameter matching
``self.param_name`` is present in request.GET; otherwise returns
plain-JSON encoded string with content-type ``application/json``"""
@@ -499,7 +499,7 @@ class RendererHelper:
class NullRendererHelper(RendererHelper):
- """ Special renderer helper that has render_* methods which simply return
+ """Special renderer helper that has render_* methods which simply return
the value they are fed rather than converting them to response objects;
useful for testing purposes and special case view configuration
registrations that want to use the view configuration machinery but do
diff --git a/src/pyramid/request.py b/src/pyramid/request.py
index ef0efaa64..e5cfb37b8 100644
--- a/src/pyramid/request.py
+++ b/src/pyramid/request.py
@@ -188,7 +188,7 @@ class Request(
@reify
def session(self):
- """ Obtain the :term:`session` object associated with this
+ """Obtain the :term:`session` object associated with this
request. If a :term:`session factory` has not been registered
during application configuration, a
:class:`pyramid.exceptions.ConfigurationError` will be raised"""
@@ -218,7 +218,7 @@ class Request(
return response_factory(self)
def is_response(self, ob):
- """ Return ``True`` if the object passed as ``ob`` is a valid
+ """Return ``True`` if the object passed as ``ob`` is a valid
response object, ``False`` otherwise."""
if ob.__class__ is Response:
return True
diff --git a/src/pyramid/response.py b/src/pyramid/response.py
index c9beb9e0d..3090d7e75 100644
--- a/src/pyramid/response.py
+++ b/src/pyramid/response.py
@@ -70,7 +70,7 @@ class FileResponse(Response):
class FileIter:
- """ A fixed-block-size iterator for use as a WSGI app_iter.
+ """A fixed-block-size iterator for use as a WSGI app_iter.
``file`` is a Python file pointer (or at least an object with a ``read``
method that takes a size hint).
@@ -96,7 +96,7 @@ class FileIter:
class response_adapter:
- """ Decorator activated via a :term:`scan` which treats the function
+ """Decorator activated via a :term:`scan` which treats the function
being decorated as a :term:`response adapter` for the set of types or
interfaces passed as ``*types_or_ifaces`` to the decorator constructor.
@@ -183,7 +183,7 @@ class response_adapter:
def _get_response_factory(registry):
- """ Obtain a :class: `pyramid.response.Response` using the
+ """Obtain a :class: `pyramid.response.Response` using the
`pyramid.interfaces.IResponseFactory`.
"""
response_factory = registry.queryUtility(
diff --git a/src/pyramid/scripting.py b/src/pyramid/scripting.py
index bf23f1008..bb2947301 100644
--- a/src/pyramid/scripting.py
+++ b/src/pyramid/scripting.py
@@ -7,7 +7,7 @@ from pyramid.traversal import DefaultRootFactory
def get_root(app, request=None):
- """ Return a tuple composed of ``(root, closer)`` when provided a
+ """Return a tuple composed of ``(root, closer)`` when provided a
:term:`router` instance as the ``app`` argument. The ``root``
returned is the application root object. The ``closer`` returned
is a callable (accepting no arguments) that should be called when
@@ -33,7 +33,7 @@ def get_root(app, request=None):
def prepare(request=None, registry=None):
- """ This function pushes data onto the Pyramid threadlocal stack
+ """This function pushes data onto the Pyramid threadlocal stack
(request and registry), making those objects 'current'. It
returns a dictionary useful for bootstrapping a Pyramid
application in a scripting environment.
@@ -128,7 +128,7 @@ class AppEnvironment(dict):
def _make_request(path, registry=None):
- """ Return a :meth:`pyramid.request.Request` object anchored at a
+ """Return a :meth:`pyramid.request.Request` object anchored at a
given path. The object returned will be generated from the supplied
registry's :term:`Request Factory` using the
:meth:`pyramid.interfaces.IRequestFactory.blank` method.
diff --git a/src/pyramid/security.py b/src/pyramid/security.py
index 2a1ef24bd..cbab0a0f2 100644
--- a/src/pyramid/security.py
+++ b/src/pyramid/security.py
@@ -122,7 +122,7 @@ deprecated(
def view_execution_permitted(context, request, name=''):
- """ If the view specified by ``context`` and ``name`` is protected
+ """If the view specified by ``context`` and ``name`` is protected
by a :term:`permission`, check the permission associated with the
view using the effective authentication/authorization policies and
the ``request``. Return a boolean result. If no
@@ -250,7 +250,7 @@ class SecurityAPIMixin:
return self.authenticated_identity is not None
def has_permission(self, permission, context=None):
- """ Given a permission and an optional context, returns an instance of
+ """Given a permission and an optional context, returns an instance of
:data:`pyramid.security.Allowed` if the permission is granted to this
request with the provided context, or the context already associated
with the request. Otherwise, returns an instance of
diff --git a/src/pyramid/session.py b/src/pyramid/session.py
index 5d5f3b939..8c27aa674 100644
--- a/src/pyramid/session.py
+++ b/src/pyramid/session.py
@@ -12,7 +12,7 @@ from pyramid.util import bytes_, text_
def manage_accessed(wrapped):
- """ Decorator which causes a cookie to be renewed when an accessor
+ """Decorator which causes a cookie to be renewed when an accessor
method is called."""
def accessed(session, *arg, **kw):
@@ -27,7 +27,7 @@ def manage_accessed(wrapped):
def manage_changed(wrapped):
- """ Decorator which causes a cookie to be set when a setter method
+ """Decorator which causes a cookie to be set when a setter method
is called."""
def changed(session, *arg, **kw):
diff --git a/src/pyramid/settings.py b/src/pyramid/settings.py
index d6e4ea9b2..56ddcaf5a 100644
--- a/src/pyramid/settings.py
+++ b/src/pyramid/settings.py
@@ -3,7 +3,7 @@ falsey = frozenset(('f', 'false', 'n', 'no', 'off', '0'))
def asbool(s):
- """ Return the boolean value ``True`` if the case-lowered value of string
+ """Return the boolean value ``True`` if the case-lowered value of string
input ``s`` is a :term:`truthy string`. If ``s`` is already one of the
boolean values ``True`` or ``False``, return it."""
if s is None:
@@ -21,7 +21,7 @@ def aslist_cronly(value):
def aslist(value, flatten=True):
- """ Return a list, separating the input based on newlines.
+ """Return a list, separating the input based on newlines.
Also if ``flatten`` is ``True`` (the default), and if the line
is a string, then the line will be split on spaces.
"""
diff --git a/src/pyramid/static.py b/src/pyramid/static.py
index ccd6404da..8b19c7b16 100644
--- a/src/pyramid/static.py
+++ b/src/pyramid/static.py
@@ -13,7 +13,7 @@ from pyramid.traversal import traversal_path_info
class static_view:
- """ An instance of this class is a callable which can act as a
+ """An instance of this class is a callable which can act as a
:app:`Pyramid` :term:`view callable`; this view will serve
static files from a directory on disk based on the ``root_dir``
you provide to its constructor.
@@ -211,7 +211,8 @@ class static_view:
# identity is acceptable
if not request.accept_encoding:
identity_path = next(
- (path for path, encoding in files if encoding is None), None,
+ (path for path, encoding in files if encoding is None),
+ None,
)
return identity_path, None
diff --git a/src/pyramid/testing.py b/src/pyramid/testing.py
index 8ee9f976c..ddfe2a660 100644
--- a/src/pyramid/testing.py
+++ b/src/pyramid/testing.py
@@ -114,7 +114,7 @@ class DummyTemplateRenderer:
return val
def assert_(self, **kw):
- """ Accept an arbitrary set of assertion key/value pairs. For
+ """Accept an arbitrary set of assertion key/value pairs. For
each assertion key/value pair assert that the renderer
(eg. :func:`pyramid.renderers.render_to_response`)
received the key with a value that equals the asserted
@@ -145,7 +145,7 @@ class DummyResource:
def __init__(
self, __name__=None, __parent__=None, __provides__=None, **kw
):
- """ The resource's ``__name__`` attribute will be set to the
+ """The resource's ``__name__`` attribute will be set to the
value of the ``__name__`` argument, and the resource's
``__parent__`` attribute will be set to the value of the
``__parent__`` argument. If ``__provides__`` is specified, it
@@ -168,7 +168,7 @@ class DummyResource:
self.subs = {}
def __setitem__(self, name, val):
- """ When the ``__setitem__`` method is called, the object
+ """When the ``__setitem__`` method is called, the object
passed in as ``val`` will be decorated with a ``__parent__``
attribute pointing at the dummy resource and a ``__name__``
attribute that is the value of ``name``. The value will then
@@ -213,7 +213,7 @@ class DummyResource:
return name in self.subs
def clone(self, __name__=_marker, __parent__=_marker, **kw):
- """ Create a clone of the resource object. If ``__name__`` or
+ """Create a clone of the resource object. If ``__name__`` or
``__parent__`` arguments are passed, use these values to
override the existing ``__name__`` or ``__parent__`` of the
resource. If any extra keyword args are passed in via the ``kw``
@@ -279,7 +279,7 @@ class DummyRequest(
AuthenticationAPIMixin,
ViewMethodsMixin,
):
- """ A DummyRequest object (incompletely) imitates a :term:`request` object.
+ """A DummyRequest object (incompletely) imitates a :term:`request` object.
The ``params``, ``environ``, ``headers``, ``path``, and
``cookies`` arguments correspond to their :term:`WebOb`
@@ -554,7 +554,7 @@ def cleanUp(*arg, **kw):
class DummyRendererFactory:
- """ Registered by
+ """Registered by
:meth:`pyramid.config.Configurator.testing_add_renderer` as
a dummy renderer factory. The indecision about what to use as a
key (a spec vs. a relative name) is caused by test suites in the
diff --git a/src/pyramid/traversal.py b/src/pyramid/traversal.py
index 39cfc4f2e..dadeeda64 100644
--- a/src/pyramid/traversal.py
+++ b/src/pyramid/traversal.py
@@ -20,7 +20,7 @@ PATH_SAFE = PATH_SEGMENT_SAFE + "/"
def find_root(resource):
- """ Find the root node in the resource tree to which ``resource``
+ """Find the root node in the resource tree to which ``resource``
belongs. Note that ``resource`` should be :term:`location`-aware.
Note that the root resource is available in the request object by
accessing the ``request.root`` attribute.
@@ -33,7 +33,7 @@ def find_root(resource):
def find_resource(resource, path):
- """ Given a resource object and a string or tuple representing a path
+ """Given a resource object and a string or tuple representing a path
(such as the return value of :func:`pyramid.traversal.resource_path` or
:func:`pyramid.traversal.resource_path_tuple`), return a resource in this
application's resource tree at the specified path. The resource passed
@@ -109,7 +109,7 @@ def find_interface(resource, class_or_interface):
def resource_path(resource, *elements):
- """ Return a string object representing the absolute physical path of the
+ """Return a string object representing the absolute physical path of the
resource object based on its position in the resource tree, e.g
``/foo/bar``. Any positional arguments passed in as ``elements`` will be
appended as path segments to the end of the resource path. For instance,
@@ -361,7 +361,7 @@ model_path_tuple = resource_path_tuple # b/w compat (forever)
def _resource_path_list(resource, *elements):
- """ Implementation detail shared by resource_path and
+ """Implementation detail shared by resource_path and
resource_path_tuple"""
path = [loc.__name__ or '' for loc in lineage(resource)]
path.reverse()
@@ -418,7 +418,7 @@ def virtual_root(resource, request):
def traversal_path(path):
- """ Variant of :func:`pyramid.traversal.traversal_path_info` suitable for
+ """Variant of :func:`pyramid.traversal.traversal_path_info` suitable for
decoding paths that are URL-encoded.
If this function is passed a string, it *must* be directly encodeable to
@@ -437,7 +437,7 @@ def traversal_path(path):
@lru_cache(1000)
def traversal_path_info(path):
- """ Given``path``, return a tuple representing that path which can be
+ """Given``path``, return a tuple representing that path which can be
used to traverse a resource tree. ``path`` is assumed to be an
already-URL-decoded ``str`` type as if it had come to us from an upstream
WSGI server as the ``PATH_INFO`` environ variable.
@@ -581,7 +581,7 @@ def quote_path_segment(segment, safe=PATH_SEGMENT_SAFE):
@implementer(ITraverser)
class ResourceTreeTraverser:
- """ A resource tree traverser that should be used (for speed) when
+ """A resource tree traverser that should be used (for speed) when
every resource in the tree supplies a ``__name__`` and
``__parent__`` attribute (ie. every resource in the tree is
:term:`location` aware) ."""
diff --git a/src/pyramid/tweens.py b/src/pyramid/tweens.py
index b5660b44b..b4a9ad641 100644
--- a/src/pyramid/tweens.py
+++ b/src/pyramid/tweens.py
@@ -20,7 +20,7 @@ def _error_handler(request, exc):
def excview_tween_factory(handler, registry):
- """ A :term:`tween` factory which produces a tween that catches an
+ """A :term:`tween` factory which produces a tween that catches an
exception raised by downstream tweens (or the main Pyramid request
handler) and, if possible, converts it into a Response using an
:term:`exception view`.
diff --git a/src/pyramid/url.py b/src/pyramid/url.py
index 438400ae8..b60bed96d 100644
--- a/src/pyramid/url.py
+++ b/src/pyramid/url.py
@@ -57,8 +57,8 @@ def parse_url_overrides(request, kw):
class URLMethodsMixin:
- """ Request methods mixin for BaseRequest having to do with URL
- generation """
+ """Request methods mixin for BaseRequest having to do with URL
+ generation"""
def _partial_application_url(self, scheme=None, host=None, port=None):
"""
diff --git a/src/pyramid/util.py b/src/pyramid/util.py
index 4a92986ae..f8d082348 100644
--- a/src/pyramid/util.py
+++ b/src/pyramid/util.py
@@ -28,7 +28,7 @@ class DottedNameResolver(_DottedNameResolver):
def text_(s, encoding='latin-1', errors='strict'):
- """ If ``s`` is an instance of ``bytes``, return
+ """If ``s`` is an instance of ``bytes``, return
``s.decode(encoding, errors)``, otherwise return ``s``"""
if isinstance(s, bytes):
return s.decode(encoding, errors)
@@ -36,7 +36,7 @@ def text_(s, encoding='latin-1', errors='strict'):
def bytes_(s, encoding='latin-1', errors='strict'):
- """ If ``s`` is an instance of ``str``, return
+ """If ``s`` is an instance of ``str``, return
``s.encode(encoding, errors)``, otherwise return ``s``"""
if isinstance(s, str):
return s.encode(encoding, errors)
@@ -102,7 +102,7 @@ class InstancePropertyHelper:
@classmethod
def make_property(cls, callable, name=None, reify=False):
- """ Convert a callable into one suitable for adding to the
+ """Convert a callable into one suitable for adding to the
instance. This will return a 2-tuple containing the computed
(name, property) pair.
"""
@@ -188,13 +188,13 @@ class InstancePropertyHelper:
class InstancePropertyMixin:
- """ Mixin that will allow an instance to add properties at
+ """Mixin that will allow an instance to add properties at
run-time as if they had been defined via @property or @reify
on the class itself.
"""
def set_property(self, callable, name=None, reify=False):
- """ Add a callable or a property descriptor to the instance.
+ """Add a callable or a property descriptor to the instance.
Properties, unlike attributes, are lazily evaluated by executing
an underlying callable when accessed. They can be useful for
@@ -251,7 +251,7 @@ class InstancePropertyMixin:
class WeakOrderedSet:
- """ Maintain a set of items.
+ """Maintain a set of items.
Each item is stored as a weakref to avoid extending their lifetime.
@@ -346,7 +346,7 @@ def strings_differ(string1, string2):
def object_description(object):
- """ Produce a human-consumable text description of ``object``,
+ """Produce a human-consumable text description of ``object``,
usually involving a Python dotted name. For example:
>>> object_description(None)
@@ -423,7 +423,7 @@ LAST = Sentinel('LAST')
class TopologicalSorter:
- """ A utility class which can be used to perform topological sorts against
+ """A utility class which can be used to perform topological sorts against
tuple-like data."""
def __init__(
@@ -460,7 +460,7 @@ class TopologicalSorter:
self.order.remove((name, u))
def add(self, name, val, after=None, before=None):
- """ Add a node to the sort input. The ``name`` should be a string or
+ """Add a node to the sort input. The ``name`` should be a string or
any other hashable object, the ``val`` should be the sortable (doesn't
need to be hashable). ``after`` and ``before`` represents the name of
one of the other sortables (or a sequence of such named) or one of the
diff --git a/src/pyramid/view.py b/src/pyramid/view.py
index 891cedde3..1541cdb23 100644
--- a/src/pyramid/view.py
+++ b/src/pyramid/view.py
@@ -26,7 +26,7 @@ _marker = object()
def render_view_to_response(context, request, name='', secure=True):
- """ Call the :term:`view callable` configured with a :term:`view
+ """Call the :term:`view callable` configured with a :term:`view
configuration` that matches the :term:`view name` ``name``
registered against the specified ``context`` and ``request`` and
return a :term:`response` object. This function will return
@@ -77,7 +77,7 @@ def render_view_to_response(context, request, name='', secure=True):
def render_view_to_iterable(context, request, name='', secure=True):
- """ Call the :term:`view callable` configured with a :term:`view
+ """Call the :term:`view callable` configured with a :term:`view
configuration` that matches the :term:`view name` ``name``
registered against the specified ``context`` and ``request`` and
return an iterable object which represents the body of a response.
@@ -108,7 +108,7 @@ def render_view_to_iterable(context, request, name='', secure=True):
def render_view(context, request, name='', secure=True):
- """ Call the :term:`view callable` configured with a :term:`view
+ """Call the :term:`view callable` configured with a :term:`view
configuration` that matches the :term:`view name` ``name``
registered against the specified ``context`` and ``request``
and unwind the view response's ``app_iter`` (see
@@ -136,7 +136,7 @@ def render_view(context, request, name='', secure=True):
class view_config:
- """ A function, class or method :term:`decorator` which allows a
+ """A function, class or method :term:`decorator` which allows a
developer to create view registrations nearer to a :term:`view
callable` definition than use :term:`imperative
configuration` to do the same.
@@ -262,7 +262,7 @@ bfg_view = view_config # bw compat (forever)
def view_defaults(**settings):
- """ A class :term:`decorator` which, when applied to a class, will
+ """A class :term:`decorator` which, when applied to a class, will
provide defaults for all view configurations that use the class. This
decorator accepts all the arguments accepted by
:meth:`pyramid.view.view_config`, and each has the same meaning.
@@ -278,7 +278,7 @@ def view_defaults(**settings):
class AppendSlashNotFoundViewFactory:
- """ There can only be one :term:`Not Found view` in any
+ """There can only be one :term:`Not Found view` in any
:app:`Pyramid` application. Even if you use
:func:`pyramid.view.append_slash_notfound_view` as the Not
Found view, :app:`Pyramid` still must generate a ``404 Not
@@ -683,13 +683,13 @@ def _call_view(
class ViewMethodsMixin:
- """ Request methods mixin for BaseRequest having to do with executing
- views """
+ """Request methods mixin for BaseRequest having to do with executing
+ views"""
def invoke_exception_view(
self, exc_info=None, request=None, secure=True, reraise=False
):
- """ Executes an exception view related to the request it's called upon.
+ """Executes an exception view related to the request it's called upon.
The arguments it takes are these:
``exc_info``
diff --git a/src/pyramid/wsgi.py b/src/pyramid/wsgi.py
index 5aec62b77..0eef0f19a 100644
--- a/src/pyramid/wsgi.py
+++ b/src/pyramid/wsgi.py
@@ -4,7 +4,7 @@ from pyramid.request import call_app_with_subpath_as_path_info
def wsgiapp(wrapped):
- """ Decorator to turn a WSGI application into a :app:`Pyramid`
+ """Decorator to turn a WSGI application into a :app:`Pyramid`
:term:`view callable`. This decorator differs from the
:func:`pyramid.wsgi.wsgiapp2` decorator inasmuch as fixups of
``PATH_INFO`` and ``SCRIPT_NAME`` within the WSGI environment *are
@@ -45,7 +45,7 @@ def wsgiapp(wrapped):
def wsgiapp2(wrapped):
- """ Decorator to turn a WSGI application into a :app:`Pyramid`
+ """Decorator to turn a WSGI application into a :app:`Pyramid`
view callable. This decorator differs from the
:func:`pyramid.wsgi.wsgiapp` decorator inasmuch as fixups of
``PATH_INFO`` and ``SCRIPT_NAME`` within the WSGI environment
diff --git a/tests/test_path.py b/tests/test_path.py
index f77e35638..479e12e40 100644
--- a/tests/test_path.py
+++ b/tests/test_path.py
@@ -655,8 +655,7 @@ class DummyPackageOrModule:
class DummyNamespacePackage:
- """Has no __file__ attribute.
- """
+ """Has no __file__ attribute."""
def __init__(self, real_package_or_module):
self.__name__ = real_package_or_module.__name__
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 74c0ae639..8f912dbd7 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -300,7 +300,9 @@ class TestDummyRequest(unittest.TestCase):
class TestDummyTemplateRenderer(unittest.TestCase):
- def _getTargetClass(self,):
+ def _getTargetClass(
+ self,
+ ):
from pyramid.testing import DummyTemplateRenderer
return DummyTemplateRenderer
diff --git a/tests/test_util.py b/tests/test_util.py
index cb5fd8185..bf4c08988 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -137,7 +137,7 @@ class Test_InstancePropertyHelper(unittest.TestCase):
self.assertEqual(2, foo.x)
def test_reset_reify(self):
- """ This is questionable behavior, but may as well get notified
+ """This is questionable behavior, but may as well get notified
if it changes."""
foo = Dummy()
helper = self._getTargetClass()
@@ -333,7 +333,7 @@ class Test_InstancePropertyMixin(unittest.TestCase):
self.assertEqual(2, foo.x)
def test_reset_reify(self):
- """ This is questionable behavior, but may as well get notified
+ """This is questionable behavior, but may as well get notified
if it changes."""
foo = self._makeOne()
foo.set_property(lambda _: 1, name='x', reify=True)