Skip to content

Commit

Permalink
build: migrate from black to ruff formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
natelandau committed Nov 11, 2023
1 parent aa99d7b commit d87d967
Show file tree
Hide file tree
Showing 48 changed files with 126 additions and 107 deletions.
12 changes: 3 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@ repos:
types: [python]

- repo: "https://github.com/adrienverge/yamllint.git"
rev: v1.32.0
rev: v1.33.0
hooks:
- id: yamllint
files: ^.*\.(yaml|yml)$
entry: yamllint --strict --config-file .yamllint.yml

- repo: "https://github.com/charliermarsh/ruff-pre-commit"
rev: "v0.1.4"
rev: "v0.1.5"
hooks:
- id: ruff
args: ["--extend-ignore", "I001,D301,D401"]
exclude: tests/
- id: ruff-format

- repo: "https://github.com/jendrikseipp/vulture"
rev: "v2.10"
Expand All @@ -87,13 +88,6 @@ repos:
pass_filenames: true
types: [text]

- id: black
name: black
entry: black
require_serial: true
language: system
types: [python]

- id: shellcheck
name: shellcheck
entry: shellcheck --check-sourced --severity=warning
Expand Down
89 changes: 19 additions & 70 deletions poetry.lock

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

9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,18 @@
pytest-xdist = "^3.3.1"

[tool.poetry.group.dev.dependencies]
black = "^23.11.0"
commitizen = "^3.12.0"
coverage = "^7.3.2"
mypy = "^1.6.1"
pdoc = "^14.0.0"
poethepoet = "^0.22.1"
pre-commit = "^3.5.0"
ruff = "^0.1.4"
ruff = "^0.1.5"
shellcheck-py = "^0.9.0.5"
types-aiofiles = "^23.2.0.0"
typos = "^1.16.23"
vulture = "^2.10"

[tool.black]
line-length = 100

[tool.commitizen]
bump_message = "bump(release): v$current_version → v$new_version"
changelog_merge_prerelease = true
Expand Down Expand Up @@ -192,6 +188,7 @@
"D413",
"E266",
"E501",
"ISC001",
"N805",
"PGH001",
"PGH003",
Expand Down Expand Up @@ -329,7 +326,7 @@
shell = "ruff --preview --no-fix src/"

[[tool.poe.tasks.lint.sequence]]
shell = "black --check src/ tests/"
shell = "ruff format --check src/ tests/"

[[tool.poe.tasks.lint.sequence]]
shell = "poetry check"
Expand Down
1 change: 1 addition & 0 deletions src/valentina/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Valentina version."""

__version__ = "2.0.0"
1 change: 1 addition & 0 deletions src/valentina/characters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Models for working with characters."""

from .add_from_sheet import AddFromSheetWizard
from .chargen import CharGenWizard, RNGCharGen
from .reallocate_dots import DotsReallocationWizard
Expand Down
1 change: 1 addition & 0 deletions src/valentina/characters/add_from_sheet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A wizard that walks the user through the character creation process."""

import asyncio
import uuid
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/valentina/characters/buttons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Buttons for character creation."""

from typing import cast

import discord
Expand Down
17 changes: 13 additions & 4 deletions src/valentina/characters/chargen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A RNG character generator for Valentina."""

import random
from typing import Literal, cast

Expand Down Expand Up @@ -94,7 +95,9 @@ def _disable_all(self) -> None:
row=2,
)
async def reroll_callback(
self, button: Button, interaction: discord.Interaction # noqa: ARG002
self,
button: Button, # noqa: ARG002
interaction: discord.Interaction,
) -> None:
"""Disable all buttons and stop the view."""
await interaction.response.defer()
Expand All @@ -109,7 +112,9 @@ async def reroll_callback(
row=2,
)
async def cancel_callback(
self, button: Button, interaction: discord.Interaction # noqa: ARG002
self,
button: Button, # noqa: ARG002
interaction: discord.Interaction,
) -> None:
"""Disable all buttons and stop the view."""
await interaction.response.defer()
Expand Down Expand Up @@ -220,7 +225,9 @@ def _disable_all(self) -> None:
row=2,
)
async def rename_callback(
self, button: Button, interaction: discord.Interaction # noqa: ARG002
self,
button: Button, # noqa: ARG002
interaction: discord.Interaction,
) -> None:
"""Callback for the rename button."""
self._disable_all()
Expand All @@ -240,7 +247,9 @@ async def rename_callback(
row=2,
)
async def reallocate_callback(
self, button: Button, interaction: discord.Interaction # noqa: ARG002
self,
button: Button, # noqa: ARG002
interaction: discord.Interaction,
) -> None:
"""Callback for the reallocate button."""
await interaction.response.defer()
Expand Down
1 change: 1 addition & 0 deletions src/valentina/characters/reallocate_dots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A wizard that walks the user through the character creation process."""

