mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-108455: Run mypy
on Tools/peg_generator
(#108456)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
f75cefd402
commit
cf7ba83eb2
6 changed files with 23 additions and 11 deletions
|
@ -10,7 +10,6 @@ from typing import Any, Callable, ClassVar, Dict, Optional, Tuple, Type, TypeVar
|
|||
from pegen.tokenizer import Mark, Tokenizer, exact_token_types
|
||||
|
||||
T = TypeVar("T")
|
||||
P = TypeVar("P", bound="Parser")
|
||||
F = TypeVar("F", bound=Callable[..., Any])
|
||||
|
||||
|
||||
|
@ -21,7 +20,7 @@ def logger(method: F) -> F:
|
|||
"""
|
||||
method_name = method.__name__
|
||||
|
||||
def logger_wrapper(self: P, *args: object) -> T:
|
||||
def logger_wrapper(self: "Parser", *args: object) -> Any:
|
||||
if not self._verbose:
|
||||
return method(self, *args)
|
||||
argsr = ",".join(repr(arg) for arg in args)
|
||||
|
@ -41,7 +40,7 @@ def memoize(method: F) -> F:
|
|||
"""Memoize a symbol method."""
|
||||
method_name = method.__name__
|
||||
|
||||
def memoize_wrapper(self: P, *args: object) -> T:
|
||||
def memoize_wrapper(self: "Parser", *args: object) -> Any:
|
||||
mark = self._mark()
|
||||
key = mark, method_name, args
|
||||
# Fast path: cache hit, and not verbose.
|
||||
|
@ -74,11 +73,13 @@ def memoize(method: F) -> F:
|
|||
return cast(F, memoize_wrapper)
|
||||
|
||||
|
||||
def memoize_left_rec(method: Callable[[P], Optional[T]]) -> Callable[[P], Optional[T]]:
|
||||
def memoize_left_rec(
|
||||
method: Callable[["Parser"], Optional[T]]
|
||||
) -> Callable[["Parser"], Optional[T]]:
|
||||
"""Memoize a left-recursive symbol method."""
|
||||
method_name = method.__name__
|
||||
|
||||
def memoize_left_rec_wrapper(self: P) -> Optional[T]:
|
||||
def memoize_left_rec_wrapper(self: "Parser") -> Optional[T]:
|
||||
mark = self._mark()
|
||||
key = mark, method_name, ()
|
||||
# Fast path: cache hit, and not verbose.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue