Skip to content

Commit

Permalink
Use Black code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Inflianskas committed Mar 18, 2022
1 parent c46e429 commit ba9680f
Show file tree
Hide file tree
Showing 21 changed files with 703 additions and 579 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
max-line-length = 125
# These codes tend to disagree with yapf
ignore = E129,W503
# Whitespace before ':' (in accordance with Black)
extend-ignore = E203
max-complexity = 15
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
disable=
bad-continuation,
bad-option-value,
bad-whitespace, # Black deals with whitespace around operators and brackets
consider-using-f-string,
duplicate-code,
fixme,
Expand Down
55 changes: 0 additions & 55 deletions .style.yapf

This file was deleted.

10 changes: 0 additions & 10 deletions .yapfignore

This file was deleted.

18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ test: pytest
lint: flake8 mypy pylint

reformat:
$(PYTHON) -m isort --recursive $(PYTHON_DIRS)
yapf --parallel --recursive --in-place .
$(PYTHON) -m isort $(PYTHON_DIRS)
$(PYTHON) -m black $(PYTHON_DIRS)

validate-style:
$(eval CHANGES_BEFORE := $(shell mktemp))
Expand Down Expand Up @@ -47,8 +47,18 @@ clean:
$(RM) -r rpms

build-dep-fedora:
sudo dnf install -y --best --allowerasing python3-devel python3-flake8 python3-requests \
tar rpmdevtools python3-mypy python3-types-requests python3-pylint python3-isort python3-pytest
sudo dnf install -y --best --allowerasing \
black \
python3-devel \
python3-flake8 \
python3-isort \
python3-mypy \
python3-pylint \
python3-pytest \
python3-requests \
python3-types-requests \
rpmdevtools \
tar

.PHONY: rpm
rpm: $(RPM)
Expand Down
28 changes: 21 additions & 7 deletions aiven/client/argx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
from argparse import Action
from os import PathLike
from typing import (
Any, Callable, cast, Collection, Dict, List, Mapping, NoReturn, Optional, Sequence, TextIO, Tuple, Type, Union
Any,
Callable,
cast,
Collection,
Dict,
List,
Mapping,
NoReturn,
Optional,
Sequence,
TextIO,
Tuple,
Type,
Union,
)

import aiven.client.client
Expand Down Expand Up @@ -37,9 +50,9 @@
__version__ = "UNKNOWN"

# cached_property only exists since python 3.8
SKIP_EVALUATION_TYPES = (property, )
SKIP_EVALUATION_TYPES = (property,)
if (sys.version_info[:2] >= (3, 8)) and hasattr(functools, "cached_property"):
SKIP_EVALUATION_TYPES += (functools.cached_property, )
SKIP_EVALUATION_TYPES += (functools.cached_property,)

ARG_LIST_PROP = "_arg_list"
LOG_FORMAT = "%(levelname)s\t%(message)s"
Expand All @@ -55,8 +68,9 @@ def _get_help_string(self, action: Action) -> str:
argparse.OPTIONAL,
argparse.ZERO_OR_MORE,
]:
if (not isinstance(action.default, bool)
and isinstance(action.default, int)) or (isinstance(action.default, str) and action.default):
if (not isinstance(action.default, bool) and isinstance(action.default, int)) or (
isinstance(action.default, str) and action.default
):
help_text += " (default: %(default)s)"
return help_text

Expand All @@ -66,7 +80,7 @@ class UserError(Exception):


def arg(*args: Any, **kwargs: Any) -> Callable:
""" Declares an argument of an CLI command.
"""Declares an argument of an CLI command.
This decorator accepts the same arguments as `argparse.Parser::add_argument`.
Expand Down Expand Up @@ -161,7 +175,7 @@ def add_cmd(self, func: Callable) -> None:

subparsers = self.subparsers
for level in range(len(cats)):
cat = tuple(cats[:level + 1])
cat = tuple(cats[: level + 1])
if cat not in self._cats:
parser = subparsers.add_parser(
cat[-1],
Expand Down
Loading

0 comments on commit ba9680f

Please sign in to comment.