Skip to content

Commit

Permalink
Merge pull request #8 from albertsgarde/4-ci-with-static-checks
Browse files Browse the repository at this point in the history
4 ci with static checks
  • Loading branch information
albertsgarde authored Sep 27, 2024
2 parents de3e6d2 + 63278e3 commit 1ebec82
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 29 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: CI
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
branches:
- main
- ci-test

jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: CRLF endings
uses: erclu/check-crlf@v1

- name: Find trailing whitespace
uses: harupy/[email protected]

- name: Validate YAML files
run: yamllint . --strict

- name: Ruff
uses: chartboost/ruff-action@v1
with:
src: eadk_discord

- name: Mypy
uses: jashparekh/mypy-action@v2
with:
mypy_version: 1.11.2
requirement_files: requirements.txt requirements_dev.txt
python_version: '3.12'
17 changes: 13 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ repos:
hooks:
- id: yamlfmt

- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: [--strict]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand All @@ -31,16 +37,19 @@ repos:
- tomli

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
# Ruff version.
rev: v0.1.13
hooks:
# Run the linter.
# Run the linter.
- id: ruff
# Run the formatter.
# Run the formatter.
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies: [types-python-dateutil~=2.9.0]
additional_dependencies:
- types-python-dateutil~=2.9.0
- discord.py~=2.4.0
- pydantic~=2.9.1
5 changes: 1 addition & 4 deletions eadk_discord/bot_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ async def handle_date(
)
return None
booking_day, _ = database.day(booking_date)
if booking_day is None:
await interaction.response.send_message(f"Date {format_date(booking_date)} is too far in the future.")
return None
return booking_date, booking_day


Expand Down Expand Up @@ -376,7 +373,7 @@ async def syncglobal(ctx: Context) -> None:
logging.info(f"Synced {synced_commands} commands globally")

@bot.event
async def on_ready():
async def on_ready() -> None:
logging.info(f"We have logged in as {bot.user}")

@bot.tree.error
Expand Down
4 changes: 2 additions & 2 deletions eadk_discord/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class History(BaseModel):
def initialize(start_date: Date) -> "History":
return History(start_date=start_date, history=[])

def to_dict(self) -> dict[Any, Any]:
def to_dict(self) -> dict[str, Any]:
return self.model_dump()

def to_json(self) -> str:
Expand All @@ -28,5 +28,5 @@ def from_json(data: str) -> "History":
def from_dict(data: dict[Any, Any]) -> "History":
return History.model_validate(data)

def append(self, event: Event):
def append(self, event: Event) -> None:
self.history.append(event)
7 changes: 7 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mypy]
warn_unused_configs = True
disallow_untyped_defs = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
warn_unreachable = True
33 changes: 16 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "setuptools-scm"]

[project]
name = "eadk_discord"
version = "0.0.1"
authors = [{name = "albertsgarde", email = "[email protected]"}]
description = "A Discord bot the EADK discord server"
authors = [{ name = "albertsgarde", email = "[email protected]" }]
license = { file = "LICENSE" }
dynamic = ["dependencies", "optional-dependencies"]
license = {file = "LICENSE"}
name = "eadk_discord"
readme = "README.md"
requires-python = ">=3.11"
dynamic = ["dependencies", "optional-dependencies"]

[tool.setuptools]
packages = ["eadk_discord"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[tool.setuptools.dynamic.optional-dependencies]
dev = { file = ['requirements_dev.txt'] }
version = "0.0.1"

[tool.pytest.ini_options]
pythonpath = ["eadk_discord"]


[tool.ruff]
line-length = 120

[tool.ruff.lint]
select = ["I", "E", "F", "W", "N", "B"]
ignore = ["D203", "D213", "F722"]
select = ["I", "E", "F", "W", "N", "B"]
isort.known-first-party = ["eadk_discord"]

[tool.setuptools]
packages = ["eadk_discord"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools.dynamic.optional-dependencies]
dev = {file = ['requirements_dev.txt']}
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
discord.py ~= 2.4.0
pydantic ~= 2.9.1
aiocron == 1.8
beartype ~= 0.18.5
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ruff ~= 0.6.5
mypy ~= 1.11.2
pre-commit ~= 3.9.0
pre-commit ~= 3.8.0

0 comments on commit 1ebec82

Please sign in to comment.