Skip to content

Commit

Permalink
Merge pull request #3616 from Pylons/blackify-master
Browse files Browse the repository at this point in the history
Blackify for v20.8b1
  • Loading branch information
stevepiercy committed Sep 30, 2020
2 parents 6116c6c + 54fa9aa commit ee7ca28
Show file tree
Hide file tree
Showing 41 changed files with 280 additions and 286 deletions.
4 changes: 2 additions & 2 deletions src/pyramid/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions src/pyramid/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _clean_principal(self, princid):
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``.
Expand Down Expand Up @@ -95,7 +95,7 @@ def authenticated_userid(self, request):
)

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
Expand Down Expand Up @@ -179,7 +179,7 @@ def effective_principals(self, request):

@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).
Expand Down Expand Up @@ -218,7 +218,7 @@ def _get_identifier(self, request):
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``.
Expand Down Expand Up @@ -272,7 +272,7 @@ def unauthenticated_userid(self, request):
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
Expand Down Expand Up @@ -345,7 +345,7 @@ def effective_principals(self, request):
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
Expand All @@ -361,7 +361,7 @@ def remember(self, request, userid, **kw):
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.
Expand All @@ -376,7 +376,7 @@ def forget(self, request):

@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
Expand Down Expand Up @@ -415,13 +415,13 @@ def unauthenticated_userid(self, request):
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 []
Expand Down Expand Up @@ -637,7 +637,7 @@ def unauthenticated_userid(self, request):
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
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def _get_cookies(self, request, value, max_age=None):
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)
Expand Down Expand Up @@ -1118,13 +1118,13 @@ def reissue_authtkt(request, response):
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``
Expand Down Expand Up @@ -1204,7 +1204,7 @@ def remember(self, request, userid, max_age=None, tokens=()):

@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`.
Expand Down Expand Up @@ -1251,7 +1251,7 @@ def unauthenticated_userid(self, request):


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
Expand Down Expand Up @@ -1284,7 +1284,7 @@ def authenticated_userid(self, request):

@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.
Expand Down Expand Up @@ -1342,14 +1342,14 @@ def unauthenticated_userid(self, request):
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)]

Expand All @@ -1370,7 +1370,7 @@ def callback(self, username, request):


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
Expand Down
12 changes: 6 additions & 6 deletions src/pyramid/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ACLDenied(_ACLDenied):

@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
Expand All @@ -68,14 +68,14 @@ def __init__(self):
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`."""
Expand All @@ -85,7 +85,7 @@ def principals_allowed_by_permission(self, context, permission):


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
Expand All @@ -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.
Expand Down Expand Up @@ -152,7 +152,7 @@ def permits(self, context, principals, permission):
)

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`.
Expand Down
16 changes: 8 additions & 8 deletions src/pyramid/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def setup_registry(
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
Expand Down Expand Up @@ -450,7 +450,7 @@ def _make_spec(self, path_or_spec):
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."""
Expand Down Expand Up @@ -714,7 +714,7 @@ def __getattr__(self, name):
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__(
Expand All @@ -731,7 +731,7 @@ def with_package(self, package):
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``,
Expand All @@ -740,7 +740,7 @@ def maybe_dotted(self, dotted):
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
Expand All @@ -755,7 +755,7 @@ def absolute_asset_spec(self, relative_spec):
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
Expand All @@ -781,7 +781,7 @@ def begin(self, request=_marker):
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.
Expand Down Expand Up @@ -882,7 +882,7 @@ def scan(
)

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
Expand Down
8 changes: 4 additions & 4 deletions src/pyramid/config/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def action(
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``).
Expand Down Expand Up @@ -187,8 +187,8 @@ def action(
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
Expand Down Expand Up @@ -541,7 +541,7 @@ def __str__(self):


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."""

Expand Down
2 changes: 1 addition & 1 deletion src/pyramid/config/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def add_subscriber_predicate(

@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
Expand Down
16 changes: 6 additions & 10 deletions src/pyramid/config/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_overrides(self):
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.
"""
Expand Down Expand Up @@ -164,23 +164,19 @@ def real_loader(self):
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)


Expand Down Expand Up @@ -321,7 +317,7 @@ def _override(

@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
Expand Down

0 comments on commit ee7ca28

Please sign in to comment.