Skip to content

Commit

Permalink
Bugfix/modify mypy ci (Pycord-Development#789)
Browse files Browse the repository at this point in the history
* Fix: mypy fatal errors (error: Invalid "type: ignore" comment)

* Add mypy.ini - ignore_errors

* Fix mypy ci returning always true

* Fix typo
  • Loading branch information
pollenjp authored Jan 22, 2022
1 parent 5244381 commit d287816
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
- run: pip install mypy
- run: pip install -r requirements.txt
- run: mkdir --parents --verbose .mypy_cache
- run: mypy --ignore-missing-imports --install-types --non-interactive . || true
- run: mypy --ignore-missing-imports --install-types --non-interactive .
10 changes: 5 additions & 5 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def __call__(self, ctx, *args, **kwargs):
def _prepare_cooldowns(self, ctx: ApplicationContext):
if self._buckets.valid:
current = datetime.datetime.now().timestamp()
bucket = self._buckets.get_bucket(ctx, current) # type: ignore (ctx instead of non-existent message)
bucket = self._buckets.get_bucket(ctx, current) # type: ignore # ctx instead of non-existent message

if bucket is not None:
retry_after = bucket.update_rate_limit(current)
Expand All @@ -183,14 +183,14 @@ async def prepare(self, ctx: ApplicationContext) -> None:
if hasattr(self, "_max_concurrency"):
if self._max_concurrency is not None:
# For this application, context can be duck-typed as a Message
await self._max_concurrency.acquire(ctx) # type: ignore (ctx instead of non-existent message)
await self._max_concurrency.acquire(ctx) # type: ignore # ctx instead of non-existent message

try:
self._prepare_cooldowns(ctx)
await self.call_before_hooks(ctx)
except:
if self._max_concurrency is not None:
await self._max_concurrency.release(ctx) # type: ignore (ctx instead of non-existent message)
await self._max_concurrency.release(ctx) # type: ignore # ctx instead of non-existent message
raise

def is_on_cooldown(self, ctx: ApplicationContext) -> bool:
Expand Down Expand Up @@ -226,7 +226,7 @@ def reset_cooldown(self, ctx: ApplicationContext) -> None:
The invocation context to reset the cooldown under.
"""
if self._buckets.valid:
bucket = self._buckets.get_bucket(ctx) # type: ignore (ctx instead of non-existent message)
bucket = self._buckets.get_bucket(ctx) # type: ignore # ctx instead of non-existent message
bucket.reset()

def get_cooldown_retry_after(self, ctx: ApplicationContext) -> float:
Expand Down Expand Up @@ -630,7 +630,7 @@ def _match_option_param_names(self, params, options):
check_annotations = [
lambda o, a: o.input_type == SlashCommandOptionType.string and o.converter is not None, # pass on converters
lambda o, a: isinstance(o.input_type, SlashCommandOptionType), # pass on slash cmd option type enums
lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o._raw_type], # type: ignore (union types)
lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o._raw_type], # type: ignore # union types
lambda o, a: self._is_typing_optional(a) and not o.required and o._raw_type in a.__args__, # optional
lambda o, a: inspect.isclass(a) and issubclass(a, o._raw_type) # 'normal' types
]
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_errors = True

0 comments on commit d287816

Please sign in to comment.