diff options
| author | Marcin Lulek <info@webreactor.eu> | 2022-01-07 14:51:48 +0100 |
|---|---|---|
| committer | Marcin Lulek <info@webreactor.eu> | 2022-01-07 14:51:48 +0100 |
| commit | b492e302a5dfe471acb065a79f5b4ec7651f34d3 (patch) | |
| tree | e85dd64335c958d5fa7200ecfc375d29c624f8de /src | |
| parent | 0ee365dc7195a402a2c04d5d857ccf70d2b6c8a5 (diff) | |
| download | pyramid-b492e302a5dfe471acb065a79f5b4ec7651f34d3.tar.gz pyramid-b492e302a5dfe471acb065a79f5b4ec7651f34d3.tar.bz2 pyramid-b492e302a5dfe471acb065a79f5b4ec7651f34d3.zip | |
make latest black happy
Diffstat (limited to 'src')
| -rw-r--r-- | src/pyramid/authentication.py | 22 | ||||
| -rw-r--r-- | src/pyramid/config/assets.py | 4 | ||||
| -rw-r--r-- | src/pyramid/csrf.py | 12 | ||||
| -rw-r--r-- | src/pyramid/i18n.py | 4 | ||||
| -rw-r--r-- | src/pyramid/interfaces.py | 80 | ||||
| -rw-r--r-- | src/pyramid/path.py | 6 | ||||
| -rw-r--r-- | src/pyramid/registry.py | 2 | ||||
| -rw-r--r-- | src/pyramid/security.py | 8 | ||||
| -rw-r--r-- | src/pyramid/session.py | 2 | ||||
| -rw-r--r-- | src/pyramid/static.py | 6 | ||||
| -rw-r--r-- | src/pyramid/testing.py | 16 | ||||
| -rw-r--r-- | src/pyramid/util.py | 14 |
12 files changed, 88 insertions, 88 deletions
diff --git a/src/pyramid/authentication.py b/src/pyramid/authentication.py index 8faf84d68..9120ad03b 100644 --- a/src/pyramid/authentication.py +++ b/src/pyramid/authentication.py @@ -24,7 +24,7 @@ VALID_TOKEN = re.compile(r"^[A-Za-z][A-Za-z0-9+_-]*$") class CallbackAuthenticationPolicy: - """ Abstract class """ + """Abstract class""" debug = False callback = None @@ -265,7 +265,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): return userid def unauthenticated_userid(self, request): - """ Return the ``repoze.who.userid`` key from the detected identity.""" + """Return the ``repoze.who.userid`` key from the detected identity.""" identity = self._get_identity(request) if identity is None: return None @@ -411,7 +411,7 @@ class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy): self.debug = debug def unauthenticated_userid(self, request): - """ The ``REMOTE_USER`` value found within the ``environ``.""" + """The ``REMOTE_USER`` value found within the ``environ``.""" return request.environ.get(self.environ_key) def remember(self, request, userid, **kw): @@ -631,7 +631,7 @@ class AuthTktAuthenticationPolicy(CallbackAuthenticationPolicy): self.debug = debug def unauthenticated_userid(self, request): - """ The userid key within the auth_tkt cookie.""" + """The userid key within the auth_tkt cookie.""" result = self.cookie.identify(request) if result: return result['userid'] @@ -647,7 +647,7 @@ class AuthTktAuthenticationPolicy(CallbackAuthenticationPolicy): return self.cookie.remember(request, userid, **kw) def forget(self, request): - """ A list of headers which will delete appropriate cookies.""" + """A list of headers which will delete appropriate cookies.""" return self.cookie.forget(request) @@ -1235,11 +1235,11 @@ class SessionAuthenticationPolicy(CallbackAuthenticationPolicy): self.helper = SessionAuthenticationHelper(prefix) def remember(self, request, userid, **kw): - """ Store a userid in the session.""" + """Store a userid in the session.""" return self.helper.remember(request, userid, **kw) def forget(self, request): - """ Remove the stored userid from the session.""" + """Remove the stored userid from the session.""" return self.helper.forget(request) def unauthenticated_userid(self, request): @@ -1263,18 +1263,18 @@ class SessionAuthenticationHelper: self.userid_key = prefix + 'userid' def remember(self, request, userid, **kw): - """ Store a userid in the session.""" + """Store a userid in the session.""" request.session[self.userid_key] = userid return [] def forget(self, request, **kw): - """ Remove the stored userid from the session.""" + """Remove the stored userid from the session.""" if self.userid_key in request.session: del request.session[self.userid_key] return [] def authenticated_userid(self, request): - """ Return the stored userid.""" + """Return the stored userid.""" return request.session.get(self.userid_key) @@ -1332,7 +1332,7 @@ class BasicAuthAuthenticationPolicy(CallbackAuthenticationPolicy): self.debug = debug def unauthenticated_userid(self, request): - """ The userid parsed from the ``Authorization`` request header.""" + """The userid parsed from the ``Authorization`` request header.""" credentials = extract_http_basic_credentials(request) if credentials: return credentials.username diff --git a/src/pyramid/config/assets.py b/src/pyramid/config/assets.py index 0dd7cf2c2..d62b04e57 100644 --- a/src/pyramid/config/assets.py +++ b/src/pyramid/config/assets.py @@ -34,7 +34,7 @@ class OverrideProvider(pkg_resources.DefaultProvider): ) def get_resource_stream(self, manager, resource_name): - """ Return a readable file-like object for resource_name.""" + """Return a readable file-like object for resource_name.""" overrides = self._get_overrides() if overrides is not None: stream = overrides.get_stream(resource_name) @@ -45,7 +45,7 @@ class OverrideProvider(pkg_resources.DefaultProvider): ) def get_resource_string(self, manager, resource_name): - """ Return a string containing the contents of resource_name.""" + """Return a string containing the contents of resource_name.""" overrides = self._get_overrides() if overrides is not None: string = overrides.get_string(resource_name) diff --git a/src/pyramid/csrf.py b/src/pyramid/csrf.py index 7f4f72f44..0ade5f2d6 100644 --- a/src/pyramid/csrf.py +++ b/src/pyramid/csrf.py @@ -32,7 +32,7 @@ class LegacySessionCSRFStoragePolicy: """ def new_csrf_token(self, request): - """ Sets a new CSRF token into the session and returns it. """ + """Sets a new CSRF token into the session and returns it.""" return request.session.new_csrf_token() def get_csrf_token(self, request): @@ -41,7 +41,7 @@ class LegacySessionCSRFStoragePolicy: return request.session.get_csrf_token() def check_csrf_token(self, request, supplied_token): - """ Returns ``True`` if the ``supplied_token`` is valid.""" + """Returns ``True`` if the ``supplied_token`` is valid.""" expected_token = self.get_csrf_token(request) return not strings_differ( bytes_(expected_token), bytes_(supplied_token) @@ -70,7 +70,7 @@ class SessionCSRFStoragePolicy: self.key = key def new_csrf_token(self, request): - """ Sets a new CSRF token into the session and returns it. """ + """Sets a new CSRF token into the session and returns it.""" token = self._token_factory() request.session[self.key] = token return token @@ -84,7 +84,7 @@ class SessionCSRFStoragePolicy: return token def check_csrf_token(self, request, supplied_token): - """ Returns ``True`` if the ``supplied_token`` is valid.""" + """Returns ``True`` if the ``supplied_token`` is valid.""" expected_token = self.get_csrf_token(request) return not strings_differ( bytes_(expected_token), bytes_(supplied_token) @@ -134,7 +134,7 @@ class CookieCSRFStoragePolicy: self.cookie_name = cookie_name def new_csrf_token(self, request): - """ Sets a new CSRF token into the request and returns it. """ + """Sets a new CSRF token into the request and returns it.""" token = self._token_factory() request.cookies[self.cookie_name] = token @@ -154,7 +154,7 @@ class CookieCSRFStoragePolicy: return token def check_csrf_token(self, request, supplied_token): - """ Returns ``True`` if the ``supplied_token`` is valid.""" + """Returns ``True`` if the ``supplied_token`` is valid.""" expected_token = self.get_csrf_token(request) return not strings_differ( bytes_(expected_token), bytes_(supplied_token) diff --git a/src/pyramid/i18n.py b/src/pyramid/i18n.py index 793b25015..7c9ef3b4b 100644 --- a/src/pyramid/i18n.py +++ b/src/pyramid/i18n.py @@ -221,7 +221,7 @@ def get_localizer(request): class Translations(gettext.GNUTranslations): - """An extended translation catalog class (ripped off from Babel) """ + """An extended translation catalog class (ripped off from Babel)""" DEFAULT_DOMAIN = 'messages' @@ -369,7 +369,7 @@ class Translations(gettext.GNUTranslations): class LocalizerRequestMixin: @reify def localizer(self): - """ Convenience property to return a localizer """ + """Convenience property to return a localizer""" registry = self.registry current_locale_name = self.locale_name diff --git a/src/pyramid/interfaces.py b/src/pyramid/interfaces.py index 6704f7c7c..c99f5a0d0 100644 --- a/src/pyramid/interfaces.py +++ b/src/pyramid/interfaces.py @@ -207,7 +207,7 @@ class IResponse(Interface): ) def copy(): - """ Makes a copy of the response and returns the copy. """ + """Makes a copy of the response and returns the copy.""" date = Attribute( """Gets and sets and deletes the Date header. For more information on @@ -306,7 +306,7 @@ class IResponse(Interface): expires=None, overwrite=False, ): - """ Set (add) a cookie for the response """ + """Set (add) a cookie for the response""" status = Attribute(""" The status string. """) @@ -334,7 +334,7 @@ class IResponse(Interface): class IException(Interface): # not an API - """ An interface representing a generic exception """ + """An interface representing a generic exception""" class IExceptionResponse(IException, IResponse): @@ -347,17 +347,17 @@ class IExceptionResponse(IException, IResponse): :class:`pyramid.httpexceptions.HTTPForbidden`).""" def prepare(environ): - """ Prepares the response for being called as a WSGI application """ + """Prepares the response for being called as a WSGI application""" class IDict(Interface): # Documentation-only interface def __contains__(k): - """ Return ``True`` if key ``k`` exists in the dictionary.""" + """Return ``True`` if key ``k`` exists in the dictionary.""" def __setitem__(k, value): - """ Set a key/value pair into the dictionary""" + """Set a key/value pair into the dictionary""" def __delitem__(k): """Delete an item from the dictionary which is passed to the @@ -368,20 +368,20 @@ class IDict(Interface): KeyError if the key doesn't exist""" def __iter__(): - """ Return an iterator over the keys of this dictionary """ + """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 the default if no such value exists.""" def items(): - """ Return a list of [(k,v)] pairs from the dictionary """ + """Return a list of [(k,v)] pairs from the dictionary""" def keys(): - """ Return a list of keys from the dictionary """ + """Return a list of keys from the dictionary""" def values(): - """ Return a list of values from the dictionary """ + """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 @@ -400,10 +400,10 @@ class IDict(Interface): the dictionary, return the default""" def update(d): - """ Update the renderer dictionary with another dictionary ``d``.""" + """Update the renderer dictionary with another dictionary ``d``.""" def clear(): - """ Clear all values from the dictionary """ + """Clear all values from the dictionary""" class IBeforeRender(IDict): @@ -453,7 +453,7 @@ class IRendererInfo(Interface): ) def clone(): - """ Return a shallow copy that does not share any mutable state.""" + """Return a shallow copy that does not share any mutable state.""" class IRendererFactory(Interface): @@ -633,7 +633,7 @@ class IMultiDict(IDict): # docs-only interface """ def add(key, value): - """ Add the key and value, not overwriting any previous value. """ + """Add the key and value, not overwriting any previous value.""" def dict_of_lists(): """ @@ -666,7 +666,7 @@ class IMultiDict(IDict): # docs-only interface class IRequest(Interface): - """ Request type interface attached to all request objects """ + """Request type interface attached to all request objects""" class ITweens(Interface): @@ -710,20 +710,20 @@ class IAcceptOrder(Interface): class IStaticURLInfo(Interface): - """ A policy for generating URLs to static assets """ + """A policy for generating URLs to static assets""" def add(config, name, spec, **extra): - """ Add a new static info registration """ + """Add a new static info registration""" def generate(path, request, **kw): - """ Generate a URL for the given path """ + """Generate a URL for the given path""" def add_cache_buster(config, spec, cache_buster): - """ Add a new cache buster to a particular set of assets """ + """Add a new cache buster to a particular set of assets""" class IResponseFactory(Interface): - """ A utility which generates a response """ + """A utility which generates a response""" def __call__(request): """Return a response object implementing IResponse, @@ -732,10 +732,10 @@ class IResponseFactory(Interface): class IRequestFactory(Interface): - """ A utility which generates a request """ + """A utility which generates a request""" def __call__(environ): - """ Return an instance of ``pyramid.request.Request``""" + """Return an instance of ``pyramid.request.Request``""" def blank(path): """Return an empty request object (see @@ -743,23 +743,23 @@ class IRequestFactory(Interface): class IViewClassifier(Interface): - """ *Internal only* marker interface for views.""" + """*Internal only* marker interface for views.""" class IExceptionViewClassifier(Interface): - """ *Internal only* marker interface for exception views.""" + """*Internal only* marker interface for exception views.""" class IView(Interface): def __call__(context, request): - """ Must return an object that implements IResponse. """ + """Must return an object that implements IResponse.""" class ISecuredView(IView): - """ *Internal only* interface. Not an API. """ + """*Internal only* interface. Not an API.""" def __call_permissive__(context, request): - """ Guaranteed-permissive version of __call__ """ + """Guaranteed-permissive version of __call__""" def __permitted__(context, request): """Return True if view execution will be permitted using the @@ -772,17 +772,17 @@ class IMultiView(ISecuredView): zero or more predicates. Not an API.""" def add(view, predicates, order, accept=None, phash=None): - """ Add a view to the multiview. """ + """Add a view to the multiview.""" class IRootFactory(Interface): def __call__(request): - """ Return a root object based on the request """ + """Return a root object based on the request""" class IDefaultRootFactory(Interface): def __call__(request): - """ Return the *default* root object for an application """ + """Return the *default* root object for an application""" class ITraverser(Interface): @@ -915,7 +915,7 @@ class ILocation(Interface): class IDebugLogger(Interface): - """ Interface representing a PEP 282 logger """ + """Interface representing a PEP 282 logger""" ILogger = IDebugLogger # b/c @@ -988,14 +988,14 @@ class IRoute(Interface): class IRoutesMapper(Interface): - """ Interface representing a Routes ``Mapper`` object """ + """Interface representing a Routes ``Mapper`` object""" def get_routes(): """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. """ + """Returns ``True`` if any route has been registered.""" def get_route(name): """Returns an ``IRoute`` object if a route with the name ``name`` @@ -1009,7 +1009,7 @@ class IRoutesMapper(Interface): pregenerator=None, static=True, ): - """ Add a new route. """ + """Add a new route.""" def generate(name, kw): """Generate a URL using the route named ``name`` with the @@ -1080,7 +1080,7 @@ class IPEP302Loader(Interface): class IPackageOverrides(IPEP302Loader): - """ Utility for pkg_resources overrides """ + """Utility for pkg_resources overrides""" # VH_ROOT_KEY is an interface; its imported from other packages (e.g. @@ -1089,12 +1089,12 @@ VH_ROOT_KEY = 'HTTP_X_VHM_ROOT' class ILocalizer(Interface): - """ Localizer for a specific language """ + """Localizer for a specific language""" class ILocaleNegotiator(Interface): def __call__(request): - """ Return a locale name """ + """Return a locale name""" class ITranslationDirectories(Interface): @@ -1131,7 +1131,7 @@ class ISessionFactory(Interface): returns an ISession object""" def __call__(request): - """ Return an ISession object """ + """Return an ISession object""" class ISession(IDict): @@ -1457,7 +1457,7 @@ class IJSONAdapter(Interface): class IPredicateList(Interface): - """ Interface representing a predicate list """ + """Interface representing a predicate list""" class IPredicateInfo(Interface): @@ -1589,7 +1589,7 @@ class IViewDeriverInfo(Interface): class IViewDerivers(Interface): - """ Interface for view derivers list """ + """Interface for view derivers list""" class ICacheBuster(Interface): diff --git a/src/pyramid/path.py b/src/pyramid/path.py index 3c0c1a682..3db4bf0ff 100644 --- a/src/pyramid/path.py +++ b/src/pyramid/path.py @@ -45,7 +45,7 @@ def package_name(pkg_or_module): def package_of(pkg_or_module): - """ Return the package of a module or return the package itself """ + """Return the package of a module or return the package itself""" pkg_name = package_name(pkg_or_module) __import__(pkg_name) return sys.modules[pkg_name] @@ -334,7 +334,7 @@ class DottedNameResolver(Resolver): return self._zope_dottedname_style(dotted, package) def _pkg_resources_style(self, value, package): - """ package.module:attr style """ + """package.module:attr style""" if value.startswith(('.', ':')): if not package: raise ValueError( @@ -354,7 +354,7 @@ class DottedNameResolver(Resolver): return ep.load(False) # pragma: NO COVER def _zope_dottedname_style(self, value, package): - """ package.module.attr style """ + """package.module.attr style""" module = getattr(package, '__name__', None) # package may be None if not module: module = None diff --git a/src/pyramid/registry.py b/src/pyramid/registry.py index 66519398c..2d790015a 100644 --- a/src/pyramid/registry.py +++ b/src/pyramid/registry.py @@ -295,7 +295,7 @@ def undefer(v): class predvalseq(tuple): - """ A subtype of tuple used to represent a sequence of predicate values """ + """A subtype of tuple used to represent a sequence of predicate values""" global_registry = Registry('global') diff --git a/src/pyramid/security.py b/src/pyramid/security.py index a0ab39701..e1de9d9a6 100644 --- a/src/pyramid/security.py +++ b/src/pyramid/security.py @@ -171,7 +171,7 @@ class PermitsResult(int): @property def msg(self): - """ A string indicating why the result was generated.""" + """A string indicating why the result was generated.""" return self.s % self.args def __str__(self): @@ -212,7 +212,7 @@ class Allowed(PermitsResult): class SecurityAPIMixin: - """ Mixin for Request class providing auth-related properties. """ + """Mixin for Request class providing auth-related properties.""" @property def identity(self): @@ -278,7 +278,7 @@ class SecurityAPIMixin: class AuthenticationAPIMixin: - """ Mixin for Request class providing compatibility properties. """ + """Mixin for Request class providing compatibility properties.""" @property def unauthenticated_userid(self): @@ -396,7 +396,7 @@ Deny = 'Deny' class AllPermissionsList: - """ Stand in 'permission list' to represent all permissions """ + """Stand in 'permission list' to represent all permissions""" def __iter__(self): return iter(()) diff --git a/src/pyramid/session.py b/src/pyramid/session.py index 032d58a8b..431fdd5ec 100644 --- a/src/pyramid/session.py +++ b/src/pyramid/session.py @@ -189,7 +189,7 @@ def BaseCookieSessionFactory( @implementer(ISession) class CookieSession(dict): - """ Dictionary-like session object """ + """Dictionary-like session object""" # configuration parameters _cookie_name = cookie_name diff --git a/src/pyramid/static.py b/src/pyramid/static.py index 8b19c7b16..5363c1671 100644 --- a/src/pyramid/static.py +++ b/src/pyramid/static.py @@ -171,7 +171,7 @@ class static_view: return name def get_possible_files(self, resource_name): - """ Return a sorted list of ``(size, encoding, path)`` entries.""" + """Return a sorted list of ``(size, encoding, path)`` entries.""" result = self.filemap.get(resource_name) if result is not None: return result @@ -206,7 +206,7 @@ class static_view: return result def find_best_match(self, request, files): - """ Return ``(path | None, encoding)``.""" + """Return ``(path | None, encoding)``.""" # if the client did not specify encodings then assume only the # identity is acceptable if not request.accept_encoding: @@ -408,7 +408,7 @@ class ManifestCacheBuster: @property def manifest(self): - """ The current manifest dictionary.""" + """The current manifest dictionary.""" if self.reload: if not self.exists(self.manifest_path): return {} diff --git a/src/pyramid/testing.py b/src/pyramid/testing.py index 621a69d4b..9a7c9af0e 100644 --- a/src/pyramid/testing.py +++ b/src/pyramid/testing.py @@ -31,7 +31,7 @@ class DummyRootFactory: class DummySecurityPolicy: - """ A standin for a :term:`security policy`.""" + """A standin for a :term:`security policy`.""" def __init__( self, @@ -105,7 +105,7 @@ class DummyTemplateRenderer: return self.string_response def __getattr__(self, k): - """ Backwards compatibility """ + """Backwards compatibility""" val = self._received.get(k, _marker) if val is _marker: val = self._implementation._received.get(k, _marker) @@ -140,7 +140,7 @@ class DummyTemplateRenderer: class DummyResource: - """ A dummy :app:`Pyramid` :term:`resource` object.""" + """A dummy :app:`Pyramid` :term:`resource` object.""" def __init__( self, __name__=None, __parent__=None, __provides__=None, **kw @@ -179,7 +179,7 @@ class DummyResource: self.subs[name] = val def __getitem__(self, name): - """ Return a named subobject (see ``__setitem__``)""" + """Return a named subobject (see ``__setitem__``)""" ob = self.subs[name] return ob @@ -190,15 +190,15 @@ class DummyResource: return self.subs.get(name, default) def values(self): - """ Return the values set by __setitem__ """ + """Return the values set by __setitem__""" return self.subs.values() def items(self): - """ Return the items set by __setitem__ """ + """Return the items set by __setitem__""" return self.subs.items() def keys(self): - """ Return the keys set by __setitem__ """ + """Return the keys set by __setitem__""" return self.subs.keys() __iter__ = keys @@ -545,7 +545,7 @@ def tearDown(unhook_zca=True): def cleanUp(*arg, **kw): - """ An alias for :func:`pyramid.testing.setUp`. """ + """An alias for :func:`pyramid.testing.setUp`.""" package = kw.get('package', None) if package is None: package = caller_package() diff --git a/src/pyramid/util.py b/src/pyramid/util.py index f8d082348..191768eb3 100644 --- a/src/pyramid/util.py +++ b/src/pyramid/util.py @@ -182,7 +182,7 @@ class InstancePropertyHelper: self.properties[name] = fn def apply(self, target): - """ Apply all configured properties to the ``target`` instance.""" + """Apply all configured properties to the ``target`` instance.""" if self.properties: self.apply_properties(target, self.properties) @@ -275,7 +275,7 @@ class WeakOrderedSet: self._order = [] def add(self, item): - """ Add an item to the set.""" + """Add an item to the set.""" oid = id(item) if oid in self._items: self._order.remove(oid) @@ -286,17 +286,17 @@ class WeakOrderedSet: self._order.append(oid) def _remove_by_id(self, oid): - """ Remove an item from the set.""" + """Remove an item from the set.""" if oid in self._items: del self._items[oid] self._order.remove(oid) def remove(self, item): - """ Remove an item from the set.""" + """Remove an item from the set.""" self._remove_by_id(id(item)) def empty(self): - """ Clear all objects from the set.""" + """Clear all objects from the set.""" self._items = {} self._order = [] @@ -445,7 +445,7 @@ class TopologicalSorter: return self.name2val.values() def remove(self, name): - """ Remove a node from the sort input """ + """Remove a node from the sort input""" self.names.remove(name) del self.name2val[name] after = self.name2after.pop(name, []) @@ -499,7 +499,7 @@ class TopologicalSorter: self.req_before.add(name) def sorted(self): - """ Returns the sort input values in topologically sorted order""" + """Returns the sort input values in topologically sorted order""" order = [(self.first, self.last)] roots = [] graph = {} |
