Skip to content

Commit

Permalink
Merge pull request #2594 from Kinto/dependabot/pip/black-20.8b1
Browse files Browse the repository at this point in the history
Bump black from 19.10b0 to 20.8b1
  • Loading branch information
leplatrem committed Sep 1, 2020
2 parents 14dbac0 + 3bcd6cd commit f818429
Show file tree
Hide file tree
Showing 26 changed files with 42 additions and 86 deletions.
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black==19.10b0
black==20.8b1
bravado_core==5.17.0
flake8==3.8.3
isort==5.4.2
Expand Down
3 changes: 1 addition & 2 deletions kinto/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def _resource_endpoint(object_uri):


def _relative_object_uri(resource_name, object_uri):
"""Returns object_uri
"""
"""Returns object_uri"""
obj_parts = object_uri.split("/")
for length in range(len(obj_parts) + 1):
parent_uri = "/".join(obj_parts[:length])
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/cache/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def wrapped(*args, **kwargs):


def create_from_config(config, prefix=""):
"""Memcached client instantiation from settings.
"""
"""Memcached client instantiation from settings."""
settings = config.get_settings()
hosts = aslist(settings[prefix + "hosts"])
return memcache.Client(hosts)
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/cache/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def setUp(self):
self.client_error_patcher = None

def _get_config(self, settings=None):
"""Mock Pyramid config object.
"""
"""Mock Pyramid config object."""
if settings is None:
settings = self.settings
config = testing.setUp()
Expand Down
18 changes: 6 additions & 12 deletions kinto/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,31 @@ def impacted_records(self):


class ResourceRead(_ResourceEvent):
"""Triggered when a resource is being read.
"""
"""Triggered when a resource is being read."""

def __init__(self, payload, read_objects, request):
super().__init__(payload, request)
self.read_objects = read_objects


class ResourceChanged(_ResourceEvent):
"""Triggered when a resource is being changed.
"""
"""Triggered when a resource is being changed."""

def __init__(self, payload, impacted_objects, request):
super().__init__(payload, request)
self.impacted_objects = impacted_objects


class AfterResourceRead(_ResourceEvent):
"""Triggered after a resource was successfully read.
"""
"""Triggered after a resource was successfully read."""

def __init__(self, payload, read_objects, request):
super().__init__(payload, request)
self.read_objects = read_objects


class AfterResourceChanged(_ResourceEvent):
"""Triggered after a resource was successfully changed.
"""
"""Triggered after a resource was successfully changed."""

