Skip to content

Commit 935ce1c

Browse files
authored
Merge pull request #964 from ods/ruff
Use ruff for linting and formatting
2 parents 2cbeee6 + 04aa839 commit 935ce1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4482
-3698
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
5757
- name: Lint code
5858
run: |
59-
make flake
59+
make lint
6060
6161
- name: Check readme for package
6262
run: |

Makefile

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,56 @@ DOCKER_IMAGE=aiolibs/kafka:$(SCALA_VERSION)_$(KAFKA_VERSION)
77
DIFF_BRANCH=origin/master
88
FORMATTED_AREAS=aiokafka/util.py aiokafka/structs.py
99

10+
.PHONY: setup
1011
setup:
1112
pip install -r requirements-dev.txt
1213
pip install -Ue .
1314

15+
.PHONY: format
1416
format:
15-
isort $(FORMATTED_AREAS) setup.py
16-
black $(FORMATTED_AREAS) setup.py
17+
ruff format aiokafka tests setup.py
18+
ruff check --fix aiokafka tests setup.py
1719

18-
flake: lint
20+
.PHONY: lint
1921
lint:
20-
black --check $(FORMATTED_AREAS) setup.py
21-
@if ! isort -c $(FORMATTED_AREAS) setup.py; then \
22-
echo "Import sort errors, run 'make format' to fix them!!!"; \
23-
isort --diff --color $(FORMATTED_AREAS) setup.py; \
24-
false; \
25-
fi
26-
flake8 aiokafka tests setup.py
22+
ruff format --check aiokafka tests setup.py
23+
ruff check aiokafka tests setup.py
2724
mypy --install-types --non-interactive $(FORMATTED_AREAS)
2825

29-
test: flake
26+
.PHONY: test
27+
test: lint
3028
pytest -s --show-capture=no --docker-image $(DOCKER_IMAGE) $(FLAGS) tests
3129

32-
vtest: flake
30+
.PHONY: vtest
31+
vtest: lint
3332
pytest -s -v --log-level INFO --docker-image $(DOCKER_IMAGE) $(FLAGS) tests
3433

35-
cov cover coverage: flake
34+
.PHONY: cov cover coverage
35+
cov cover coverage: lint
3636
pytest -s --cov aiokafka --cov-report html --docker-image $(DOCKER_IMAGE) $(FLAGS) tests
3737
@echo "open file://`pwd`/htmlcov/index.html"
3838

39+
.PHONY: ci-test-unit
3940
ci-test-unit:
4041
pytest -s --log-format="%(asctime)s %(levelname)s %(message)s" --log-level DEBUG --cov aiokafka --cov-report xml --color=yes $(FLAGS) tests
4142

43+
.PHONY: ci-test-all
4244
ci-test-all:
4345
pytest -s -v --log-format="%(asctime)s %(levelname)s %(message)s" --log-level DEBUG --cov aiokafka --cov-report xml --color=yes --docker-image $(DOCKER_IMAGE) $(FLAGS) tests
4446

4547
coverage.xml: .coverage
4648
coverage xml
4749

50+
.PHONY: diff-cov
4851
diff-cov: coverage.xml
4952
git fetch
5053
diff-cover coverage.xml --html-report diff-cover.html --compare-branch=$(DIFF_BRANCH)
5154

55+
.PHONY: check-readme
5256
check-readme:
5357
python setup.py check -rms
5458

59+
.PHONY: clean
5560
clean:
5661
rm -rf `find . -name __pycache__`
5762
rm -f `find . -type f -name '*.py[co]' `
@@ -72,8 +77,7 @@ clean:
7277
rm -f aiokafka/record/_crecords/memory_records.c
7378
rm -f aiokafka/record/_crecords/*.html
7479

80+
.PHONY: doc
7581
doc:
7682
make -C docs html
7783
@echo "open file://`pwd`/docs/_build/html/index.html"
78-
79-
.PHONY: all flake test vtest cov clean doc

aiokafka/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
__version__ = '0.10.0' # noqa
1+
__version__ = "0.10.0" # noqa
22

33
from .abc import ConsumerRebalanceListener
44
from .client import AIOKafkaClient
55
from .consumer import AIOKafkaConsumer
66
from .errors import ConsumerStoppedError, IllegalOperation
77
from .producer import AIOKafkaProducer
88
from .structs import (
9-
TopicPartition, ConsumerRecord, OffsetAndTimestamp, OffsetAndMetadata
9+
ConsumerRecord,
10+
OffsetAndMetadata,
11+
OffsetAndTimestamp,
12+
TopicPartition,
1013
)
1114

12-
1315
__all__ = [
1416
# Clients API
1517
"AIOKafkaProducer",
1618
"AIOKafkaConsumer",
1719
# ABC's
1820
"ConsumerRebalanceListener",
1921
# Errors
20-
"ConsumerStoppedError", "IllegalOperation",
22+
"ConsumerStoppedError",
23+
"IllegalOperation",
2124
# Structs
22-
"ConsumerRecord", "TopicPartition", "OffsetAndTimestamp",
23-
"OffsetAndMetadata"
25+
"ConsumerRecord",
26+
"TopicPartition",
27+
"OffsetAndTimestamp",
28+
"OffsetAndMetadata",
2429
]
2530

2631
AIOKafkaClient

aiokafka/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,5 @@ def extensions(self):
143143

144144
__all__ = [
145145
"ConsumerRebalanceListener",
146-
"AbstractTokenProvider"
146+
"AbstractTokenProvider",
147147
]

0 commit comments

Comments
 (0)