from typing import cast

import discord
Expand Down
4 changes: 3 additions & 1 deletion src/valentina/cogs/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="valid-type"
"""Administration commands for Valentina."""

from pathlib import Path

import discord
Expand Down Expand Up @@ -216,7 +217,8 @@ async def massban(
await assert_permissions(ctx, ban_members=True)
converter = MemberConverter()
converted_members = [
await converter.convert(ctx, member) for member in members.split() # type: ignore # mismatching context type
await converter.convert(ctx, member) # type: ignore # mismatching context type
for member in members.split()
]
if (count := len(converted_members)) > 10: # noqa: PLR2004
await present_embed(
Expand Down
4 changes: 3 additions & 1 deletion src/valentina/cogs/characters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="valid-type"
"""Character cog for Valentina."""

from pathlib import Path

import discord
Expand Down Expand Up @@ -234,7 +235,8 @@ async def list_characters(
) -> None:
"""List all player characters in this guild."""
all_characters = await Character.find_many(
Character.guild == ctx.guild.id, Character.type_player == True # noqa: E712
Character.guild == ctx.guild.id,
Character.type_player == True, # noqa: E712
).to_list()

if scope == "mine":
Expand Down
4 changes: 3 additions & 1 deletion src/valentina/cogs/developer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="valid-type"
"""Commands for bot development."""

from datetime import datetime
from pathlib import Path

Expand Down Expand Up @@ -183,7 +184,8 @@ async def delete_developer_characters(
) -> None:
"""Delete all developer characters from the database."""
dev_characters = await Character.find(
Character.type_developer == True, fetch_links=True # noqa: E712
Character.type_developer == True, # noqa: E712
fetch_links=True,
).to_list()

title = f"Delete `{len(dev_characters)}` developer {p.plural_noun('character', len(dev_characters))} characters from `{ctx.guild.name}`"
Expand Down
1 change: 1 addition & 0 deletions src/valentina/cogs/experience.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="valid-type"
"""Experience commands."""

import discord
import inflect
from discord.commands import Option
Expand Down
5 changes: 4 additions & 1 deletion src/valentina/cogs/help.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="valid-type"
"""Help Command for Valentina."""

from pathlib import Path

import discord
Expand Down Expand Up @@ -73,7 +74,9 @@ def __build_help_text(self, cmd: commands.Command) -> str:

@help.command(name="commands", description="Help information for Valentina's commands")
async def command_help(
self, ctx: ValentinaContext, command: Option(str, required=False) # type: ignore
self,
ctx: ValentinaContext,
command: Option(str, required=False), # type: ignore
) -> None:
"""Provide help information."""
commands = self.__build_command_list(ctx)
Expand Down
5 changes: 4 additions & 1 deletion src/valentina/cogs/misc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="valid-type"
"""Miscellaneous commands."""

import random

import arrow
Expand Down Expand Up @@ -102,7 +103,9 @@ async def server_info(
embed.add_field(
name="Roll Statistics",
value=await roll_stats.guild_statistics(
as_embed=False, with_title=False, with_help=True # type: ignore [arg-type]
as_embed=False,
with_title=False,
with_help=True, # type: ignore [arg-type]
),
inline=False,
)
Expand Down
1 change: 1 addition & 0 deletions src/valentina/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main file which instantiates the bot and runs it."""

import logging
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions src/valentina/models/aws.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Class for interacting with AWS services."""

from pathlib import Path

import boto3
Expand Down
1 change: 1 addition & 0 deletions src/valentina/models/character.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Character models for Valentina."""

from datetime import datetime
from typing import Optional, Union, cast

Expand Down
Loading

0 comments on commit d87d967

Please sign in to comment.