Skip to content

Commit

Permalink
Merge pull request #964 from ods/ruff
Browse files Browse the repository at this point in the history
Use ruff for linting and formatting
  • Loading branch information
ods authored Jan 21, 2024
2 parents 2cbeee6 + 04aa839 commit 935ce1c
Show file tree
Hide file tree
Showing 77 changed files with 4,482 additions and 3,698 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Lint code
run: |
make flake
make lint
- name: Check readme for package
run: |
Expand Down
34 changes: 19 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,56 @@ DOCKER_IMAGE=aiolibs/kafka:$(SCALA_VERSION)_$(KAFKA_VERSION)
DIFF_BRANCH=origin/master
FORMATTED_AREAS=aiokafka/util.py aiokafka/structs.py

.PHONY: setup
setup:
pip install -r requirements-dev.txt
pip install -Ue .

.PHONY: format
format:
isort $(FORMATTED_AREAS) setup.py
black $(FORMATTED_AREAS) setup.py
ruff format aiokafka tests setup.py
ruff check --fix aiokafka tests setup.py

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

test: flake
.PHONY: test
test: lint
pytest -s --show-capture=no --docker-image $(DOCKER_IMAGE) $(FLAGS) tests

vtest: flake
.PHONY: vtest
vtest: lint
pytest -s -v --log-level INFO --docker-image $(DOCKER_IMAGE) $(FLAGS) tests

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

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

.PHONY: ci-test-all
ci-test-all:
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

coverage.xml: .coverage
coverage xml

.PHONY: diff-cov
diff-cov: coverage.xml
git fetch
diff-cover coverage.xml --html-report diff-cover.html --compare-branch=$(DIFF_BRANCH)

.PHONY: check-readme
check-readme:
python setup.py check -rms

.PHONY: clean
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
Expand All @@ -72,8 +77,7 @@ clean:
rm -f aiokafka/record/_crecords/memory_records.c
rm -f aiokafka/record/_crecords/*.html

.PHONY: doc
doc:
make -C docs html
@echo "open file://`pwd`/docs/_build/html/index.html"

.PHONY: all flake test vtest cov clean doc
17 changes: 11 additions & 6 deletions aiokafka/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
__version__ = '0.10.0' # noqa
__version__ = "0.10.0" # noqa

from .abc import ConsumerRebalanceListener
from .client import AIOKafkaClient
from .consumer import AIOKafkaConsumer
from .errors import ConsumerStoppedError, IllegalOperation
from .producer import AIOKafkaProducer
from .structs import (
TopicPartition, ConsumerRecord, OffsetAndTimestamp, OffsetAndMetadata
ConsumerRecord,
OffsetAndMetadata,
OffsetAndTimestamp,
TopicPartition,
)


__all__ = [
# Clients API
"AIOKafkaProducer",
"AIOKafkaConsumer",
# ABC's
"ConsumerRebalanceListener",
# Errors
"ConsumerStoppedError", "IllegalOperation",
"ConsumerStoppedError",
"IllegalOperation",
# Structs
"ConsumerRecord", "TopicPartition", "OffsetAndTimestamp",
"OffsetAndMetadata"
"ConsumerRecord",
"TopicPartition",
"OffsetAndTimestamp",
"OffsetAndMetadata",
]

AIOKafkaClient
2 changes: 1 addition & 1 deletion aiokafka/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@ def extensions(self):

__all__ = [
"ConsumerRebalanceListener",
"AbstractTokenProvider"
"AbstractTokenProvider",
]
Loading

0 comments on commit 935ce1c

Please sign in to comment.