Skip to content

Commit

Permalink
Reblacken Python code (#7461)
Browse files Browse the repository at this point in the history
Black 24 is upon us, and with it a new stable code style. Reformat all
code to prevent CI failures in future PRs.
  • Loading branch information
SpecLad authored Feb 9, 2024
1 parent 8e6e46a commit b4eed78
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cvat-cli/requirements/development.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r base.txt

black>=22.1.0
black>=24.1
isort>=5.10.1
pylint>=2.7.0
3 changes: 1 addition & 2 deletions cvat-sdk/cvat_sdk/core/proxies/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class AnnotationCrudMixin(ABC):
# TODO: refactor

@property
def _put_annotations_data_param(self) -> str:
...
def _put_annotations_data_param(self) -> str: ...

def get_annotations(self: _EntityT) -> models.ILabeledData:
(annotations, _) = self.api.retrieve_annotations(getattr(self, self._model_id_field))
Expand Down
12 changes: 4 additions & 8 deletions cvat-sdk/cvat_sdk/core/proxies/model_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class ModelProxy(ABC, Generic[ModelType, ApiType]):
_client: Client

@property
def _api_member_name(self) -> str:
...
def _api_member_name(self) -> str: ...

def __init__(self, client: Client) -> None:
self.__dict__["_client"] = client
Expand Down Expand Up @@ -142,12 +141,10 @@ def retrieve(self: Repo, obj_id: int) -> _EntityT:

class ModelListMixin(Generic[_EntityT]):
@overload
def list(self: Repo, *, return_json: Literal[False] = False) -> List[_EntityT]:
...
def list(self: Repo, *, return_json: Literal[False] = False) -> List[_EntityT]: ...

@overload
def list(self: Repo, *, return_json: Literal[True] = False) -> List[Any]:
...
def list(self: Repo, *, return_json: Literal[True] = False) -> List[Any]: ...

def list(self: Repo, *, return_json: bool = False) -> List[Union[_EntityT, Any]]:
"""
Expand All @@ -166,8 +163,7 @@ def list(self: Repo, *, return_json: bool = False) -> List[Union[_EntityT, Any]]

class ModelUpdateMixin(ABC, Generic[IModel]):
@property
def _model_partial_update_arg(self: Entity) -> str:
...
def _model_partial_update_arg(self: Entity) -> str: ...

def _export_update_fields(
self: Entity, overrides: Optional[Union[Dict[str, Any], IModel]] = None
Expand Down
8 changes: 4 additions & 4 deletions cvat-sdk/cvat_sdk/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def filter_dict(


@overload
def atomic_writer(path: Union[os.PathLike, str], mode: Literal["wb"]) -> ContextManager[BinaryIO]:
...
def atomic_writer(
path: Union[os.PathLike, str], mode: Literal["wb"]
) -> ContextManager[BinaryIO]: ...


@overload
def atomic_writer(
path: Union[os.PathLike, str], mode: Literal["w"], encoding: str = "UTF-8"
) -> ContextManager[TextIO]:
...
) -> ContextManager[TextIO]: ...


@contextlib.contextmanager
Expand Down
18 changes: 6 additions & 12 deletions cvat-sdk/cvat_sdk/datasets/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ class UpdatePolicy(Enum):

class _CacheObjectModel(metaclass=ABCMeta):
@abstractmethod
def dump(self) -> _CacheObject:
...
def dump(self) -> _CacheObject: ...

@classmethod
@abstractmethod
def load(cls, obj: _CacheObject):
...
def load(cls, obj: _CacheObject): ...


_ModelType = TypeVar("_ModelType", bound=Union[OpenApiModel, _CacheObjectModel])
Expand Down Expand Up @@ -115,8 +113,7 @@ def save_model(self, path: Path, model: _ModelType) -> None:
return self._save_object(path, self._serialize_model(model))

@abstractmethod
def retrieve_task(self, task_id: int) -> Task:
...
def retrieve_task(self, task_id: int) -> Task: ...

@abstractmethod
def ensure_task_model(
Expand All @@ -126,16 +123,13 @@ def ensure_task_model(
model_type: Type[_ModelType],
downloader: Callable[[], _ModelType],
model_description: str,
) -> _ModelType:
...
) -> _ModelType: ...

@abstractmethod
def ensure_chunk(self, task: Task, chunk_index: int) -> None:
...
def ensure_chunk(self, task: Task, chunk_index: int) -> None: ...

@abstractmethod
def retrieve_project(self, project_id: int) -> Project:
...
def retrieve_project(self, project_id: int) -> Project: ...


class _CacheManagerOnline(CacheManager):
Expand Down
1 change: 0 additions & 1 deletion cvat-sdk/gen/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# can't have a dependency on base.txt, because it depends on the generated file

black>=22.1.0
inflection >= 0.5.1
isort>=5.10.1
ruamel.yaml>=0.17.21
6 changes: 2 additions & 4 deletions cvat/apps/analytics_report/report/primary_metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ def is_filterable_by_date(cls):
return cls._is_filterable_by_date

@abstractmethod
def calculate(self):
...
def calculate(self): ...

@abstractmethod
def get_empty(self):
...
def get_empty(self): ...

def _make_clickhouse_query(self, parameters):
return make_clickhouse_query(query=self._query, parameters=parameters)
Expand Down
16 changes: 9 additions & 7 deletions cvat/apps/quality_control/quality_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,15 @@ def from_dict(cls, d: dict):
}
return cls(
**{field: d[field] for field in optional_fields if field in d},
**dict(
conflicts_by_type={
AnnotationConflictType(k): v for k, v in d["conflicts_by_type"].items()
}
)
if "conflicts_by_type" in d
else {},
**(
dict(
conflicts_by_type={
AnnotationConflictType(k): v for k, v in d["conflicts_by_type"].items()
}
)
if "conflicts_by_type" in d
else {}
),
conflicts=[AnnotationConflict.from_dict(v) for v in d["conflicts"]],
annotations=ComparisonReportAnnotationsSummary.from_dict(d["annotations"]),
annotation_components=ComparisonReportAnnotationComponentsSummary.from_dict(
Expand Down
2 changes: 1 addition & 1 deletion cvat/requirements/development.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r base.in

black==23.3.0
black>=24.1
django-extensions==3.0.8
django-silk==5.0.3
pylint-django==2.5.3
Expand Down
4 changes: 2 additions & 2 deletions cvat/requirements/development.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:c976e8cb5c96afe9ebe284d9b4dcf8019f55140e
# SHA1:27238f2f377debba1b5fe910878f0cc0cfaf6e7d
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -10,7 +10,7 @@ astroid==2.11.7
# via pylint
autopep8==2.0.4
# via django-silk
black==23.3.0
black==24.1.1
# via -r cvat/requirements/development.in
dill==0.3.7
# via pylint
Expand Down
1 change: 0 additions & 1 deletion site/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
black>=22.1.0
gitpython
inflection >= 0.5.1
isort>=5.10.1
Expand Down
6 changes: 3 additions & 3 deletions tests/python/rest_api/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,9 +1266,9 @@ def _create_task_with_cloud_data(
"image_quality": 75,
"use_cache": use_cache,
"cloud_storage_id": cloud_storage["id"],
"server_files": server_files
if not use_manifest
else server_files + ["test/manifest.jsonl"],
"server_files": (
server_files if not use_manifest else server_files + ["test/manifest.jsonl"]
),
"sorting_method": sorting_method,
}
if server_files_exclude:
Expand Down
3 changes: 1 addition & 2 deletions tests/python/rest_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class CollectionSimpleFilterTestBase(metaclass=ABCMeta):
cmp_ignore_keys: List[str] = ["updated_date"]

@abstractmethod
def _get_endpoint(self, api_client: ApiClient) -> Endpoint:
...
def _get_endpoint(self, api_client: ApiClient) -> Endpoint: ...

def _retrieve_collection(self, **kwargs) -> List:
kwargs["return_json"] = True
Expand Down

0 comments on commit b4eed78

Please sign in to comment.