Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy: no_implicit_optional = False #6036

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ formats = sdist.tgz,bdist_wheel

[mypy]
ignore_missing_imports = True
no_implicit_optional = True
no_implicit_optional = False
strict_equality = True
warn_redundant_casts = True
warn_return_any = True
Expand Down
8 changes: 2 additions & 6 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,7 @@ class ExceptionInfo(Generic[_E]):

@classmethod
def from_exc_info(
cls,
exc_info: Tuple["Type[_E]", "_E", TracebackType],
exprinfo: Optional[str] = None,
cls, exc_info: Tuple["Type[_E]", "_E", TracebackType], exprinfo: str = None
) -> "ExceptionInfo[_E]":
"""returns an ExceptionInfo for an existing exc_info tuple.

Expand All @@ -429,9 +427,7 @@ def from_exc_info(
return cls(exc_info, _striptext)

@classmethod
def from_current(
cls, exprinfo: Optional[str] = None
) -> "ExceptionInfo[BaseException]":
def from_current(cls, exprinfo: str = None) -> "ExceptionInfo[BaseException]":
"""returns an ExceptionInfo matching the current traceback

.. warning::
Expand Down
6 changes: 1 addition & 5 deletions src/_pytest/config/findpaths.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from typing import List
from typing import Optional

import py

Expand Down Expand Up @@ -108,10 +107,7 @@ def get_dir_from_path(path):


def determine_setup(
inifile: str,
args: List[str],
rootdir_cmd_arg: Optional[str] = None,
config: Optional["Config"] = None,
inifile: str, args: List[str], rootdir_cmd_arg: str = None, config: "Config" = None
):
dirs = get_dirs_from_args(args)
if inifile:
Expand Down
15 changes: 5 additions & 10 deletions src/_pytest/outcomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class OutcomeException(BaseException):
contain info about test and collection outcomes.
"""

def __init__(self, msg: Optional[str] = None, pytrace: bool = True) -> None:
def __init__(self, msg: str = None, pytrace: bool = True) -> None:
if msg is not None and not isinstance(msg, str):
error_msg = (
"{} expected string as 'msg' parameter, got '{}' instead.\n"
Expand Down Expand Up @@ -45,10 +45,7 @@ class Skipped(OutcomeException):
__module__ = "builtins"

def __init__(
self,
msg: Optional[str] = None,
pytrace: bool = True,
allow_module_level: bool = False,
self, msg: str = None, pytrace: bool = True, allow_module_level: bool = False
) -> None:
OutcomeException.__init__(self, msg=msg, pytrace=pytrace)
self.allow_module_level = allow_module_level
Expand All @@ -63,9 +60,7 @@ class Failed(OutcomeException):
class Exit(Exception):
""" raised for immediate program exits (no tracebacks/summaries)"""

def __init__(
self, msg: str = "unknown reason", returncode: Optional[int] = None
) -> None:
def __init__(self, msg: str = "unknown reason", returncode: int = None) -> None:
self.msg = msg
self.returncode = returncode
super().__init__(msg)
Expand All @@ -74,7 +69,7 @@ def __init__(
# exposed helper methods


def exit(msg: str, returncode: Optional[int] = None) -> "NoReturn":
def exit(msg: str, returncode: int = None) -> "NoReturn":
"""
Exit testing process.

Expand Down Expand Up @@ -155,7 +150,7 @@ def xfail(reason: str = "") -> "NoReturn":


def importorskip(
modname: str, minversion: Optional[str] = None, reason: Optional[str] = None
modname: str, minversion: str = None, reason: Optional[str] = None
) -> Any:
"""Imports and returns the requested module ``modname``, or skip the
current test if the module cannot be imported.
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def raises(
def raises( # noqa: F811
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
*args: Any,
match: Optional[Union[str, "Pattern"]] = None,
match: Union[str, "Pattern"] = None,
**kwargs: Any
) -> Union["RaisesContext[_E]", Optional[_pytest._code.ExceptionInfo[_E]]]:
r"""
Expand Down Expand Up @@ -725,7 +725,7 @@ def __init__(
self,
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
message: str,
match_expr: Optional[Union[str, "Pattern"]] = None,
match_expr: Union[str, "Pattern"] = None,
) -> None:
self.expected_exception = expected_exception
self.message = message
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def warns(
def warns( # noqa: F811
expected_warning: Union["Type[Warning]", Tuple["Type[Warning]", ...]],
*args: Any,
match: Optional[Union[str, "Pattern"]] = None,
match: Union[str, "Pattern"] = None,
**kwargs: Any
) -> Union["WarningsChecker", Any]:
r"""Assert that code raises a particular class of warning.
Expand Down Expand Up @@ -207,7 +207,7 @@ def __init__(
expected_warning: Optional[
Union["Type[Warning]", Tuple["Type[Warning]", ...]]
] = None,
match_expr: Optional[Union[str, "Pattern"]] = None,
match_expr: Union[str, "Pattern"] = None,
) -> None:
super().__init__()

Expand Down