Skip to content

Commit

Permalink
Changed from black to ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
Xithrius committed Oct 27, 2023
1 parent 3d598c0 commit d89c250
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 483 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: python-check-blanket-noqa

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.1
rev: v0.1.3
hooks:
- id: ruff

Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"source.fixAll.ruff": true,
"source.organizeImports.ruff": true
},
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
8 changes: 4 additions & 4 deletions api/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ output_encoding = utf-8
version_path_separator = os

[post_write_hooks]
hooks = black
black.type = console_scripts
black.entrypoint = black
black.options = -l 120 REVISION_SCRIPT_FILENAME
hooks = ruff
ruff.type = console_scripts
ruff.entrypoint = ruff format
ruff.options = -l 120 REVISION_SCRIPT_FILENAME

[loggers]
keys = root,sqlalchemy,alembic
Expand Down
6 changes: 1 addition & 5 deletions api/app/routers/deep_rock_galactic/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ async def remove_build(
session: Annotated[AsyncSession, Depends(get_db_session)],
id: int,
) -> DeepRockGalacticBuildModel:
stmt = (
delete(DeepRockGalacticBuildModel)
.where(DeepRockGalacticBuildModel.id == id)
.returning()
)
stmt = delete(DeepRockGalacticBuildModel).where(DeepRockGalacticBuildModel.id == id).returning()

items = await session.execute(stmt)

Expand Down
240 changes: 34 additions & 206 deletions api/pdm.lock

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ dependencies = [
"pillow>=10.0.1",
"croniter>=2.0.0",
"matplotlib>=3.8.0",
"docker>=6.1.3",
"prometheus-client>=0.17.1",
"prometheus-fastapi-instrumentator>=6.1.0",
]

[tool]
[tool.pdm]
[tool.pdm.dev-dependencies]
lint = ["ruff>=0.0.285"]
format = ["black>=23.7.0"]
lint-format = ["ruff>=0.1.3"]
precommit = ["pre-commit>=3.3.3"]
check = ["mypy>=1.6.0"]
test = [
"pytest>=7.4.0",
"anyio>=3.7.1",
Expand All @@ -47,11 +44,11 @@ test = [
[tool.pdm.scripts]
start = "python3 -m app"
lint = "pre-commit run --all-files"
fmt = "ruff format ."
precommit = "pre-commit install"
migrate = "alembic revision --autogenerate -m"
upgrade = "alembic upgrade head"
test = "pytest"
check = "mypy"

[build-system]
requires = ["pdm-pep517>=1.0.0"]
Expand Down
151 changes: 21 additions & 130 deletions pdm.lock

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

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ requires-python = ">=3.11"
dev = [
"-e file:///${PROJECT_ROOT}/xythrion",
"-e file:///${PROJECT_ROOT}/api",
"ruff>=0.0.285",
"ruff>=0.1.3",
"pre-commit>=3.3.3",
"black>=23.7.0",
]

[tool.pdm.scripts]
lint = "pre-commit run --all-files"
fmt = "ruff format ."
precommit = "pre-commit install"
test = "pytest"
5 changes: 4 additions & 1 deletion xythrion/bot/extensions/games/minecraft/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ async def mc(self, ctx: Context) -> None:

@mc.command()
async def distance(
self, ctx: Context, start: convert_3d_tuples, end: convert_3d_tuples,
self,
ctx: Context,
start: convert_3d_tuples,
end: convert_3d_tuples,
) -> None:
(x0, y0, z0), (x1, y1, z1) = start, end

Expand Down
5 changes: 4 additions & 1 deletion xythrion/bot/extensions/image_generation/gradient_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ async def gradient(

buffer = await asyncio.to_thread(
lambda: self.generate_gradient_image(
start, end, (size_h, size_v), gradient_direction,
start,
end,
(size_h, size_v),
gradient_direction,
),
)

Expand Down
3 changes: 2 additions & 1 deletion xythrion/bot/extensions/info/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ async def info(self, ctx: Context) -> None:
"""Information about bot origin."""
embed = Embed(
description=markdown_link(
desc="Xythrion Github Repository", link=GITHUB_URL,
desc="Xythrion Github Repository",
link=GITHUB_URL,
),
)

Expand Down
6 changes: 5 additions & 1 deletion xythrion/bot/extensions/third_party/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# TODO: Pydantic models


class CVE(Cog):
"""CVE information."""

Expand All @@ -18,7 +19,10 @@ def __init__(self, bot: Xythrion):

@staticmethod
def cve_embed_builder(
title: str, description: str, url: str, published: str,
title: str,
description: str,
url: str,
published: str,
) -> Embed:
embed = Embed(
title=title,
Expand Down
5 changes: 1 addition & 4 deletions xythrion/bot/extensions/third_party/mars_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ async def weather(self, ctx: Context) -> None:

try:
first_sol_checked = j["validity_checks"]["sols_checked"][0]
valid = any(
j["validity_checks"][first_sol_checked][x]["valid"]
for x in DATA_SECTIONS
)
valid = any(j["validity_checks"][first_sol_checked][x]["valid"] for x in DATA_SECTIONS)

if not valid:
err = True
Expand Down
6 changes: 5 additions & 1 deletion xythrion/bot/utils/gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

# https://github.com/nkmk/python-snippets/blob/master/notebook/numpy_generate_gradient_image.py
def gradient2(
start: int, stop: int, width: int, height: int, is_horizontal: bool,
start: int,
stop: int,
width: int,
height: int,
is_horizontal: bool,
) -> np.array:
if is_horizontal:
return np.tile(np.linspace(start, stop, width), (height, 1))
Expand Down
Loading

0 comments on commit d89c250

Please sign in to comment.