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: remove black #3437

Merged
merged 13 commits into from
Apr 12, 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
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"dbaeumer.vscode-eslint",
"matangover.mypy",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/partial-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
id: cache-validate
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
run: |
echo "import black;print('venv good?')" > test.py && poetry run python test.py && echo "cache-hit-success=true" >> $GITHUB_OUTPUT
echo "import fastapi;print('venv good?')" > test.py && poetry run python test.py && echo "cache-hit-success=true" >> $GITHUB_OUTPUT
rm test.py
continue-on-error: true

Expand All @@ -78,9 +78,9 @@ jobs:
poetry add "psycopg2-binary==2.9.9"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' || steps.cache-validate.outputs.cache-hit-success != 'true'

- name: Formatting (Black)
- name: Formatting (Ruff)
run: |
poetry run black . --check
poetry run ruff format . --check

- name: Lint (Ruff)
run: |
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: ^tests/data/
- repo: https://github.com/psf/black
rev: 24.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.5
hooks:
- id: black
- id: ruff-format
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,5 @@
},
"[vue]": {
"editor.formatOnSave": false
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
},
}
}
9 changes: 8 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ tasks:
desc: run code generators
cmds:
- poetry run python dev/code-generation/main.py
- task: py:format

dev:services:
desc: starts postgres and mailpit containers
Expand Down Expand Up @@ -105,7 +106,7 @@ tasks:
py:format:
desc: runs python code formatter
cmds:
- poetry run black mealie
- poetry run ruff format .

py:lint:
desc: runs python linter
Expand Down Expand Up @@ -146,6 +147,12 @@ tasks:
cmds:
- poetry run python mealie/app.py

py:migrate:
desc: generates a new migration file e.g. task py:migrate:generate "add new column"
cmds:
- poetry run alembic revision --autogenerate -m "{{ .CLI_ARGS }}"
- task: py:format

Comment on lines +150 to +155
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-genson should auto-format alembic migrations and make it easier to run them.

ui:build:
desc: builds the frontend in frontend/dist
dir: frontend
Expand Down
12 changes: 0 additions & 12 deletions alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,3 @@ sqlalchemy.url =
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

hooks = isort, black

# format using "isort" - use the console_scripts runner, against the "isort" entrypoint
isort.type = console_scripts
isort.entrypoint = isort
isort.options = REVISION_SCRIPT_FILENAME

# format using "black" - use the console_scripts runner, against the "black" entrypoint
black.type = console_scripts
black.entrypoint = black
black.options = REVISION_SCRIPT_FILENAME
5 changes: 0 additions & 5 deletions dev/code-generation/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from dataclasses import dataclass
from pathlib import Path

import black
import isort
from jinja2 import Template
from rich.logging import RichHandler

Expand All @@ -23,10 +21,7 @@ def render_python_template(template_file: Path | str, dest: Path, data: dict):

text = tplt.render(data=data)

text = black.format_str(text, mode=black.FileMode())

dest.write_text(text)
isort.file(dest)


@dataclass
Expand Down
63 changes: 1 addition & 62 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pillow-heif = "^0.16.0"
psycopg2-binary = { version = "^2.9.1" }

[tool.poetry.group.dev.dependencies]
black = "^24.0.0"
coverage = "^7.0"
coveragepy-lcov = "^0.1.1"
mkdocs-material = "^9.0.0"
Expand All @@ -76,13 +75,6 @@ types-urllib3 = "^1.26.11"
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]

[tool.black]
line-length = 120
target-version = ["py310"]

[tool.isort]
line_length = 120

[tool.vulture]
exclude = ["**/models/**/*.py", "dir/"]
ignore_decorators = ["@*router.*", "@app.on_event", "@field_validator", "@controller"]
Expand Down
Loading
Loading