Skip to content

Commit d4923c0

Browse files
committed
fix the types
1 parent 135d723 commit d4923c0

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

.github/workflows/coverage_and_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
5959
id: install-deps
6060
run: |
61-
poetry install --without=dev --no-interaction
61+
poetry install --no-interaction
6262
6363
- name: Activate venv @ ${{ matrix.python-version }}
6464
run: |

core/checks.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
2222
"""
23+
from __future__ import annotations
24+
25+
from typing import TYPE_CHECKING, Any
26+
2327
from discord.ext import commands
2428

2529
import constants
26-
import core
30+
from core.context import GuildContext
31+
32+
33+
if TYPE_CHECKING:
34+
from discord.ext.commands._types import Check # type: ignore # why would this need stubs
2735

2836

29-
def is_role_or_higher(role_id: int):
30-
def predicate(ctx: core.Context):
37+
def is_role_or_higher(role_id: int) -> Check[Any]:
38+
def predicate(ctx: GuildContext) -> bool:
3139
role = ctx.guild.get_role(role_id)
3240

3341
# This should never be a problem, but just in case...
@@ -36,18 +44,12 @@ def predicate(ctx: core.Context):
3644
raise commands.CheckFailure(f"Role with ID <{role_id}> does not exist.")
3745

3846
ignored = (constants.Roles.NITRO_BOOSTER, constants.Roles.MUTED)
39-
roles = [
40-
r
41-
for r in ctx.author.roles
42-
if r.id not in ignored and ctx.author.top_role >= r
43-
]
47+
roles = [r for r in ctx.author.roles if r.id not in ignored and ctx.author.top_role >= r]
4448

4549
if roles:
4650
return True
4751

4852
# TODO: Change this to a custom exception.
49-
raise commands.CheckFailure(
50-
f"{ctx.author} is not in or higher than role <{role.name}(ID: {role.id})>."
51-
)
53+
raise commands.CheckFailure(f"{ctx.author} is not in or higher than role <{role.name}(ID: {role.id})>.")
5254

5355
return commands.check(predicate)

core/context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
__all__ = (
1313
"Context",
14+
"GuildContext",
1415
"Interaction",
1516
)
1617

@@ -19,3 +20,8 @@
1920

2021
class Context(commands.Context["Bot"]):
2122
pass
23+
24+
25+
class GuildContext(Context):
26+
guild: discord.Guild # type: ignore # type lie due to narrowing
27+
author: discord.Member # type: ignore # type lie due to narrowing

core/utils/paginator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from core.context import Context
3434

35+
3536
if TYPE_CHECKING:
3637
from typing_extensions import Self
3738

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ combine_star = true
3333

3434

3535
[tool.pyright]
36+
ignore = ["core/utils/paginator.py", "constants/_meta.py"] # TODO: Undo this when someone fixes the module lol
3637
useLibraryCodeForTypes = true
3738
typeCheckingMode = "strict"
3839
pythonVersion = "3.11"

0 commit comments

Comments
 (0)