Skip to content

Commit

Permalink
pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Nov 8, 2023
1 parent 1e67711 commit d6a0fbe
Show file tree
Hide file tree
Showing 23 changed files with 259 additions and 57 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [main]
schedule:
- cron: '24 4 * * 5'
- cron: "24 4 * * 5"

jobs:
analyze:
Expand All @@ -32,40 +32,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
language: ["python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/config.toml
/data/
/html/
node_modules/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.0
hooks:
# blocks files larger than 500 KB
- id: check-added-large-files

# blocks files with leftover merge conflict markers
- id: check-merge-conflict

- id: no-commit-to-branch
name: Block commits to main branch

- repo: local
hooks:
- id: ruff
name: Lint files with ruff
args: [check, --target-version, py311, --fix, --show-fixes]
entry: ruff
language: system
types: [python]

- id: black
name: Format files with black
args: [-t, py311]
entry: black
language: system
types: [python]

- id: prettier
name: Format files with prettier
args: [prettier, -l, -u, -w]
entry: npx
exclude: \.py$
language: system
types: [text]
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
1 change: 0 additions & 1 deletion aethersprite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Aethersprite Discord bot/framework"""

# stdlib
from asyncio import new_event_loop
from importlib import import_module
import logging
from os import environ
Expand Down
2 changes: 1 addition & 1 deletion aethersprite/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# stdlib
from os import environ
from typing import Sequence, Union
from typing import Sequence

# 3rd party
from discord import DMChannel, Member, Role
Expand Down
4 changes: 0 additions & 4 deletions aethersprite/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
from typing import Any

# 3rd party
from discord.ext.commands import Context

# stdlib
from collections import namedtuple
from datetime import datetime, timezone
from functools import wraps
from math import ceil, floor
import re
from typing import Callable, Tuple

# constants
MINUTE = 60
Expand Down
4 changes: 2 additions & 2 deletions aethersprite/emotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

BUTTON_SUFFIX = "\ufe0f\u20e3"
CHECK_MARK = "\u2705"
POLICE_OFFICER = '\U0001F46E'
POLICE_OFFICER = "\U0001F46E"
PROHIBITED = "\U0001f6ab"
SHADE_BLOCK = "\u2591"
SOLID_BLOCK = "\u2588"
THUMBS_DOWN = '\U0001F44E'
THUMBS_DOWN = "\U0001F44E"
WASTEBASKET = "\U0001f5d1"
6 changes: 3 additions & 3 deletions aethersprite/extensions/base/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ async def add(self, ctx: Context, alias: str, command: str):
als = aliases[guild]

if alias in als:
await ctx.send(f":newspaper: Already exists.")
await ctx.send(":newspaper: Already exists.")

return

cmd = bot.get_command(command)

if cmd is None:
await ctx.send(f":scream: No such command!")
await ctx.send(":scream: No such command!")

return

als[alias] = command
aliases[guild] = als
log.info(f"{ctx.author} added alias {alias} for {command}")
await ctx.send(f":sunglasses: Done.")
await ctx.send(":sunglasses: Done.")

@command(name="alias.remove")
async def remove(self, ctx: Context, alias: str):
Expand Down
1 change: 0 additions & 1 deletion aethersprite/extensions/base/greet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# 3rd party
from discord import Member
from discord.channel import TextChannel
from discord.ext.commands import Bot

# filters
Expand Down
4 changes: 2 additions & 2 deletions aethersprite/extensions/base/only.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ async def add(
ourchan = ours[chan_id]

if command in ourchan:
await ctx.send(f":newspaper: Already done.")
await ctx.send(":newspaper: Already done.")

return

ourchan.add(command)
ours[chan_id] = ourchan
onlies[guild] = ours
log.info(f"{ctx.author} added {command} to {channel} whitelist")
await ctx.send(f":shield: Done.")
await ctx.send(":shield: Done.")

@command(name="only.remove")
async def remove(
Expand Down
3 changes: 0 additions & 3 deletions aethersprite/extensions/base/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

# 3rd party
from discord import Color, Embed, Message, Member
from discord.abc import GuildChannel
from discord.channel import TextChannel
from discord.ext.commands import check, command, Context
from discord.ext.commands.bot import Bot
from discord.guild import Guild
from discord.raw_models import RawReactionActionEvent
from sqlitedict import SqliteDict

Expand Down
5 changes: 2 additions & 3 deletions aethersprite/extensions/base/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
# stdlib
import asyncio as aio
from datetime import datetime, timedelta
from typing import Optional

# 3rd party
from discord import Color, Embed, Guild, Member, Message, TextChannel
from discord import Color, Embed, Message
from discord.errors import NotFound
from discord.ext.commands import Bot, check, command, Context
from discord.raw_models import RawReactionActionEvent
Expand Down Expand Up @@ -76,7 +75,7 @@ async def _get_message(
):
roles_: list[str] = settings["roles.catalog"].get(ctx)[:10] # type: ignore
embed = Embed(
title=f":billed_cap: Available roles",
title=":billed_cap: Available roles",
description="Use post reactions to manage role membership",
color=Color.purple(),
)
Expand Down
4 changes: 2 additions & 2 deletions aethersprite/extensions/base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ async def set(
return

if settings[name].set(ctx, value, channel=channel.id):
await ctx.send(f":thumbsup: Value updated.")
await ctx.send(":thumbsup: Value updated.")
log.info(
f"{ctx.author} updated setting {name}: {value} in {channel}"
)
else:
await ctx.send(f":thumbsdown: Error updating value.")
await ctx.send(":thumbsdown: Error updating value.")
log.warn(
f"{ctx.author} failed to update setting {name}: {value} "
f"in {channel}"
Expand Down
1 change: 0 additions & 1 deletion aethersprite/extensions/base/wipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# than x days old on a schedule

# typing
from typing import Optional

# 3rd party
from discord.ext.commands import Bot, check, command, Context
Expand Down
7 changes: 3 additions & 4 deletions aethersprite/extensions/base/yeet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Yeet cog"""

# stdlib
import typing

# 3rd party
from discord import DMChannel, TextChannel
Expand Down Expand Up @@ -53,13 +52,13 @@ async def add(
key = f"{server_key}#{channel.id}"
guild = str(ctx.guild.id)

if not ctx.guild.id in yeets:
if ctx.guild.id not in yeets:
yeets[guild] = set([])

ys = yeets[guild]

if (key in ys and not server) or (server_key in ys and server):
await ctx.send(f":newspaper: Already done.")
await ctx.send(":newspaper: Already done.")

return

Expand All @@ -75,7 +74,7 @@ async def add(
log.info(
f"{ctx.author} yeeted {server_key if server else key} in {ctx.channel}"
)
await ctx.send(f":boom: Yeet!")
await ctx.send(":boom: Yeet!")

@command(name="unyeet")
async def remove(
Expand Down
1 change: 0 additions & 1 deletion aethersprite/webapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# stdlib
from importlib import import_module
from inspect import ismodule

# 3rd party
from flask import Flask
Expand Down
Loading

0 comments on commit d6a0fbe

Please sign in to comment.