Add black, isort and pyright checks to CI job (#2)

This commit is contained in:
Patryk 2022-06-04 15:10:25 +02:00 committed by GitHub
parent 013e326a30
commit 325e56fab4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 6 deletions

30
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,30 @@
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Set up Python 3
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Poetry
run: curl https://install.python-poetry.org | python -
- name: Install dependencies
run: poetry install
- name: Run black
run: poetry run python -m black --check --diff .
- name: Run isort
run: poetry run python -m isort --check-only --diff .
- name: Run pyright
run: poetry run python -m pyright --warnings

4
.gitignore vendored
View file

@ -1,2 +1,4 @@
.env
__pycache__/
.env
.venv/
.pytest_cache/

37
poetry.lock generated
View file

@ -112,7 +112,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "discord.py"
version = "2.0.0a4320+g06c1f44d"
version = "2.0.0a4321+gf6a74f74"
description = "A Python wrapper for the Discord API"
category = "main"
optional = false
@ -132,7 +132,7 @@ voice = ["PyNaCl (>=1.3.0,<1.6)"]
type = "git"
url = "https://github.com/Rapptz/discord.py"
reference = "master"
resolved_reference = "06c1f44d749fa66b3b276adb7ee5616922112aaa"
resolved_reference = "f6a74f74a7aed0879fc086805eae8873e745d0ea"
[[package]]
name = "frozenlist"
@ -188,6 +188,14 @@ category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "nodeenv"
version = "1.6.0"
description = "Node.js virtual environment builder"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "packaging"
version = "21.3"
@ -250,6 +258,21 @@ python-versions = ">=3.6.8"
[package.extras]
diagrams = ["railroad-diagrams", "jinja2"]
[[package]]
name = "pyright"
version = "1.1.251"
description = "Command line wrapper for pyright"
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
nodeenv = ">=1.6.0"
[package.extras]
all = ["twine (>=3.4.1)"]
dev = ["twine (>=3.4.1)"]
[[package]]
name = "pytest"
version = "7.1.2"
@ -305,7 +328,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "db997c1a69459917f3164f71d6b1d9629f6bebd4069f5f3f9d5934404825bf2f"
content-hash = "84b2ddf247dc861d1f82ae652853c4acfd5e91f85f60ee825e25c8b09a058f45"
[metadata.files]
aiohttp = [
@ -574,6 +597,10 @@ mypy-extensions = [
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
]
nodeenv = [
{file = "nodeenv-1.6.0-py2.py3-none-any.whl", hash = "sha256:621e6b7076565ddcacd2db0294c0381e01fd28945ab36bcf00f41c5daf63bef7"},
{file = "nodeenv-1.6.0.tar.gz", hash = "sha256:3ef13ff90291ba2a4a7a4ff9a979b63ffdd00a464dbe04acf0ea6471517a4c2b"},
]
packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
@ -598,6 +625,10 @@ pyparsing = [
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
]
pyright = [
{file = "pyright-1.1.251-py3-none-any.whl", hash = "sha256:ca71506d492500496236f568fa85091964f2376f070882f88c372e68261d5f8e"},
{file = "pyright-1.1.251.tar.gz", hash = "sha256:c0cc328dd8a7b6f1c120b16091e04f17912eda04d3328518dd6acded091b2f2d"},
]
pytest = [
{file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},

View file

@ -15,6 +15,7 @@ python-dotenv = "^0.20.0"
[tool.poetry.dev-dependencies]
black = "^22.3.0"
isort = "^5.10.1"
pyright = "^1.1.251"
pytest = "^7.1.2"
[tool.black]
@ -26,6 +27,10 @@ skip-magic-trailing-comma = true
profile = "black"
line_length = 100
[tool.pyright]
typeCheckingMode = "basic"
reportUnnecessaryTypeIgnoreComment = "warning"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

View file

@ -5,13 +5,13 @@ class DeleteButton(discord.ui.View):
def __init__(self, invoker: discord.User | discord.Member) -> None:
super().__init__(timeout=10)
self.invoker = invoker
self.message: discord.Message | None = None
self.message: discord.Message
async def interaction_check(self, interaction: discord.Interaction) -> bool:
if (
interaction.user == self.invoker
or isinstance(interaction.user, discord.Member)
and interaction.user.resolved_permissions.manage_messages
and interaction.user.resolved_permissions.manage_messages # pyright: ignore [reportOptionalMemberAccess]
):
return True