Skip to content

Commit 1876400

Browse files
authored
feat: 83 replace poetry co by uv and ruff (#91)
* modify makefile * add uv * remove poetry * modify pyproject.toml and remove other config files * modify pyproject.toml and remove other config files * modify auto format with ruff linting * fix project.toml * add ignore linting rules to have the same result like before with pylint. * add uv add ... --dev to makefile. dependencies are going to be installed if not there by default * add py.typed and add to pyproject.toml * fix typo issues * modify github action. migrate poetry to uv * modify github action uv migration * fix uv migration in github action package dependencies * Udpate pytest -> 8.4.0 and aiohttp -> 3.12.11 * add editorconfig in pyproject.toml * modify exceptions * fix exception message * remove unnecessary test files * remove manually uv packages in github action * remove comments * remove blank lines * fix short to long * fixing short to long, remove empty lines and manually packages * add points. * misspelling fixed * add blank line * remove comments __hash__ * remove comments and qa first, help remove * fix issues * add clean to Makefile * remove poetry.lock * fix comments * remove ruff all to the more practical rules * remove linter issues * fix linting
1 parent 3b361ab commit 1876400

Some content is hidden

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

61 files changed

+1755
-971
lines changed

.editorconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_size = 2
7-
indent_style = tab
86
insert_final_newline = true
9-
tab_width = 2
107
trim_trailing_whitespace = true
8+
indent_style = tab
9+
indent_size = 2
10+
tab_width = 2
1111

1212
[*.py]
1313
indent_style = space

.github/workflows/qa.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
python-version: ${{ matrix.version }}
2222
- name: Install dependencies
2323
run: |
24-
pip install poetry
25-
poetry install
24+
curl --location --silent --show-error --fail https://astral.sh/uv/install.sh | sh
25+
export PATH="$HOME/.local/bin:$PATH"
26+
uv sync --dev
2627
- name: Run QA
2728
run: make qa

.github/workflows/release.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ jobs:
2727
python-version: '3.13'
2828
- name: Install dependencies
2929
run: |
30-
# First install Poetry in latest version, then install
31-
# build and twine in matching versions. The following
32-
# commands should not be run in a single line.
33-
pip install poetry
34-
pip install build twine
35-
poetry install
30+
curl --location --silent --show-error --fail https://astral.sh/uv/install.sh | sh
31+
export PATH="$HOME/.local/bin:$PATH"
32+
uv sync --dev
3633
- name: Run QA
3734
run: make qa
3835
- name: Get next version

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Python folders
22
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
*.egg-info/
7+
*.egg/
8+
.pytest_cache/
9+
.mypy_cache/
10+
.ruff_cache/
11+
.pytype/
12+
13+
# Package managers
14+
.uv/
15+
__pypackages__/
16+
pip-wheel-metadata/
17+
18+
# Virtual environments
19+
venv/
20+
env/
21+
.venv/
22+
.env/
23+
24+
# Build and distribution
25+
build/
26+
dist/
27+
28+
# Testing and coverage
29+
.coverage
30+
.coverage.*
31+
htmlcov/
32+
.tox/
333

434
# OS generated files and folders
535
.DS_Store

.pylintrc

Lines changed: 0 additions & 39 deletions
This file was deleted.

Makefile

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,64 @@
1-
qa: analyze test
1+
PACKAGE := eventsourcingdb
2+
TEST_DIR := tests
3+
PYTHON_DIRS := $(PACKAGE) $(TEST_DIR)
4+
5+
qa: analyze typecheck security test
26

37
analyze:
4-
@poetry run pylint eventsourcingdb tests
8+
@echo "Running code analysis..."
9+
@uv run ruff check $(PYTHON_DIRS)
10+
11+
build: qa clean
12+
@echo "Build prepared."
13+
14+
clean:
15+
@echo "Cleaning up..."
16+
@find . -type d -name __pycache__ -exec rm -rf {} +
17+
@find . -type f -name "*.pyc" -delete
18+
@find . -type f -name "*.pyo" -delete
19+
@find . -type f -name "*.pyd" -delete
20+
@find . -type f -name ".coverage" -delete
21+
@find . -type d -name "*.egg-info" -exec rm -rf {} +
22+
@find . -type d -name "*.egg" -exec rm -rf {} +
23+
@find . -type d -name ".pytest_cache" -exec rm -rf {} +
24+
@find . -type d -name ".mypy_cache" -exec rm -rf {} +
25+
@find . -type d -name ".pyright" -exec rm -rf {} +
26+
@find . -type d -name ".ruff_cache" -exec rm -rf {} +
27+
@rm -rf build/ dist/ .coverage htmlcov/ .venv/
28+
29+
coverage:
30+
@echo "Checking test coverage..."
31+
@uv run pytest --cov=$(PACKAGE) --cov-report=term-missing $(TEST_DIR)
532

633
format:
7-
@poetry run autopep8 --in-place --aggressive --max-line-length=100 --recursive eventsourcingdb tests
8-
34+
@echo "Formatting code..."
35+
@uv run ruff format $(PYTHON_DIRS)
36+
937
lock:
10-
@poetry lock
38+
@echo "Updating dependency lock..."
39+
@uv run uv lock
1140

12-
test:
13-
@poetry run pytest --maxfail=1
41+
security:
42+
@echo "Running security checks..."
43+
@uv run bandit -r $(PACKAGE) -c pyproject.toml
1444

15-
clean:
45+
test:
46+
@echo "Running tests..."
47+
@uv run pytest --maxfail=1
1648

17-
build: qa clean
49+
typecheck:
50+
@uv add pyright --dev
51+
@echo "Running type checking..."
52+
@uv run pyright $(PACKAGE)
1853

19-
.PHONY: analyze build clean format lock qa test
54+
.PHONY: analyze \
55+
build \
56+
coverage \
57+
format \
58+
help \
59+
lock \
60+
qa \
61+
security \
62+
test \
63+
typecheck \
64+
clean

eventsourcingdb/__init__.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
from .bound import Bound, BoundType
22
from .client import Client
33
from .container import Container
4-
from .event import Event, EventCandidate
54
from .errors import ClientError, CustomError, InternalError, ServerError, ValidationError
5+
from .event import Event, EventCandidate
66
from .observe_events import (
7+
IfEventIsMissingDuringObserve,
78
ObserveEventsOptions,
89
ObserveFromLatestEvent,
9-
IfEventIsMissingDuringObserve
1010
)
11-
from .read_events import ReadEventsOptions, ReadFromLatestEvent, IfEventIsMissingDuringRead, Order
1211
from .read_event_types import EventType
13-
from .write_events import Precondition, IsSubjectOnEventId, IsSubjectPristine
14-
12+
from .read_events import IfEventIsMissingDuringRead, Order, ReadEventsOptions, ReadFromLatestEvent
13+
from .write_events import IsSubjectOnEventId, IsSubjectPristine, Precondition
1514

1615
__all__ = [
17-
'Bound', 'BoundType',
18-
'Client',
19-
'Container',
20-
'Event', 'EventCandidate',
21-
'EventType',
22-
'ObserveEventsOptions', 'ObserveFromLatestEvent', 'IfEventIsMissingDuringObserve',
23-
'Precondition', 'IsSubjectOnEventId', 'IsSubjectPristine',
24-
'ReadEventsOptions', 'ReadFromLatestEvent', 'IfEventIsMissingDuringRead', 'Order',
25-
'ClientError', 'CustomError', 'InternalError', 'ServerError', 'ValidationError',
16+
"Bound",
17+
"BoundType",
18+
"Client",
19+
"ClientError",
20+
"Container",
21+
"CustomError",
22+
"Event",
23+
"EventCandidate",
24+
"EventType",
25+
"IfEventIsMissingDuringObserve",
26+
"IfEventIsMissingDuringRead",
27+
"InternalError",
28+
"IsSubjectOnEventId",
29+
"IsSubjectPristine",
30+
"ObserveEventsOptions",
31+
"ObserveFromLatestEvent",
32+
"Order",
33+
"Precondition",
34+
"ReadEventsOptions",
35+
"ReadFromLatestEvent",
36+
"ServerError",
37+
"ValidationError",
2638
]

eventsourcingdb/bound.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ class Bound:
1313
type: BoundType
1414

1515
def to_json(self) -> dict[str, str]:
16-
return {
17-
'id': self.id,
18-
'type': self.type.value
19-
}
16+
return {"id": self.id, "type": self.type.value}

0 commit comments

Comments
 (0)