def __init__(self, payload, impacted_objects, request):
super().__init__(payload, request)
Expand Down Expand Up @@ -176,8 +172,7 @@ def setup_transaction_hook(config):
"""

def _notify_resource_events_after(success, request):
"""Notify the accumulated resource events if transaction succeeds.
"""
"""Notify the accumulated resource events if transaction succeeds."""
if not success: # pragma: no cover
return

Expand All @@ -188,8 +183,7 @@ def _notify_resource_events_after(success, request):
logger.error("Unable to notify", exc_info=True)

def on_new_request(event):
"""When a new request comes in, hook on transaction commit.
"""
"""When a new request comes in, hook on transaction commit."""
# Since there is one transaction per batch, ignore subrequests.
if hasattr(event.request, "parent"):
return
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def on_new_response(event):


def setup_version_redirection(config):
"""Add a view which redirects to the current version of the API.
"""
"""Add a view which redirects to the current version of the API."""
settings = config.get_settings()
redirect_enabled = settings["version_prefix_redirect_enabled"]
version_prefix_redirection_enabled = asbool(redirect_enabled)
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/permission/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def setUp(self):
self.client_error_patcher = []

def _get_config(self):
"""Mock Pyramid config object.
"""
"""Mock Pyramid config object."""
config = testing.setUp()
config.add_settings(self.settings)
return config
Expand Down
10 changes: 3 additions & 7 deletions kinto/core/resource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def register_resource(resource_cls, settings=None, viewset=None, depth=1, **kwar
resource_name = viewset.get_name(resource_cls)

def register_service(endpoint_type, settings):
"""Registers a service in cornice, for the given type.
"""
"""Registers a service in cornice, for the given type."""
path_pattern = getattr(viewset, f"{endpoint_type}_path")
path_values = {"resource_name": resource_name}
path = path_pattern.format_map(path_values)
Expand Down Expand Up @@ -887,9 +886,7 @@ def _get_object_or_404(self, object_id):
raise self._404_for_object(object_id)

def _add_timestamp_header(self, response, timestamp=None):
"""Add current timestamp in response headers, when request comes in.
"""
"""Add current timestamp in response headers, when request comes in."""
if timestamp is None:
timestamp = self.timestamp
# Pyramid takes care of converting.
Expand Down Expand Up @@ -1026,8 +1023,7 @@ def _raise_400_if_id_mismatch(self, new_id, object_id):
raise_invalid(self.request, **error_details)

def _extract_partial_fields(self):
"""Extract the fields to do the projection from QueryString parameters.
"""
"""Extract the fields to do the projection from QueryString parameters."""
fields = self.request.validated["querystring"].get("_fields")
if fields:
root_fields = [f.split(".")[0] for f in fields]
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/resource/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def _annotate(self, obj, perm_object_id):
return annotated

def _allow_write(self, perm_object_id):
"""Helper to give the ``write`` permission to the current user.
"""
"""Helper to give the ``write`` permission to the current user."""
self.permission.add_principal_to_ace(perm_object_id, "write", self.current_principal)

def get_objects(
Expand Down
6 changes: 2 additions & 4 deletions kinto/core/resource/viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ def get_view_arguments(self, endpoint_type, resource_cls, method):
return args

def get_object_schema(self, resource_cls, method):
"""Return the Cornice schema for the given method.
"""
"""Return the Cornice schema for the given method."""
if method.lower() in ("patch", "delete"):
resource_schema = SimpleSchema
else:
Expand All @@ -185,8 +184,7 @@ def get_view(self, endpoint_type, method):
return f"{endpoint_type}_{method.lower()}"

def get_name(self, resource_cls):
"""Returns the name of the resource.
"""
"""Returns the name of the resource."""
# Provided on viewset during registration.
if "name" in self.__dict__:
return self.__dict__["name"]
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def initialize_schema(self, dry_run=False):
raise NotImplementedError

def flush(self):
"""Remove **every** object from this storage.
"""
"""Remove **every** object from this storage."""
raise NotImplementedError

def resource_timestamp(self, resource_name, parent_id):
Expand Down
8 changes: 2 additions & 6 deletions kinto/core/storage/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ def __init__(self, original=None, message=None, *args, **kwargs):


class RecordNotFoundError(Exception):
"""Deprecated exception name.
"""
"""Deprecated exception name."""

pass


class ObjectNotFoundError(RecordNotFoundError):
"""An exception raised when a specific object could not be found.
"""
"""An exception raised when a specific object could not be found."""

pass

Expand Down
12 changes: 4 additions & 8 deletions kinto/core/storage/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def bump_timestamp(self, resource_timestamp, obj, modified_field, last_modified)
def bump_and_store_timestamp(
self, resource_name, parent_id, obj=None, modified_field=None, last_modified=None
):
"""Use the bump_timestamp to get its next value and store the resource_timestamp.
"""
"""Use the bump_timestamp to get its next value and store the resource_timestamp."""
raise NotImplementedError


Expand Down Expand Up @@ -157,8 +156,7 @@ def resource_timestamp(self, resource_name, parent_id):
def bump_and_store_timestamp(
self, resource_name, parent_id, obj=None, modified_field=None, last_modified=None
):
"""Use the bump_timestamp to get its next value and store the resource_timestamp.
"""
"""Use the bump_timestamp to get its next value and store the resource_timestamp."""
current_resource_timestamp = self._timestamps[parent_id].get(resource_name, 0)

current, resource_timestamp = self.bump_timestamp(
Expand Down Expand Up @@ -447,8 +445,7 @@ def canonical_json(obj):


def apply_filters(objects, filters):
"""Filter the specified objects, using basic iteration.
"""
"""Filter the specified objects, using basic iteration."""

def contains_filtering(object_value, search_term):
if object_value == MISSING:
Expand Down Expand Up @@ -552,8 +549,7 @@ def schwartzian_transform(value):


def apply_sorting(objects, sorting):
"""Sort the specified objects, using cumulative python sorting.
"""
"""Sort the specified objects, using cumulative python sorting."""
result = list(objects)

if not result:
Expand Down
6 changes: 2 additions & 4 deletions kinto/core/storage/postgresql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def __init__(self, client, max_fetch_size, *args, readonly=False, **kwargs):
self.readonly = readonly

def create_schema(self, dry_run=False):
"""Override create_schema to ensure DB encoding and TZ are OK.
"""
"""Override create_schema to ensure DB encoding and TZ are OK."""
self._check_database_encoding()
self._check_database_timezone()
return super().create_schema(dry_run)
Expand Down Expand Up @@ -124,8 +123,7 @@ def _check_database_encoding(self):
raise AssertionError(f"Unexpected database encoding {encoding}")

def get_installed_version(self):
"""Return current version of schema or None if not any found.
"""
"""Return current version of schema or None if not any found."""
# Check for objects table, which definitely indicates a new
# DB. (metadata can exist if the permission schema ran first.)
table_exists_query = """
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/storage/postgresql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def connect(self, readonly=False, force_commit=False):


