Skip to content

Commit

Permalink
format: Updating black to resolve click dependency issue (PROJQUAY-3487
Browse files Browse the repository at this point in the history
…) (#1209)

Currently the CI breaks due to a dependency of black, `click`, breaking with it's latest release with `ImportError: cannot import name '_unicodefun' from 'click'`. Since black does not pin it's version of click it pulls in the latest version containing the breaking change and fails the CI check. This updates black with the patch. [See the original issue here.](psf/black#2964) The rest of the changes are format updates introduced with the latest version of black.
  • Loading branch information
bcaton85 authored Mar 29, 2022
1 parent 188e450 commit ef91c57
Show file tree
Hide file tree
Showing 25 changed files with 76 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black==20.8b1
pip install black==22.3.0
pip install flake8
- name: Check Formatting (Black)
Expand Down
6 changes: 3 additions & 3 deletions buildman/container_cloud_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@


class CloudConfigContext(object):
""" Context object for easy generating of cloud config. """
"""Context object for easy generating of cloud config."""

def populate_jinja_environment(self, env):
""" Populates the given jinja environment with the methods defined in this context. """
"""Populates the given jinja environment with the methods defined in this context."""
env.filters["registry"] = self.registry
env.filters["dataurl"] = self.data_url
env.filters["jsonify"] = json.dumps
Expand Down Expand Up @@ -111,7 +111,7 @@ def _dockersystemd_template(
)

def data_url(self, content):
""" Encodes the content of an ignition file using RFC 2397. """
"""Encodes the content of an ignition file using RFC 2397."""
data = "," + urlquote(content)
return "data:" + data

Expand Down
2 changes: 1 addition & 1 deletion buildman/manager/basemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BaseManager(ABC):
"""

def __new__(cls, *args, **kwargs):
"""Hack to ensure method defined as async are implemented as such. """
"""Hack to ensure method defined as async are implemented as such."""
coroutines = inspect.getmembers(BaseManager, predicate=inspect.iscoroutinefunction)
for coroutine in coroutines:
implemented_method = getattr(cls, coroutine[0])
Expand Down
2 changes: 1 addition & 1 deletion data/cache/redis_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class ReadEndpointSupportedRedis(object):
""" Wrapper class for Redis to split read/write requests between separate endpoints."""
"""Wrapper class for Redis to split read/write requests between separate endpoints."""

def __init__(self, primary=None, replica=None):
if not primary or primary.get("host") is None:
Expand Down
4 changes: 2 additions & 2 deletions data/decorators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def deprecated_model(model_cls):
""" Marks a model has deprecated, and ensures no writings occur on it. """
"""Marks a model has deprecated, and ensures no writings occur on it."""
model_cls.__deprecated_model = True
return model_cls


def is_deprecated_model(model_cls):
""" Returns whether the given model class has been deprecated. """
"""Returns whether the given model class has been deprecated."""
return hasattr(model_cls, "__deprecated_model")
4 changes: 2 additions & 2 deletions data/estimate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def mysql_estimate_row_count(model_cls, db):
""" Uses the information_schema to retrieve the row count for a table. """
"""Uses the information_schema to retrieve the row count for a table."""
query = "SELECT table_rows FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = %s"
cursor = db.execute_sql(query, (model_cls._meta.table_name,))
res = cursor.fetchone()
return res[0]


def normal_row_count(model_cls, db):
""" Uses a normal .count() to retrieve the row count for a model. """
"""Uses a normal .count() to retrieve the row count for a model."""
return model_cls.select().count()
4 changes: 2 additions & 2 deletions data/model/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def temp_link_blob(repository_id, blob_digest, link_expiration_s):


def _temp_link_blob(repository_id, storage, link_expiration_s):
""" Note: Should *always* be called by a parent under a transaction. """
"""Note: Should *always* be called by a parent under a transaction."""
try:
repository = Repository.get(id=repository_id)
except Repository.DoesNotExist:
Expand All @@ -127,7 +127,7 @@ def _temp_link_blob(repository_id, storage, link_expiration_s):


def lookup_expired_uploaded_blobs(repository):
""" Looks up all expired uploaded blobs in a repository. """
"""Looks up all expired uploaded blobs in a repository."""
return UploadedBlob.select().where(
UploadedBlob.repository == repository, UploadedBlob.expires_at <= datetime.utcnow()
)
Expand Down
2 changes: 1 addition & 1 deletion data/model/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def purge_repository(repo, force=False):


def _chunk_delete_all(repo, model, force=False, chunk_size=500):
""" Deletes all rows referencing the given repository in the given model. """
"""Deletes all rows referencing the given repository in the given model."""
assert repo.state == RepositoryState.MARKED_FOR_DELETION or force

while True:
Expand Down
2 changes: 1 addition & 1 deletion data/model/oci/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def _build_blob_map(


def populate_legacy_images_for_testing(manifest, manifest_interface_instance, storage):
""" Populates the legacy image rows for the given manifest. """
"""Populates the legacy image rows for the given manifest."""
# NOTE: This method is only kept around for use by legacy tests that still require
# legacy images. As a result, we make sure we're in testing mode before we run.
assert os.getenv("TEST") == "true"
Expand Down
2 changes: 1 addition & 1 deletion data/model/oci/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def tags_containing_legacy_image(image):
.join(Image)
.where(Tag.repository == image.repository_id)
.where(Image.repository == image.repository_id)
.where((Image.id == image.id) | (Image.ancestors ** ancestors_str))
.where((Image.id == image.id) | (Image.ancestors**ancestors_str))
)
return filter_to_alive_tags(tags)

Expand Down
2 changes: 1 addition & 1 deletion data/model/repositoryactioncount.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def update_repository_score(repo):


def missing_counts_query(date):
""" Returns a query to find all Repository's with missing RAC entries for the given date. """
"""Returns a query to find all Repository's with missing RAC entries for the given date."""
subquery = (
RepositoryActionCount.select(RepositoryActionCount.id, RepositoryActionCount.repository)
.where(RepositoryActionCount.date == date)
Expand Down
2 changes: 1 addition & 1 deletion data/model/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def default_tag_policy(initialized_db):


def _delete_temp_links(repo):
""" Deletes any temp links to blobs. """
"""Deletes any temp links to blobs."""
UploadedBlob.delete().where(UploadedBlob.repository == repo).execute()


Expand Down
8 changes: 4 additions & 4 deletions data/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def _canonical_name(name_list):
@classmethod
def _running_jobs(cls, now, name_match_query):
return cls._running_jobs_where(QueueItem.select(QueueItem.queue_name), now).where(
QueueItem.queue_name ** name_match_query
QueueItem.queue_name**name_match_query
)

@classmethod
def _available_jobs(cls, now, name_match_query):
return cls._available_jobs_where(QueueItem.select(), now).where(
QueueItem.queue_name ** name_match_query
QueueItem.queue_name**name_match_query
)

@staticmethod
Expand Down Expand Up @@ -113,7 +113,7 @@ def strip_slash(name):

return (
QueueItem.select()
.where(QueueItem.queue_name ** canonical_name_query)
.where(QueueItem.queue_name**canonical_name_query)
.where(QueueItem.retries_remaining > 0)
.count()
)
Expand Down Expand Up @@ -190,7 +190,7 @@ def delete_namespaced_items(self, namespace, subpath=None):

subpath_query = "%s/" % subpath if subpath else ""
queue_prefix = "%s/%s/%s%%" % (self._queue_name, namespace, subpath_query)
return QueueItem.delete().where(QueueItem.queue_name ** queue_prefix).execute()
return QueueItem.delete().where(QueueItem.queue_name**queue_prefix).execute()

def alive(self, canonical_name_list):
"""
Expand Down
6 changes: 3 additions & 3 deletions data/registry_model/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def legacy_image_root_id(self, legacy_id_handler):
return legacy_id_handler.encode(self._db_id)

def as_manifest(self):
""" Returns the manifest or legacy image as a manifest. """
"""Returns the manifest or legacy image as a manifest."""
return self

@property
Expand Down Expand Up @@ -493,7 +493,7 @@ def for_schema1_manifest_layer_index(
)

def with_blob(self, blob):
""" Sets the blob for the legacy image. """
"""Sets the blob for the legacy image."""
return self._replace(blob=blob)

@property
Expand All @@ -516,7 +516,7 @@ def full_image_id_chain(self):
return [self.docker_image_id] + self.ancestor_ids

def as_manifest(self):
""" Returns the parent manifest for the legacy image. """
"""Returns the parent manifest for the legacy image."""
return self.manifest


Expand Down
2 changes: 1 addition & 1 deletion endpoints/appr/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def token(self):
return "basic ZGV2dGFibGU6cGFzc3dvcmQ="

def test_search_package_match(self, db_with_data1, client):
""" TODO: search cross namespace and package name """
"""TODO: search cross namespace and package name"""
BaseTestServer.test_search_package_match(self, db_with_data1, client)

def test_list_search_package_match(self, db_with_data1, client):
Expand Down
2 changes: 1 addition & 1 deletion image/docker/schema2/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _manifest_image_layers(self, content_retriever):

@property
def is_empty_manifest(self):
""" Returns whether this manifest is empty. """
"""Returns whether this manifest is empty."""
return len(self._parsed[DOCKER_SCHEMA2_MANIFEST_LAYERS_KEY]) == 0

@property
Expand Down
2 changes: 1 addition & 1 deletion image/oci/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def local_blob_digests(self):

@property
def annotations(self):
""" Returns the annotations on the manifest itself. """
"""Returns the annotations on the manifest itself."""
return self._parsed.get(OCI_MANIFEST_ANNOTATIONS_KEY) or {}

def get_blob_digests_for_translation(self):
Expand Down
2 changes: 1 addition & 1 deletion image/shared/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def is_manifest_list_type(content_type):
""" Returns True if the given content type refers to a manifest list of some kind. """
"""Returns True if the given content type refers to a manifest list of some kind."""
return content_type in MANIFEST_LIST_TYPES


Expand Down
2 changes: 1 addition & 1 deletion image/shared/schemautil.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def to_canonical_json(value, ensure_ascii=True, indent=None):


class LazyManifestLoader(object):
""" Lazy loader for manifests referenced by another manifest list or index. """
"""Lazy loader for manifests referenced by another manifest list or index."""

def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions mypy_stubs/peewee.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,9 @@ class Insert(_WriteQuery):
SIMPLE: int = ...
QUERY: int = ...
MULTI: int = ...

class DefaultValuesException(Exception): ...

def __init__(
self,
table: Any,
Expand Down
2 changes: 1 addition & 1 deletion storage/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@


def _build_endpoint_url(hostname, port=None, is_secure=True):
"""Normalize the formats from boto2 and boto3. """
"""Normalize the formats from boto2 and boto3."""

# If the scheme is not in the hostname, check if is_secure is set to set http or https as the scheme
if not hostname.startswith("http://") and not hostname.startswith("https://"):
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):


class log_queries(object):
""" Logs all queries that occur under the context. """
"""Logs all queries that occur under the context."""

def __init__(self, query_filters=None):
self.filters = query_filters
Expand Down
Loading

0 comments on commit ef91c57

Please sign in to comment.