diff options
Diffstat (limited to 'pylint/utils/pragma_parser.py')
-rw-r--r-- | pylint/utils/pragma_parser.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py index cbff8b26a..f1c1c2224 100644 --- a/pylint/utils/pragma_parser.py +++ b/pylint/utils/pragma_parser.py @@ -3,7 +3,7 @@ import re from collections import namedtuple -from typing import Generator, List +from typing import Generator, List, Optional # Allow stopping after the first semicolon/hash encountered, # so that an option can be continued with the reasons @@ -52,7 +52,7 @@ TOK_REGEX = "|".join( ) -def emit_pragma_representer(action, messages): +def emit_pragma_representer(action: str, messages: List[str]) -> PragmaRepresenter: if not messages and action in MESSAGE_KEYWORDS: raise InvalidPragmaError( "The keyword is not followed by message identifier", action @@ -65,7 +65,7 @@ class PragmaParserError(Exception): A class for exceptions thrown by pragma_parser module """ - def __init__(self, message, token): + def __init__(self, message: str, token: str) -> None: """ :args message: explain the reason why the exception has been thrown :args token: token concerned by the exception @@ -88,7 +88,7 @@ class InvalidPragmaError(PragmaParserError): def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]: - action = None + action: Optional[str] = None messages: List[str] = [] assignment_required = False previous_token = "" @@ -113,7 +113,9 @@ def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None] raise InvalidPragmaError("Missing keyword before assignment", "") assignment_required = False elif assignment_required: - raise InvalidPragmaError("The = sign is missing after the keyword", action) + raise InvalidPragmaError( + "The = sign is missing after the keyword", action or "" + ) elif kind == "KEYWORD": if action: yield emit_pragma_representer(action, messages) |