def create_from_config(config, prefix="", with_transaction=True):
"""Create a PostgreSQLClient client using settings in the provided config.
"""
"""Create a PostgreSQLClient client using settings in the provided config."""
if sqlalchemy is None:
message = (
"PostgreSQL SQLAlchemy dependency missing. "
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/storage/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def setUp(self):
self.auth = "Basic bWF0OjE="

def _get_config(self, settings=None):
"""Mock Pyramid config object.
"""
"""Mock Pyramid config object."""
if settings is None:
settings = self.settings
config = testing.setUp()
Expand Down
6 changes: 2 additions & 4 deletions kinto/core/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@


class DummyRequest(mock.MagicMock):
"""Fully mocked request.
"""
"""Fully mocked request."""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -64,8 +63,7 @@ def blank(cls, path, *args, **kwargs):


class FormattedErrorMixin:
"""Test mixin in order to perform advanced error responses assertions.
"""
"""Test mixin in order to perform advanced error responses assertions."""

def assertFormattedError(self, response, code, errno, error, message=None, info=None):
self.assertIn("application/json", response.headers["Content-Type"])
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ def reapply_cors(request, response):


def log_context(request, **kwargs):
"""Bind information to the current request summary log.
"""
"""Bind information to the current request summary log."""
non_empty = {k: v for k, v in kwargs.items() if v is not None}
try:
request._log_context.update(**non_empty)
Expand Down
3 changes: 1 addition & 2 deletions kinto/core/views/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def __init__(self, *args, **kwargs):
self.get("defaults").get("path").missing = colander.drop

def deserialize(self, cstruct=colander.null):
"""Preprocess received data to carefully merge defaults.
"""
"""Preprocess received data to carefully merge defaults."""
if cstruct is not colander.null:
defaults = cstruct.get("defaults")
requests = cstruct.get("requests")
Expand Down
3 changes: 1 addition & 2 deletions kinto/plugins/openid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def __init__(self, issuer, client_id, realm="Realm", **kwargs):
self._jwt_keys = None

def unauthenticated_userid(self, request):
"""Return the userid or ``None`` if token could not be verified.
"""
"""Return the userid or ``None`` if token could not be verified."""
settings = request.registry.settings
hmac_secret = settings["userid_hmac_secret"]

Expand Down
3 changes: 1 addition & 2 deletions kinto/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def __call__(self):


class RelaxedUUID(generators.UUID4):
"""A generator that generates UUIDs but accepts any string.
"""
"""A generator that generates UUIDs but accepts any string."""

regexp = generators.Generator.regexp

Expand Down
3 changes: 1 addition & 2 deletions kinto/views/buckets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def get_parent_id(self, request):

@subscriber(ResourceChanged, for_resources=("bucket",), for_actions=(ACTIONS.DELETE,))
def on_buckets_deleted(event):
"""Some buckets were deleted, delete sub-resources.
"""
"""Some buckets were deleted, delete sub-resources."""
storage = event.request.registry.storage
permission = event.request.registry.permission

Expand Down
3 changes: 1 addition & 2 deletions kinto/views/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def process_object(self, new, old=None):

@subscriber(ResourceChanged, for_resources=("collection",), for_actions=(ACTIONS.DELETE,))
def on_collections_deleted(event):
"""Some collections were deleted, delete records.
"""
"""Some collections were deleted, delete records."""
storage = event.request.registry.storage
permission = event.request.registry.permission

Expand Down
6 changes: 2 additions & 4 deletions kinto/views/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def process_object(self, new, old=None):

@subscriber(ResourceChanged, for_resources=("group",), for_actions=(ACTIONS.DELETE,))
def on_groups_deleted(event):
"""Some groups were deleted, remove them from users principals.
"""
"""Some groups were deleted, remove them from users principals."""
permission_backend = event.request.registry.permission

for change in event.impacted_objects:
Expand All @@ -67,8 +66,7 @@ def on_groups_deleted(event):
ResourceChanged, for_resources=("group",), for_actions=(ACTIONS.CREATE, ACTIONS.UPDATE)
)
def on_groups_changed(event):
"""Some groups were changed, update users principals.
"""
"""Some groups were changed, update users principals."""
permission_backend = event.request.registry.permission

for change in event.impacted_objects:
Expand Down

0 comments on commit f818429

Please sign in to comment.