summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-09-26 22:46:17 +0200
committerGitHub <noreply@github.com>2021-09-26 22:46:17 +0200
commit162cbfef2d7cd62509241261fb976828dd1423af (patch)
tree42a16785d5c0a4493a35a0a6e6b09665279d4826
parent2c0e27330f494856799de9fd9cfb02fa71dacf27 (diff)
downloadpylint-git-162cbfef2d7cd62509241261fb976828dd1423af.tar.gz
Add ``no-implicit-optional`` flag to ``mypy`` (#5075)
-rw-r--r--pylint/checkers/imports.py4
-rw-r--r--pylint/checkers/stdlib.py4
-rw-r--r--pylint/checkers/utils.py2
-rw-r--r--pylint/graph.py5
-rw-r--r--pylint/message/message_definition.py2
-rw-r--r--pylint/message/message_handler_mix_in.py2
-rw-r--r--setup.cfg1
-rw-r--r--tests/test_self.py2
8 files changed, 13 insertions, 9 deletions
diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py
index d887cd3ff..05f1a28e9 100644
--- a/pylint/checkers/imports.py
+++ b/pylint/checkers/imports.py
@@ -51,7 +51,7 @@ import copy
import os
import sys
from distutils import sysconfig
-from typing import Any, Dict, List, Set, Tuple, Union
+from typing import Any, Dict, List, Optional, Set, Tuple, Union
import astroid
from astroid import nodes
@@ -424,7 +424,7 @@ class ImportsChecker(DeprecatedMixin, BaseChecker):
)
def __init__(
- self, linter: PyLinter = None
+ self, linter: Optional[PyLinter] = None
): # pylint: disable=super-init-not-called # See https://github.com/PyCQA/pylint/issues/4941
BaseChecker.__init__(self, linter)
self.stats: CheckerStats = {}
diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py
index 508c358e1..0eb47296e 100644
--- a/pylint/checkers/stdlib.py
+++ b/pylint/checkers/stdlib.py
@@ -39,7 +39,7 @@
import sys
from collections.abc import Iterable
-from typing import Any, Dict, Set
+from typing import Any, Dict, Optional, Set
import astroid
from astroid import nodes
@@ -447,7 +447,7 @@ class StdlibChecker(DeprecatedMixin, BaseChecker):
}
def __init__(
- self, linter: PyLinter = None
+ self, linter: Optional[PyLinter] = None
): # pylint: disable=super-init-not-called # See https://github.com/PyCQA/pylint/issues/4941
BaseChecker.__init__(self, linter)
self._deprecated_methods: Set[Any] = set()
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 87c12433d..d37c8ab5d 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -674,7 +674,7 @@ def is_attr_private(attrname: str) -> Optional[Match[str]]:
def get_argument_from_call(
- call_node: nodes.Call, position: int = None, keyword: str = None
+ call_node: nodes.Call, position: Optional[int] = None, keyword: Optional[str] = None
) -> nodes.Name:
"""Returns the specified argument from a function call.
diff --git a/pylint/graph.py b/pylint/graph.py
index 2dc3bae99..038db7e4e 100644
--- a/pylint/graph.py
+++ b/pylint/graph.py
@@ -26,6 +26,7 @@ import shutil
import subprocess
import sys
import tempfile
+from typing import Optional
def target_info_from_filename(filename):
@@ -82,7 +83,9 @@ class DotBackend:
source = property(get_source)
- def generate(self, outputfile: str = None, mapfile: str = None) -> str:
+ def generate(
+ self, outputfile: Optional[str] = None, mapfile: Optional[str] = None
+ ) -> str:
"""Generates a graph file.
:param str outputfile: filename and path [defaults to graphname.png]
diff --git a/pylint/message/message_definition.py b/pylint/message/message_definition.py
index 30dacb32f..31fbeb08d 100644
--- a/pylint/message/message_definition.py
+++ b/pylint/message/message_definition.py
@@ -20,7 +20,7 @@ class MessageDefinition:
scope: str,
minversion: Optional[Tuple[int, int]] = None,
maxversion: Optional[Tuple[int, int]] = None,
- old_names: List[Tuple[str, str]] = None,
+ old_names: Optional[List[Tuple[str, str]]] = None,
):
self.checker_name = checker.name
self.check_msgid(msgid)
diff --git a/pylint/message/message_handler_mix_in.py b/pylint/message/message_handler_mix_in.py
index 90f40235a..185658d4a 100644
--- a/pylint/message/message_handler_mix_in.py
+++ b/pylint/message/message_handler_mix_in.py
@@ -74,7 +74,7 @@ class MessagesHandlerMixIn:
self,
msgid: str,
scope: str = "package",
- line: Union[bool, int] = None,
+ line: Union[bool, int, None] = None,
ignore_unknown: bool = False,
):
if not line:
diff --git a/setup.cfg b/setup.cfg
index 0416ceb30..7556523dc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -83,6 +83,7 @@ skip_glob = tests/functional/**,tests/input/**,tests/extensions/data/**,tests/re
src_paths = pylint
[mypy]
+no_implicit_optional = True
scripts_are_modules = True
warn_unused_ignores = True
diff --git a/tests/test_self.py b/tests/test_self.py
index 2b5daef84..a4a3ac794 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -141,7 +141,7 @@ class TestRunTC:
args: List[str],
reporter: Any = None,
out: Optional[StringIO] = None,
- code: int = None,
+ code: Optional[int] = None,
) -> None:
if out is None:
out = StringIO()