Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Ruff #7

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
"customizations": {
"vscode": {
"settings": {
"python.pythonPath": "/usr/local/bin/python",
// "python.linting.pylintPath": "/usr/local/bin/pylint",
// "python.linting.enabled": true,
"python.testing.pytestArgs": [
"tests",
"-vv"
],
"python.testing.unittestEnabled": true,
"python.testing.pytestEnabled": true,
"python.linting.pylintEnabled": true,
"python.analysis.typeCheckingMode": "basic"
"python.analysis.typeCheckingMode": "basic",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
},
"editor.formatOnSave": true
},
},
"extensions": [
"mhutchie.git-graph",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"-vv"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
}
}
19 changes: 4 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
RYE=rye
PYTEST=$(RYE) run pytest
MYPY=$(RYE) run mypy --ignore-missing-imports
BLACK=$(RYE) run black
ISORT=$(RYE) run isort
PYLINT=$(RYE) run pylint
UVICORN=$(RYE) run uvicorn
PACKAGE=dddpy

install:
sync:
$(RYE) sync
$(POETRY_EXPORT)

update:
$(POETRY) sync

test: install
$(MYPY) main.py ./${PACKAGE}/
$(PYTEST) -vv

fmt:
$(ISORT) main.py ./${PACKAGE} ./tests
$(BLACK) main.py ./${PACKAGE} ./tests
$(PYTEST) -vv

lint:
$(PYLINT) main.py ./${PACKAGE} ./tests
format:
$(RYE) run ruff format

dev:
${UVICORN} main:app --reload
5 changes: 4 additions & 1 deletion dddpy/infrastructure/sqlite/book/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .book_dto import BookDTO
from .book_query_service import BookQueryServiceImpl
from .book_repository import BookCommandUseCaseUnitOfWorkImpl, BookRepositoryImpl
from .book_repository import (
BookCommandUseCaseUnitOfWorkImpl,
BookRepositoryImpl,
)
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ def get_session() -> Iterator[Session]:
session.close()


def book_query_usecase(session: Session = Depends(get_session)) -> BookQueryUseCase:
def book_query_usecase(
session: Session = Depends(get_session),
) -> BookQueryUseCase:
"""Get a book query use case."""
book_query_service: BookQueryService = BookQueryServiceImpl(session)
return BookQueryUseCaseImpl(book_query_service)


def book_command_usecase(session: Session = Depends(get_session)) -> BookCommandUseCase:
def book_command_usecase(
session: Session = Depends(get_session),
) -> BookCommandUseCase:
"""Get a book command use case."""
book_repository: BookRepository = BookRepositoryImpl(session)
uow: BookCommandUseCaseUnitOfWork = BookCommandUseCaseUnitOfWorkImpl(
Expand Down
33 changes: 30 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,42 @@ build-backend = "hatchling.build"
[tool.rye]
managed = true
dev-dependencies = [
"black>=24.4.2",
"mypy>=1.11.0",
"pytest>=8.3.2",
"isort>=5.13.2",
"pylint>=3.2.6",
"ruff>=0.5.5",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["dddpy"]

[tool.ruff]
line-length = 88
indent-width = 4

target-version = "py312"

[lint]
select = ["E4", "E7", "E9", "F"]
ignore = []

fixable = ["ALL"]
unfixable = []

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
21 changes: 1 addition & 20 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ anyio==4.4.0
# via httpx
# via starlette
# via watchfiles
astroid==3.2.4
# via pylint
black==24.4.2
certifi==2024.7.4
# via httpcore
# via httpx
click==8.1.7
# via black
# via typer
# via uvicorn
dill==0.3.8
# via pylint
dnspython==2.6.1
# via email-validator
email-validator==2.2.0
Expand All @@ -53,30 +47,19 @@ idna==3.7
# via httpx
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via pylint
jinja2==3.1.4
# via fastapi
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.5
# via jinja2
mccabe==0.7.0
# via pylint
mdurl==0.1.2
# via markdown-it-py
mypy==1.11.0
mypy-extensions==1.0.0
# via black
# via mypy
packaging==24.1
# via black
# via pytest
pathspec==0.12.1
# via black
platformdirs==4.2.2
# via black
# via pylint
pluggy==1.5.0
# via pytest
pydantic==2.8.2
Expand All @@ -86,7 +69,6 @@ pydantic-core==2.20.1
# via pydantic
pygments==2.18.0
# via rich
pylint==3.2.6
pytest==8.3.2
python-dotenv==1.0.1
# via uvicorn
Expand All @@ -96,6 +78,7 @@ pyyaml==6.0.1
# via uvicorn
rich==13.7.1
# via typer
ruff==0.5.5
shellingham==1.5.4
# via typer
shortuuid==1.0.13
Expand All @@ -107,8 +90,6 @@ sqlalchemy==2.0.9
# via dddpy
starlette==0.37.2
# via fastapi
tomlkit==0.13.0
# via pylint
typer==0.12.3
# via fastapi-cli
typing-extensions==4.12.2
Expand Down